<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function() {
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
////////////////////////////////////// start below this line ˇˇˇˇˇˇˇˇˇˇ
//Rectangle
var x =0;
var y =0;
var width = canvas.width;
var height = canvas.height;
var startx = 800
var starty = 600
var endx = 0
var endy = 0
//Rectangle
context.beginPath();
context.rect(x,y,width,height);
//Rect Color
var grd= context.createLinearGradient(startx, starty, endx, endy);
grd.addColorStop(0,'rgb(100,0,100)');
grd.addColorStop(.5,'rgb(200,0,200)');
grd.addColorStop(1,'rgb(255,0,255)');
context.fillStyle=grd;
context.lineWidth = 0;
context.fill();
context.strokeStyle = 'rgb(155,0,155)';
context.stroke();
//Heart
var xa = 400;
var ya = 160;
var xb = 400;
var yb = 400;
var controlx1 = 260;
var controly1 = -50;
var controlx2 = 125;
var controly2 = 255;
var controlx3 = 660;
var controly3 = 255;
var controlx4 = 535;
var controly4 = -50;
context.beginPath();
context.moveTo(xa, ya);
context.bezierCurveTo(controlx1, controly1, controlx2, controly2, xb, yb);
context.bezierCurveTo(controlx3, controly3, controlx4, controly4, xa, ya);
context.lineWidth = 30;
//Heart Color
context.linestrokeStyle = 'rgb(0, 0, 0)';
context.lineCap = 'round';
context.stroke();
context.fillStyle = 'rgb(255, 0, 255)';
context.fill()
////////////////////////////////////// end above this line ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ
};
</script>
</head>
<body>
<canvas id="myCanvas" width="800" height="600"></canvas>
</body>
</html>
No comments:
Post a Comment