<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function() {
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
////////////////////////////////////// start below this line ˇˇˇˇˇˇˇˇˇˇ
////////////////////////////SKY///////////////
var x = 0;
var y = 0;
var width = 800;
var height = 200;
context.beginPath();
context.rect(x,y,width,height);
// context.fillStyle = 'green';
// add linear gradient
var grd = context.createLinearGradient(800, 150, 800, 0);
// STARTING COLOR
grd.addColorStop(0, "#FF3300");
// INTERMEDIATE COLOR
grd.addColorStop(0.5, "#990000");
// ENDING COLOR
grd.addColorStop(1, "#660066");
context.fillStyle = grd;
context.fill();
context.closePath();
//////////////////////SEA/////////////
var x = 0;
var y = 200;
var width = 800;
var height = 100;
context.beginPath();
context.rect(x,y,width,height);
// context.fillStyle = 'green';
// add linear gradient
var grd = context.createLinearGradient(400, 200, 400, 300);
// STARTING COLOR
grd.addColorStop(1, "#00CCFF");
// ENDING COLOR
grd.addColorStop(0.25, "#000066");
context.fillStyle = grd;
context.fill();
context.closePath();
/////////////////////SAND/////////////
context.beginPath();
context.rect(0, 300, 800, 600);
context.fillStyle = "#FFCC99";
context.fill();
context.lineWidth = 5;
context.strokeStyle = "#FFCC99";
context.stroke();
context.closePath();
////////////////////////////////////////////////////
};
</script>
</head>
<body>
<canvas id="myCanvas" width="800" height="600"></canvas>
</body>
</html>
No comments:
Post a Comment