<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function() {
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
////////////////////////////////////// start below this line ˇˇˇˇˇˇˇˇˇˇ
//background
context.beginPath();
context.rect(0, 0, 800, 600);
//context.fillStyle= 'rgb(153,102,255)';
var grd = context.createLinearGradient(400, 0, 400, 600);
grd.addColorStop(0, 'rgb(153,102,255)');
grd.addColorStop(1,'rgb(102,255,255)');
context.fillStyle= grd;
context.fill();
context.strokeStyle = 'rgb(153,102,255)'
context.stroke();
//heart bezier
//hearttop right
context.beginPath();
context.moveTo(400,200);
context.bezierCurveTo(300, 0, 100, 200, 250, 325);
//begin heart bottom right
context.quadraticCurveTo(400, 450 , 400, 500);
context.quadraticCurveTo(400, 435 , 550, 325);
//hearttop left
context.bezierCurveTo(700, 200, 500, 0, 400, 200);
context.fillStyle = 'rgb(255,102,204)';
context.fill();
context.lineWidth=6;
context.lineCap= 'round'
context.strokeStyle = 'rgb(204,0,204)';
context.stroke();
////////////////////////////////////// end above this line ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ
};
</script>
</head>
<body>
<canvas id="myCanvas" width="800" height="600"></canvas>
</body>
</html>
No comments:
Post a Comment