Skip to content
Snippets Groups Projects
Commit b21d9c31 authored by Evelim Carla Ribeiro's avatar Evelim Carla Ribeiro
Browse files

primeiro commit

parents
No related branches found
No related tags found
No related merge requests found
<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="700" height="400" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.</canvas>
<script>
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.beginPath();
var y1 = 20;
var y2 = 100;
var x1 = 20;
var x2 = 100;
ctx.moveTo(x1,y1);//posicao inicial
ctx.lineTo(x2,y1);
<!--ctx.moveTo(x2,y1);-->
<!--ctx.lineTo(x2,y2);-->
ctx.moveTo(x2,y2);
ctx.lineTo(x1,y2);
ctx.moveTo(x1,y2);
ctx.lineTo(x1,y1);
<!--penta-->
ctx.moveTo(150,60);
ctx.lineTo(x2,y2);
ctx.moveTo(x2,y1);
ctx.lineTo(150,60);
function Shape(x, y, w, h, fill) {
// This is a very simple and unsafe constructor.
// All we're doing is checking if the values exist.
// "x || 0" just means "if there is a value for x, use that. Otherwise use 0."
this.x = x || 0;
this.y = y || 0;
this.w = w || 1;
this.h = h || 1;
this.fill = fill || '#AAAAAA';
}
// Draws this shape to a given context
Shape.prototype.draw = function(ctx) {
ctx.fillStyle = this.fill;
ctx.fillRect(this.x, this.y, this.w, this.h);
}
ctx.stroke();
</script>
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment