MY CODE:
<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function() {
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
////////////////////////////////////// start below this line ˇˇˇˇˇˇˇˇˇˇ
var x1 =50;
var y1 =50;
var x2 =750;
var y2 =500;
var rectx1 = 50;
var recty1 = 100;
var rectwidth1 = 300;
var rectheight1 = 250;
var grd = context.createLinearGradient(rectx1, recty1, rectx1+rectwidth1, recty1+rectheight1);
var rectx2 = 300;
var recty2 = 300;
var rectwidth2 = 200;
var rectheight2 = 300;
var x3= 300;
var y3= 60;
var x4= 100;
var y4= 500;
var rectx3 = 555;
var recty3 = 100;
var rectwidth3 = 150;
var rectheight3 = 150;
var x5= 600;
var y5= 150;
var x6= 550;
var y6= 500;
//orange line
context.beginPath();
context.moveTo(x3,y4);
context.lineTo(x1,y6);
context.lineWidth = 10;
context.strokeStyle = 'rgb(255,165,0)';
context.lineCap = 'butt';
context.stroke();
//light blue line
context.beginPath();
context.moveTo(x1,y1);
context.lineTo(x2,y2);
context.lineWidth = 5;
context.strokeStyle = 'rgb(0,250,250)';
context.lineCap = 'round';
context.stroke();
//red and yellow rectangle2
context.beginPath();
context.rect(rectx3,recty1,rectwidth2,rectheight2);
context.lineWidth = 15;
context.strokeStyle = 'rgb(250,250,100)';
context.fillStyle = 'red';
context.fill();
context.stroke();
//light blue line
context.beginPath();
context.moveTo(x1,y5);
context.lineTo(x2,y3);
context.lineWidth = 10;
context.strokeStyle = 'rgb(100,200,250)';
context.lineCap = 'round';
context.stroke();
// rectangle 1
context.beginPath();
context.rect(rectx1,recty1,rectwidth1,rectheight1);
context.lineWidth = 10;
context.strokeStyle = 'rgb(235,280,0)';
// starting gradient color
grd.addColorStop(0, "rgb(235,281,0)");
//intermediate color
grd.addColorStop(0.5, "rgb(193,24,0)");
// ending color
grd.addColorStop(1, "rgb(255,100,0)");
context.fillStyle = grd;
context.fill();
context.stroke();
//Simple V line in purple
var x= 50;
var y = 100;
var x1 = 300;
var y1 = 450;
var x2 = 400;
var y2 = 300
var x3 = 500;
var y3 = 450
var x4 = 700;
var y4 = 100
//comment
context.beginPath();
context.moveTo(x, y);
context.lineTo(x1, y1); // move to starting coordinates
context.lineTo(x2, y2); // draw line to following point
context.lineTo(x3, y3)
context.lineTo(x4, y4)
context.lineCap = 'round';
context.lineWidth = 30;// declare the width in pixels of the line
context.strokeStyle = 'rgb(100,0,205)'; // or "#FF0000" // declare the line color in rgb or hexadecimal values
context.stroke();
////////////////////////////////////// end above this line ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ
};
</script>
</head>
<body>
<canvas id="myCanvas" width="800" height="600"></canvas>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function() {
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
////////////////////////////////////// start below this line ˇˇˇˇˇˇˇˇˇˇ
var x1 =50;
var y1 =50;
var x2 =750;
var y2 =500;
var rectx1 = 50;
var recty1 = 100;
var rectwidth1 = 300;
var rectheight1 = 250;
var grd = context.createLinearGradient(rectx1, recty1, rectx1+rectwidth1, recty1+rectheight1);
var rectx2 = 300;
var recty2 = 300;
var rectwidth2 = 200;
var rectheight2 = 300;
var x3= 300;
var y3= 60;
var x4= 100;
var y4= 500;
var rectx3 = 555;
var recty3 = 100;
var rectwidth3 = 150;
var rectheight3 = 150;
var x5= 600;
var y5= 150;
var x6= 550;
var y6= 500;
//orange line
context.beginPath();
context.moveTo(x3,y4);
context.lineTo(x1,y6);
context.lineWidth = 10;
context.strokeStyle = 'rgb(255,165,0)';
context.lineCap = 'butt';
context.stroke();
//light blue line
context.beginPath();
context.moveTo(x1,y1);
context.lineTo(x2,y2);
context.lineWidth = 5;
context.strokeStyle = 'rgb(0,250,250)';
context.lineCap = 'round';
context.stroke();
//red and yellow rectangle2
context.beginPath();
context.rect(rectx3,recty1,rectwidth2,rectheight2);
context.lineWidth = 15;
context.strokeStyle = 'rgb(250,250,100)';
context.fillStyle = 'red';
context.fill();
context.stroke();
//light blue line
context.beginPath();
context.moveTo(x1,y5);
context.lineTo(x2,y3);
context.lineWidth = 10;
context.strokeStyle = 'rgb(100,200,250)';
context.lineCap = 'round';
context.stroke();
// rectangle 1
context.beginPath();
context.rect(rectx1,recty1,rectwidth1,rectheight1);
context.lineWidth = 10;
context.strokeStyle = 'rgb(235,280,0)';
// starting gradient color
grd.addColorStop(0, "rgb(235,281,0)");
//intermediate color
grd.addColorStop(0.5, "rgb(193,24,0)");
// ending color
grd.addColorStop(1, "rgb(255,100,0)");
context.fillStyle = grd;
context.fill();
context.stroke();
//Simple V line in purple
var x= 50;
var y = 100;
var x1 = 300;
var y1 = 450;
var x2 = 400;
var y2 = 300
var x3 = 500;
var y3 = 450
var x4 = 700;
var y4 = 100
//comment
context.beginPath();
context.moveTo(x, y);
context.lineTo(x1, y1); // move to starting coordinates
context.lineTo(x2, y2); // draw line to following point
context.lineTo(x3, y3)
context.lineTo(x4, y4)
context.lineCap = 'round';
context.lineWidth = 30;// declare the width in pixels of the line
context.strokeStyle = 'rgb(100,0,205)'; // or "#FF0000" // declare the line color in rgb or hexadecimal values
context.stroke();
////////////////////////////////////// end above this line ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ
};
</script>
</head>
<body>
<canvas id="myCanvas" width="800" height="600"></canvas>
</body>
</html>
Comments
Post a Comment