JS Drawing Line (instance code) _javascript Tips

Source: Internet
Author: User

IE below draw line

Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<style type= "Text/css" >
v/:* {behavior:url (#default #vml);}
</style>
<body>
<v:line
From= ' 200,200 '
To= ' 300,100 '
style= ' Position:absolute;z-index:8 ' >
</v:line>
</body>

<script>
var R =function () {};
R.prototype.createline = function (Startx,starty,endx,endy) {
var le = document.createelement ("<v:line><v:line>");
Le.from = StartX + ', ' + starty;
le.to = EndX + ', ' + EndY;
Le.strokecolor= "Red";
Le.strokeweight= "1pt";
Return le;
}
var d =new R ();
Document.body.appendChild (D.createline (1,1,200,100));
</script>


FF Drawing Line
Copy Code code as follows:

<title>a Canvas fillrect, strokerect and Clearrect example</title>
<meta name= "Dc.creator" content= "Kamiel martinet, http://www.martinet.nl/" >
<meta name= "Dc.publisher" content= "Mozilla Developer Center, http://developer.mozilla.org" >
<script type= "Text/javascript" >
function Drawshape () {
Get the canvas element using the DOM
var canvas = document.getElementById (' tutorial ');

Make sure we don ' t execute canvas isn ' t supported

if (Canvas.getcontext) {

Use GetContext to use the canvas for drawing
var ctx = Canvas.getcontext (' 2d ');

Draw shapes
Ctx.fillrect (25,25,100,100);
Ctx.clearrect (45,45,60,60);
Ctx.strokerect (50,50,50,50);

Ctx.beginpath ();
Ctx.moveto (100,100);
Ctx.lineto (200,250);
Ctx.lineto (50,250);
Ctx.closepath ();
Ctx.stroke ();

} else {
Alert (' Your need Safari or Firefox 1.5+ to the ');
}
}
</script>
<style type= "Text/css" >
</style>

<body onload= "Drawshape ();" >
<div>
<canvas id= "Tutorial" width= "height=" ></canvas>
</div>
</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.