Tuesday, September 15, 2015
Sunset
Sunset behind mountains.
Here is the coding for the image:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title> here goes the title of your project </title>
<style type="text/css">
body,td,th {
font-family: Helvetica, Arial, sans-serif;
font-size: 12px;
color: #000;
}
body {
background-color: #FFF;
}
#myCanvas { border: rgb(102,0,255) medium dashed; }
</style>
</head>
<body>
<canvas id="myCanvas" width="800" height="600"></canvas>
<script>
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
//// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> START HERE
context.rect(0, 0, canvas.width, canvas.height);
// create radial gradient
var nuhnight = context.createRadialGradient(230, 350, 80, 230, 75, 600);
// yellow
nuhnight.addColorStop(0, '#F2B93F');
//orange
nuhnight.addColorStop(0.25, '#FA5534');
//red
nuhnight.addColorStop(0.5, '#FA344C');
//pink
nuhnight.addColorStop(0.75, '#FF69AF');
// blue
nuhnight.addColorStop(1, '#4D9EF0');
context.fillStyle = nuhnight;
context.fill();
//mountains
context.beginPath();
context.moveTo(-45,600); //a - starting point
context.lineTo(75,275); //b
context.lineTo(105,376); //c
context.lineTo(150,330); //d
context.lineTo(210,465); //e
context.lineTo(300,350) //f
context.lineTo(400,555); //g
context.lineTo(450,450); //h
context.lineTo(500,500); //i
context.lineTo(575,300); //j
context.lineTo(650,505); //k
context.lineTo(720,360); //l
context.lineTo(860,600); //m
context.lineTo(0,600); //n - ending point
context.lineWidth = 20;
context.lineCap = "square";
context.fillStyle = 'black';
context.fill();
context.strokeStyle = "black";
context.stroke();
context.closePath();
//// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< END HERE
</script>
</body>
</html>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment