Home

Home
"There are places I remember all my life." The Beatles

Wednesday, February 6, 2013

First attempt at heart assignment!..I only used 2 curves so it is a slightly funny shape!

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

////////////////////////////////////// start below this line ˇˇˇˇˇˇˇˇˇˇ
var rectx1 = 0;
var recty1 = 0;
var rectwidth1 = 800;
var rectheight1 = 600;
var startx = 400
var starty = 0
var endx = 400
var endy = 800

//rectangle
context.beginPath();
context.rect(rectx1, recty1, rectwidth1, rectheight1);
context.strokeStyle = 'rgb(153, 102, 255)';
//context.fillStyle = 'rgb(255, 204, 204)';
var grd = context.createLinearGradient (startx, starty, endx, endy);
grd.addColorStop (0, 'rgb(102, 255, 255)');
grd.addColorStop (1, 'rgb(255, 0, 255)');
context.fillStyle = grd;
context.fill();
context.stroke();

//left curve
context.beginPath();
context.moveTo (300, 225);
context.bezierCurveTo (150, 25, 125, 350, 300, 450);
context.bezierCurveTo (475, 350, 450, 25, 300, 225);
context.closePath();
context.fillStyle = 'rgb(255, 100, 150)';
context.fill();
context.lineWidth = 7;
context.strokeStyle = 'maroon'
context.lineCap = 'round';
context.stroke();



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

};

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

No comments:

Post a Comment