Monday, September 10, 2012

Homework: Heart





<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function() {
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");

////////////////////////////////////// start below this line ˇˇˇˇˇˇˇˇˇˇ

var grdstartX = 0;
var grdstartY = 250;
var grdendX = 300;
var grdendY = 300;


//Rectangle
context.beginPath();
context.rect(0, 0, 400, 300);
//context.fillStyle = 'rgb(100, 100, 255)';
var grd = context.createLinearGradient(grdstartX, grdstartY, grdendX, grdendY);
grd.addColorStop(0, 'rgb(200, 200, 255)');
grd.addColorStop(1, 'rgb(100, 100, 255)');
context.fillStyle = grd;
context.fill();
context.stroke();

//Heart
context.beginPath();
context.lineCap = "round";
context.lineWidth = 15;
context.strokeStyle = "rgb(200, 0, 0)";
context.fillStyle = "rgb(200, 0, 0)";
context.moveTo(100, 85);
context.quadraticCurveTo(80,150,200, 215);
context.quadraticCurveTo(320, 150,300, 90);
context.quadraticCurveTo(280, 30, 200, 90);
context.quadraticCurveTo(120, 30, 100, 90);
context.stroke();
context.fill();








////////////////////////////////////// end above this line ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ

};

</script>
</head>
<body>
<canvas id="myCanvas" width="800" height="600"></canvas>
</body>
</html>

No comments:

Post a Comment