Wednesday, September 19, 2012

Project 1


HTML 5 code was a new learning experience for me. With a lot of time and effort I was able to create this picture. I think I was pretty successful considering the struggles I faced throughout this process.



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

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


//sky
context.beginPath();
context.rect(0, 0, canvas.width, canvas.height);
var grd=context.createRadialGradient(0, 0, 400, 800, 400, 400);
grd.addColorStop(0, 'blue');
grd.addColorStop(1, 'green');
context.fillStyle = grd;
context.fill();
context.stroke();


//sun
context.beginPath();
context.arc(400, 200, 100, 0 , 2 * Math.PI, false);
var grd = context.createLinearGradient(300, 200, 500, 200);
grd.addColorStop(0, 'rgb(255,255,0)');
grd.addColorStop(1, 'rgb(255,0,0)');
context.fillStyle = grd;
context.fill();

//lines
context.moveTo(400,100);
context.lineTo(400,0);
context.moveTo(450,110);
context.lineTo(500,0);
context.moveTo(350,110);
context.lineTo(300,0);
context.moveTo(490,160);
context.lineTo(600,70);
context.moveTo(310,160);
context.lineTo(200,70);
context.moveTo(500,200);
context.lineTo(650,200);
context.moveTo(300,200);
context.lineTo(150,200);
context.moveTo(310,250);
context.lineTo(200,310);
context.moveTo(490,250);
context.lineTo(600,310);
context.moveTo(450,290);
context.lineTo(465,340);
context.moveTo(350,290);
context.lineTo(315,350);
context.moveTo(400,300);
context.lineTo(400,370);
context.lineWidth = 10;
context.strokeStyle = 'orange';
context.stroke();

//water
context.beginPath();
context.moveTo(0,365);
context.quadraticCurveTo(70, 365, 100, 300);
context.quadraticCurveTo(95, 365, 200, 365);
context.quadraticCurveTo(250, 365, 300, 300);
context.quadraticCurveTo(280, 365, 400, 365);
context.quadraticCurveTo(450, 365, 500, 300);
context.quadraticCurveTo(480, 365, 600, 365);
context.quadraticCurveTo(650, 365, 700, 300);
context.quadraticCurveTo(680, 365, 800, 365);
context.lineTo(800,400);
context.lineTo(0,400);
context.fillStyle = 'lightblue';
context.fill();
 
//sand
context.beginPath();
context.rect(0, 400, canvas.width, 400)
context.fillStyle = 'rgb(200, 150, 0)';
context.fill();

//umbrella
context.beginPath();
context.moveTo(100,550);
context.lineTo(100,370);
context.strokeStyle = 'rgb(0,200,220)';
context.stroke();

context.beginPath();
context.moveTo(25,385);
context.quadraticCurveTo(100, 200, 175, 385);
context.moveTo(25,385);
context.quadraticCurveTo(100, 365, 175, 385);
context.strokeStyle = 'rgb(0,200,220)';
var grd = context.createLinearGradient(25, 300, 185, 300);
grd.addColorStop(0, 'rgb(0,255,255)');
grd.addColorStop(1, 'rgb(0,255,0)');
context.fillStyle = grd;
context.fill();

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

};

</script>
</head>
<body>
<canvas id="myCanvas" width="800" height="600"></canvas>
</body>
</html>
<head>
<script>
window.onload = function() {
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");

No comments:

Post a Comment