diff --git a/task3.html b/task3.html index 7a9d6fe3d6916ea12b06eb1998cdd75268b7af3b..ff3902296b9770edde6d6ca622a872016f8ee999 100644 --- a/task3.html +++ b/task3.html @@ -9,19 +9,38 @@ <canvas id="myCanvas" width="800" height="600" style="border:1px solid #d3d3d3;"> Your browser does not support the HTML5 canvas tag.</canvas> -<script> +<script type="text/javascript"> var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); +var linhas[]; + +function criaLinha(xOrig,xDest,yOrig,yDest) { + var l = new Object(); + l.xOrig = xOrig; + l.xDest = xDest; + l.yOrig = yOrig; + l.yDest = yDest; + return l; +} +function desenhaLinha(l){ -function createLine(xOrig,yOrig,xDest,yDest) { - var line = new Object(); - line.xOrig = xOrig; - line.yOrig = yOrig; - line.xDest = xDest; - line.yDest = yDest; - return line; + ctx.beginPath(); + ctx.moveTo(l.xOrig,l.yOrig); + ctx.lineTo(l.xDest,l.yDest); + ctx.stroke(); + +} + +function initPage(){ + var l = new Object(); + l.xOrig = 50; + l.xDest = 700; + l.yOrig = 50; + l.yDest = 500; + //linhas.criaLinha(50,700,50,500); + desenhaLinha(l[0]); } function criarPoligono(){ @@ -107,8 +126,7 @@ Shape.prototype.draw = function(ctx) { ctx.fillRect(this.x, this.y, this.w, this.h); } - - +initPage(); </script>