Canvas Assignment #2
Image on Chrome: file:///Users/reginaacra/Desktop/ART%20210%20-%20CANVAS%20PROJECT.webarchive
Code:
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title> ART 210 - CANVAS PROJECT </title>
<style type="text/css">
body,td,th {
font-family: Helvetica, Arial, sans-serif;
font-size: 12px;
color: rgba(0,0,0,1);
}
body {
background-color: rgba(255,255,255,1);
}
#myCanvas { border: rgba(102,0,255,1) medium dashed; }
</style>
</head>
<body>
<canvas id="myCanvas" width="900" height="800"></canvas>
<script>
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
//// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> YOUR CODE STARTS HERE
// oval big
// var canvas = document.getElementById('myCanvas');
// var context = canvas.getContext('2d');
var centerX = 0;
var centerY = 0;
var radius = 190;
// save state
context.save();
// translate context
context.translate(canvas.width / 2, canvas.height / 1.6);
// scale context horizontally
context.scale(2, 1);
// draw circle which will be stretched into an oval
context.beginPath();
context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
// restore to original state
context.restore();
// apply styling
context.fillStyle = '#FFA07A';
context.lineWidth = 5;
context.strokeStyle = '#FFA07A';
context.stroke();
context.closePath();
context.fill();
context.lineWidth = 2;
context.strokeStyle = '#FF7F50';
context.stroke();
// oval small
var centerX = 0;
var centerY = 100;
var radius = 150;
// save state
context.save();
// translate context
context.translate(canvas.width / 2, canvas.height / 2);
// scale context horizontally
context.scale(2, 1);
// draw circle which will be stretched into an oval
context.beginPath();
context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
// restore to original state
context.restore();
// apply styling
context.fillStyle = '#FFA07A';
context.lineWidth = 5;
context.strokeStyle = '#FFA07A';
context.stroke();
context.closePath();
context.fill();
context.lineWidth = 2;
context.strokeStyle = '#FF7F50';
context.stroke();
// Cup
// var canvas = document.getElementById('myCanvas');
// var context = canvas.getContext('2d');
context.beginPath();
context.arc(440,300, 310, 0, Math.PI, false);
context.closePath();
context.lineWidth = 30;
// context.fillStyle = 'orange';
// add linear gradient
var grd = context.createLinearGradient(0, 0, canvas.width, canvas.height);
// light blue
grd.addColorStop(0, '#87CEEB');
// dark blue
grd.addColorStop(1, '#6A5ACD');
context.fillStyle = grd;
context.fill();
// context.strokeStyle = 'orange';
// context.stroke();
// handle of cup
//Arc
context.beginPath();
context.arc(700,450,100,250, .7*Math.PI, false);
context.lineWidth = 30;
context.strokeStyle = '#6A5ACD';
context.stroke();
//Bezier curve
// starting point coordinates
var startX = 0;
var startY = canvas.height/2;
// control point 1 coordinates ( magnet )
var cpointX1 = canvas.width / 4;
var cpointY1 = canvas.height / 2 + 200;
// control point 2 coordinates ( magnet )
var cpointX2 = canvas.width * 3/4;
var cpointY2 = canvas.height / 2 - 200;
// ending point coordinates
var endX = canvas.width;
var endY = canvas.height/2;
context.beginPath();
context.moveTo(300, 250);
context.bezierCurveTo(100,200,450,100,300,10);
context.lineWidth = 15;
context.strokeStyle = "#F5F5F5";
context.stroke();
//Line 2
// starting point coordinates
var startX = 0;
var startY = canvas.height/2;
// control point 1 coordinates ( magnet )
var cpointX1 = canvas.width / 4;
var cpointY1 = canvas.height / 2 + 200;
// control point 2 coordinates ( magnet )
var cpointX2 = canvas.width * 3/4;
var cpointY2 = canvas.height / 2 - 200;
// ending point coordinates
var endX = canvas.width;
var endY = canvas.height/2;
context.beginPath();
context.moveTo(450, 250);
context.bezierCurveTo(300,100,600,200,450,20);
context.lineWidth = 15;
context.strokeStyle = "#F5F5F5";
context.stroke();
//Line 3
// starting point coordinates
var startX = 0;
var startY = canvas.height/2;
// control point 1 coordinates ( magnet )
var cpointX1 = canvas.width / 4;
var cpointY1 = canvas.height / 2 + 200;
// control point 2 coordinates ( magnet )
var cpointX2 = canvas.width * 3/4;
var cpointY2 = canvas.height / 2 - 200;
// ending point coordinates
var endX = canvas.width;
var endY = canvas.height/2;
context.beginPath();
context.moveTo(620, 250);
context.bezierCurveTo(480,100,800,200,580,20);
context.lineWidth = 15;
context.strokeStyle = "#F5F5F5";
context.stroke();
//// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< YOUR CODE ENDS HERE
// CHANGE THE CREDITS
context.beginPath();
context.font = 'bold 20px Arial';
context.fillStyle = "rgba(0,0,0,1)";
context.fillText('Regina Acra', 40, 750);
context.closePath();
</script>
</body>
</html>
Comments
Post a Comment