Monday, February 18, 2013
.:In Class Heart:.
In Class Heart:
Code:
<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function() {
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
////////////////////////////////////// start below this line ??????????
//Bezier Curve Variables
var x = 400;
var y = 100;
var controlX1 = 150;
var controlY1 = 30;
var controlX2 = 125;
var controlY2 = 175;
var endX = 300;
var endY = 350;
//Quadratic Curve Variables
var controlX3 = 400;
var controlY3 = 440;
var endX3 = 400;
var endY3 = 500;
//Quadratic Curve Variables
var controlX4 = 400;
var controlY4 = 400;
var endX4 = 500;
var endY4 = 300;
//Bezier Curve Variables
var controlX5 = 700;
var controlY5 = 150;
var controlX6 = 550;
var controlY6 = 30;
var endX5 = x;
var endY5 = y;
//Rectangle Variables
var rectX = 0;
var rectY = 0;
context.beginPath();
context.rect(rectX, rectY, canvas.width, canvas.height);
context.fillStyle = 'rgb(0, 204, 255)';
context.fill();
context.stroke();
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.closePath();
context.fillStyle = 'rgb(255, 51, 153)';
context.fill();
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