Wednesday, February 6, 2013
Heart
<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function() {
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
////////////////////////////////////// start below this line ˇˇˇˇˇˇˇˇˇˇ
//Rectangle (background)
context.beginPath();
context.rect(0, 0, 800, 600);
context.fillStyle = 'rgb(175,225,240)';
context.fill();
//Bezier curve variables
var x=390;
var y=175;
var controlX1=285;
var controlY1=25;
var controlX2= 125;
var controlY2= 175;
var endX= 300;
var endY= 340;
//Quadratic Curve (left)
var controlX3 = 350;
var controlY3 = 390;
var endX3 = 390;
var endY3 = 470;
//Quadratic curve (right)
var controlX4 = 415;
var controlY4 = 390;
var endX4 = 470;
var endY4 = 350;
//Bezier curve variables
var controlX5= 655;
var controlY5= 185;
var controlX6= 525;
var controlY6= 25;
var endX5= x;
var endY5= y;
context.beginPath();
context.moveTo(x,y);
context.bezierCurveTo(controlX1, controlY1, controlX2, controlY2, endX, endY);
context.quadraticCurveTo(controlX3, controlY3, endX3, endY3);
context.quadraticCurveTo(controlX4, controlY4, endX4, endY4);
context.bezierCurveTo(controlX5, controlY5, controlX6, controlY6, endX5, endY5);
context.fillStyle = 'rgb(242,141,68)';
context.fill();
context.strokeStyle = 'rgb(237,64,12)';
context.lineWidth = 5;
context.stroke();
////////////////////////////////////// end above this line ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ
};
</script>
</head>
<body>
<canvas id="myCanvas" width="800" height="600"></canvas>
</body>
</html>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment