A Non-Clockwork Orange by Carson Mann
This is my final Canvas Project and it was inspired by my favorite film and book A Clockwork Orange. The project took several days and continuous headaches to finish and I was very pleased when completed.
My 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="510" height="600"></canvas>
<script>
//// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> YOUR CODE STARTS HERE
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
///////////////////////////// Background
context.beginPath();
context.rect(0,0,550,600)
context.fillStyle='orange'
context.fill();
context.lineWidth ='5'
////////////////////////// Gradient
// Create gradient
var grd = context.createRadialGradient(475,50,15,490,60,100);
grd.addColorStop(0,"white");
grd.addColorStop(1,"orange");
context.fillStyle = grd;
context.fill();
////////////////////////////////////////////////////////////////////////// Hat
context.beginPath();
context.arc(234, 330, 179, 0, Math.PI*.992, true);
context.closePath();
context.lineWidth = 5;
context.fillStyle = 'black';
context.fill();
context.beginPath();
context.arc(234, 319, 177, 0, Math.PI*.992, true);
context.closePath();
context.lineWidth = 5;
context.fillStyle = 'black';
context.fill();
context.beginPath();
context.arc(250, 295, 154, 0, Math.PI*.992, true);
context.closePath();
context.lineWidth = 5;
context.fillStyle = 'black';
context.fill();
context.beginPath();
context.arc(225, 305, 165, 0, Math.PI*.992, true);
context.closePath();
context.lineWidth = 5;
context.fillStyle = 'black';
context.fill();
context.beginPath();
context.arc(249, 296, 156, 0, Math.PI*.992, true);
context.closePath();
context.lineWidth = 4.8;
context.fillStyle = 'black';
context.fill();
context.beginPath();
context.rect(56.5, 300, 350, 155);
context.fillStyle = 'black';
context.fill();
context.lineWidth = 7;
context.beginPath();
context.moveTo(403,300);
context.lineTo(408,405);
context.lineWidth = 16;
context.strokeStyle = "black"
context.stroke();
context.beginPath();
context.moveTo(55,385);
context.lineTo(55,405);
context.lineWidth = 16;
context.strokeStyle = "black"
context.stroke();
///////////////////////////////////////// Right Tip
var x = canvas.width / 1.2;
var y = canvas.height / 1.48;
var radius = 30;
var startAngle = 1.4 * Math.PI;
var endAngle = 2.5 * Math.PI;
var counterClockwise = false;
context.beginPath();
context.arc(x, y, radius, startAngle, endAngle, counterClockwise);
context.lineWidth = 40;
// line color
context.strokeStyle = 'black';
context.stroke();
var x = canvas.width / 1.25;
var y = canvas.height / 1.48;
var radius = 33;
var startAngle = 1.6 * Math.PI;
var endAngle = 2.5 * Math.PI;
var counterClockwise = false;
context.beginPath();
context.arc(x, y, radius, startAngle, endAngle, counterClockwise);
context.lineWidth = 40;
// line color
context.strokeStyle = 'black';
context.stroke();
var x = canvas.width / 1.2;
var y = canvas.height / 1.49;
var radius = 32;
var startAngle = 1.39 * Math.PI;
var endAngle = 2.5 * Math.PI;
var counterClockwise = false;
context.beginPath();
context.arc(x, y, radius, startAngle, endAngle, counterClockwise);
context.lineWidth = 40;
// line color
context.strokeStyle = 'black';
context.stroke();
context.beginPath();
context.moveTo(413, 360);
context.lineTo(413, 456);
context.lineWidth = "25"
context.strokeStyle= 'black';
context.stroke();
///////////////////////////////////////////////////////////// Left Tip
var x = canvas.width / 9;
var y = canvas.height / 1.49;
var radius = 35;
var startAngle = 1 * Math.PI;
var endAngle = 2 * Math.PI;
var counterClockwise = false;
context.beginPath();
context.arc(x, y, radius, startAngle, endAngle, counterClockwise);
context.lineWidth = 40;
// line color
context.strokeStyle = 'black';
context.stroke();
var x = canvas.width / 19;
var y = canvas.height / 1.5;
var radius = 20;
var startAngle = 0 * Math.PI;
var endAngle = 2 * Math.PI;
var counterClockwise = false;
context.beginPath();
context.arc(x, y, radius, startAngle, endAngle, counterClockwise);
context.lineWidth = 20;
// line color
context.strokeStyle = 'black';
context.stroke();
var x = canvas.width / 19;
var y = canvas.height / 1.48;
var radius = 23;
var startAngle = 0 * Math.PI;
var endAngle = 2 * Math.PI;
var counterClockwise = false;
context.beginPath();
context.arc(x, y, radius, startAngle, endAngle, counterClockwise);
context.lineWidth = 20;
// line color
context.strokeStyle = 'black';
context.stroke();
var x = canvas.width / 19;
var y = canvas.height / 1.48;
var radius = 10;
var startAngle = 0 * Math.PI;
var endAngle = 2 * Math.PI;
var counterClockwise = false;
context.beginPath();
context.arc(x, y, radius, startAngle, endAngle, counterClockwise);
context.lineWidth = 20;
// line color
context.strokeStyle = 'black';
context.stroke();
context.beginPath();
context.rect(106, 350, 30, 184);
context.fillStyle = 'black';
context.fill();
context.lineWidth = 8;
///////////////////////////////////////////// Ear
context.beginPath();
context.moveTo(80,570);
context.lineTo(110,565)
context.lineWidth = "15"
context.strokeStyle= 'black';
context.stroke();
var x = canvas.width / 8;
var y = canvas.height / 1.35;
var radius = 25;
var startAngle = 0 * Math.PI;
var endAngle = 2 * Math.PI;
var counterClockwise = false;
context.beginPath();
context.arc(x, y, radius, startAngle, endAngle, counterClockwise);
context.lineWidth = 21;
// line color
context.strokeStyle = '#e1ac96';
context.stroke();
var x = canvas.width / 8;
var y = canvas.height / 1.36;
var radius = 25;
var startAngle = 0 * Math.PI;
var endAngle = 2 * Math.PI;
var counterClockwise = false;
context.beginPath();
context.arc(x, y, radius, startAngle, endAngle, counterClockwise);
context.lineWidth = 20;
// line color
context.strokeStyle = '#e1ac96';
context.stroke();
context.beginPath();
context.moveTo(103,563)
context.bezierCurveTo(-4, 630, 0, 210, 110, 563)
context.lineWidth= 4;
context.closePath();
context.fillStyle = '#e1ac96'
context.fill();
context.beginPath();
context.moveTo(113,563)
context.bezierCurveTo(-4, 630, 0, 210, 110, 563)
context.lineWidth= 7;
context.closePath();
context.fillStyle = '#e1ac96'
context.fill();
var centerX = -180;
var centerY = 90;
var radius = 33.5;
context.save();
context.translate(canvas.width / 2, canvas.height / 2);
context.scale(1, 2);
context.beginPath();
context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
context.restore();
context.fillStyle = '#blue';
context.fill();
context.lineWidth = 5;
context.beginPath();
context.rect(79, 490, 29, 49);
context.fillStyle = '#e1ac96';
context.fill();
context.lineWidth = 11;
//////////////////////////////// Face
context.beginPath();
context.rect(150, 415, 235, 174);
context.fillStyle = '#e1ac96';
context.fill();
context.lineWidth = 7;
context.beginPath();
context.rect(100, 534, 230, 28);
context.fillStyle = '#e1ac96';
context.fill();
context.lineWidth = 7;
context.beginPath();
context.rect(136, 445, 230, 144);
context.fillStyle = '#e1ac96';
context.fill();
context.lineWidth = 7;
context.beginPath();
context.moveTo(120,550);
context.lineTo(130, 586);
context.lineWidth = 20;
context.strokeStyle = "#e1ac96"
context.stroke();
context.beginPath();
context.moveTo(130,550);
context.lineTo(130, 589);
context.lineWidth = 20;
context.strokeStyle = "#e1ac96"
context.stroke();
context.beginPath();
context.moveTo(390,386);
context.lineTo(390,535);
context.lineWidth = 22;
context.strokeStyle = "#e1ac96"
context.stroke();
context.beginPath();
context.rect(100, 535, 230, 28);
context.fillStyle = '#e1ac96';
context.fill();
context.lineWidth = 7;
context.beginPath();
context.arc(200, 445, 57, 10, Math.PI, false);
context.closePath();
context.lineWidth = 5;
context.fillStyle = '#e1ac96';
context.fill();
context.beginPath();
context.moveTo(225,415);
context.lineTo(390,415);
context.lineWidth = 35;
context.strokeStyle = "#e1ac96"
context.stroke();
context.beginPath();
context.moveTo(390,530);
context.lineTo(375,585);
context.lineWidth = 27;
context.strokeStyle = "#e1ac96"
context.stroke();
context.beginPath();
context.moveTo(205,400);
context.lineTo(390,415);
context.lineWidth = 26;
context.strokeStyle = "#e1ac96"
context.stroke();
context.beginPath();
context.moveTo(215,395);
context.lineTo(390,405);
context.lineWidth = 16;
context.strokeStyle = "#e1ac96"
context.stroke();
context.beginPath();
context.moveTo(215,425);
context.lineTo(400.5,388);
context.lineWidth = 12;
context.strokeStyle = "#e1ac96"
context.stroke();
context.beginPath();
context.moveTo(145,450);
context.lineTo(160,420);
context.lineWidth = 22;
context.strokeStyle = "#e1ac96"
context.stroke();
context.beginPath();
context.moveTo(145,455);
context.lineTo(157,420);
context.lineWidth = 22;
context.strokeStyle = "#e1ac96"
context.stroke();
////////////////////////////////////// Neck
context.beginPath();
context.moveTo(98,573.5);
context.lineTo(98,589);
context.lineWidth = 30;
context.strokeStyle = "#e1ac96"
context.stroke();
context.beginPath();
context.moveTo(105,571);
context.lineTo(110,587);
context.lineWidth = 12;
context.strokeStyle = "#e1ac96"
context.stroke();
context.beginPath();
context.moveTo(107,574);
context.lineTo(109.5,589);
context.lineWidth = 12;
context.strokeStyle = "#e1ac96"
context.stroke();
//////////////////////////////////////// EYE
context.beginPath();
context.moveTo(198, 409);
context.lineTo(210, 452);
context.lineWidth = "11"
context.strokeStyle= 'black';
context.stroke();
context.beginPath();
context.moveTo(218, 407);
context.lineTo(219, 460);
context.lineWidth = "11"
context.strokeStyle= 'black';
context.stroke();
context.beginPath();
context.moveTo(240, 412);
context.lineTo(230, 435);
context.lineWidth = "11"
context.strokeStyle= 'black';
context.stroke();
context.beginPath();
context.moveTo(258, 424);
context.lineTo(239, 440);
context.lineWidth = "11"
context.strokeStyle= 'black';
context.stroke();
context.beginPath();
context.moveTo(270, 440);
context.lineTo(260, 445);
context.lineWidth = "11"
context.strokeStyle= 'black';
context.stroke();
context.beginPath();
context.moveTo(277, 460);
context.lineTo(215, 460);
context.lineWidth = "11"
context.strokeStyle= 'black';
context.stroke();
context.beginPath();
context.moveTo(210, 455);
context.lineTo(235, 527);
context.lineWidth = "11"
context.strokeStyle= 'black';
context.stroke();
context.beginPath();
context.moveTo(192, 455);
context.lineTo(254, 517);
context.lineWidth = "11"
context.strokeStyle= 'black';
context.stroke();
context.beginPath();
context.moveTo(192, 455);
context.lineTo(269, 500);
context.lineWidth = "11"
context.strokeStyle= 'black';
context.stroke();
context.beginPath();
context.moveTo(199, 469);
context.lineTo(277, 480);
context.lineWidth = "11"
context.strokeStyle= 'black';
context.stroke();
context.beginPath();
context.moveTo(205, 455);
context.lineTo(215, 530);
context.lineWidth = "11"
context.strokeStyle= 'black';
context.stroke();
context.beginPath();
context.moveTo(215, 450);
context.lineTo(192, 527);
context.lineWidth = "11"
context.strokeStyle= 'black';
context.stroke();
context.beginPath();
context.moveTo(200, 480);
context.lineTo(175, 515);
context.lineWidth = "11"
context.strokeStyle= 'black';
context.stroke();
context.beginPath();
context.moveTo(200, 480);
context.lineTo(161, 497);
context.lineWidth = "11"
context.strokeStyle= 'black';
context.stroke();
context.beginPath();
context.moveTo(200, 475);
context.lineTo(154, 475);
context.lineWidth = "11"
context.strokeStyle= 'black';
context.stroke();
context.beginPath();
context.moveTo(200, 469);
context.lineTo(154, 453);
context.lineWidth = "11"
context.strokeStyle= 'black';
context.stroke();
context.beginPath();
context.moveTo(200, 465);
context.lineTo(165, 433);
context.lineWidth = "11"
context.strokeStyle= 'black';
context.stroke();
context.beginPath();
context.moveTo(200, 445);
context.lineTo(178, 420);
context.lineWidth = "11"
context.strokeStyle= 'black';
context.stroke();
var centerX = canvas.width / 2.359;
var centerY = canvas.height /1.281;
var radius = 50;
context.beginPath();
context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
context.fillStyle = 'black';
context.fill();
context.lineWidth = 5;
var centerX = canvas.width / 2.359;
var centerY = canvas.height /1.281;
var radius = 40;
context.beginPath();
context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
context.fillStyle = 'white';
context.fill();
context.lineWidth = 5;
var centerX = canvas.width / 2.359;
var centerY = canvas.height /1.281;
var radius = 20;
context.beginPath();
context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
context.fillStyle = 'black';
context.fill();
context.lineWidth = 5;
/////////////////////////////////////// Words
/////////////////////////////////// E
context.beginPath();
context.rect(360,108,63,34)
context.fillStyle="white"
context.fill();
context.lineWidth ='10'
context.beginPath();
context.rect(361,64.5,33,45)
context.fillStyle="white"
context.fill();
context.lineWidth ='10'
context.beginPath();
context.rect(361,64.5,44.6,29.8)
context.fillStyle="white"
context.fill();
context.lineWidth ='10'
context.beginPath();
context.rect(361,64.5,55.5,18.5)
context.fillStyle="white"
context.fill();
context.lineWidth ='10'
context.beginPath();
context.rect(375,124,55.5,18.5)
context.fillStyle="white"
context.fill();
context.lineWidth ='10'
context.beginPath();
context.moveTo(435,143);
context.lineTo(418,110)
context.lineWidth = "9"
context.strokeStyle= 'white';
context.stroke();
////////////////////////////////////// G
////////////////// Lining
context.beginPath();
context.moveTo(305,160);
context.lineTo(295,135)
context.lineWidth = "10"
context.strokeStyle= 'orange';
context.stroke();
//////////////////////// Letter
context.beginPath();
context.rect(331,105,28,37)
context.fillStyle="white"
context.fill();
context.lineWidth ='12'
context.beginPath();
context.moveTo(359,104);
context.lineTo(381,143)
context.lineTo(350,143);
context.lineTo(355,143)
context.fillStyle = 'white'
context.fill();
context.lineJoin = 'miter'
context.lineWidth = "2"
context.strokeStyle= 'orange';
context.stroke();
var x = canvas.width / 1.59;
var y = canvas.height / 5.9;
var radius = 26;
var startAngle = 1.75* Math.PI;
var endAngle = 2.1 * Math.PI;
var counterClockwise = true;
context.beginPath();
context.arc(x, y, radius, startAngle, endAngle, counterClockwise);
context.lineWidth = 35;
context.strokeStyle = 'white';
context.stroke();
//////////////////////////////////////////// N
/////////////////// Letter
context.beginPath();
context.rect(262.5,64,31,80)
context.fillStyle="orange"
context.fill();
context.lineWidth ='10'
context.beginPath();
context.rect(223,64,69,72)
context.fillStyle="orange"
context.fill();
context.lineWidth ='10'
context.beginPath();
context.rect(224,72,69,72)
context.fillStyle="white"
context.fill();
context.lineWidth ='10'
context.beginPath();
context.rect(262.5,64,30,62)
context.fillStyle="white"
context.fill();
context.lineWidth ='11'
context.beginPath();
context.moveTo(290, 80);
context.lineTo(224.5, 69);
context.lineWidth = "8"
context.strokeStyle= 'white';
context.stroke();
////////////////// Lining
context.beginPath();
context.moveTo(350,161.5);
context.lineTo(252,143)
context.lineWidth = "15"
context.strokeStyle= 'orange';
context.stroke();
context.beginPath();
context.moveTo(252.5,162);
context.lineTo(252.5,136)
context.lineWidth = "5"
context.strokeStyle= 'orange';
context.stroke();
///////////////////////////////////// A1
///////////////////// Lining
context.beginPath();
context.moveTo(232,160);
context.lineTo(196,110)
context.lineTo(177,160);
context.lineJoin = 'miter'
context.lineWidth = "32"
context.strokeStyle= 'orange';
context.stroke();
/////////////// Letter
context.beginPath();
context.moveTo(232,160);
context.lineTo(196,99)
context.lineTo(162,159);
context.lineJoin = 'miter'
context.lineWidth = "35"
context.strokeStyle= 'orange';
context.stroke();
context.beginPath();
context.moveTo(232,160);
context.lineTo(196,99)
context.lineTo(162,159);
context.lineJoin = 'miter'
context.lineWidth = "32"
context.strokeStyle= 'white';
context.stroke();
////////////////////////////////////// R1
context.beginPath();
context.rect(101,64,37.5,77.5)
context.fillStyle="orange"
context.fill();
context.lineWidth ='4'
context.beginPath();
context.moveTo(166,152);
context.lineTo(130,75)
context.lineWidth = "12"
context.strokeStyle= 'orange';
context.stroke();
context.beginPath();
context.rect(102,65,37,77)
context.fillStyle="white"
context.fill();
context.lineWidth ='2'
var centerX = canvas.width / 3.89;
var centerY = canvas.height / 6.2;
var radius = 32.5;
context.beginPath();
context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
context.fillStyle = 'white';
context.fill();
context.beginPath();
context.rect(117,75,37,67)
context.fillStyle="white"
context.fill();
context.lineWidth ='2'
context.beginPath();
context.moveTo(160,141.5);
context.lineTo(130,75)
context.lineWidth = "12"
context.strokeStyle= 'white';
context.stroke();
context.beginPath();
context.moveTo(164,143);
context.lineTo(120,75)
context.lineWidth = "6"
context.strokeStyle= 'white';
context.stroke();
var centerX = canvas.width / 3.85;
var centerY = canvas.height / 6.1;
var radius = 10;
context.beginPath();
context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
context.fillStyle = 'orange';
context.fill();
//////////////////////////// O1
//////////////////// O lining
context.beginPath();
context.moveTo(320,275);
context.lineTo(70,182)
context.lineWidth = "8"
context.strokeStyle= 'black';
context.stroke();
context.beginPath();
context.rect(85,141,37,50)
context.fillStyle="black"
context.fill();
context.lineWidth ='5'
context.beginPath();
context.rect(66,135,37,50)
context.fillStyle="black"
context.fill();
context.lineWidth ='5'
context.beginPath();
context.rect(102,145,37,67)
context.fillStyle="black"
context.fill();
context.lineWidth ='2'
////////////////////////// Letter
var centerX = canvas.width / 8;
var centerY = canvas.height / 4.8;
var radius = 58;
context.beginPath();
context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
context.fillStyle = 'white';
context.fill();
context.lineWidth = '2';
context.strokeStyle = 'orange'
context.stroke();
var centerX = canvas.width / 6.5;
var centerY = canvas.height / 6;
var radius = 10;
context.beginPath();
context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
context.fillStyle = 'orange';
context.fill();
////////////////////////////////////// Lining
context.beginPath();
context.moveTo(375,157);
context.lineTo(120,157)
context.lineWidth = "30"
context.strokeStyle= 'black';
context.stroke();
context.beginPath();
context.moveTo(404,300);
context.lineTo(404,535)
context.lineWidth = "7"
context.strokeStyle= 'black';
context.stroke();
context.beginPath();
context.moveTo(390,589);
context.lineTo(404,534)
context.lineWidth = "8"
context.strokeStyle= 'black';
context.stroke();
///////////// Neck Lining
context.beginPath();
context.moveTo(117,590);
context.lineTo(110,565)
context.lineWidth = "7"
context.strokeStyle= 'black';
context.stroke();
context.beginPath();
context.moveTo(80,590);
context.lineTo(80,570)
context.lineWidth = "7"
context.strokeStyle= 'black';
context.stroke();
/////////////// Below E
context.beginPath();
context.moveTo(425,145);
context.lineTo(375,170)
context.lineWidth = "7"
context.strokeStyle= 'black';
context.stroke();
context.beginPath();
context.rect(365,142,27,24)
context.fillStyle="black"
context.fill();
context.lineWidth ='5'
context.beginPath();
context.rect(380,142,27,16)
context.fillStyle="black"
context.fill();
context.lineWidth ='5'
context.beginPath();
context.rect(393,142,27,10)
context.fillStyle="black"
context.fill();
context.lineWidth ='5'
context.beginPath();
context.rect(402,142,27,5.5)
context.fillStyle="black"
context.fill();
context.lineWidth ='5'
context.beginPath();
context.rect(410,142,27,2.5)
context.fillStyle="black"
context.fill();
context.lineWidth ='5'
/////////////// Bottom Line
context.beginPath();
context.rect(0,590,550,50)
context.fillStyle='orange'
context.fill();
context.lineWidth ='5'
//// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< YOUR CODE ENDS HERE
// CHANGE THE CREDITS
context.beginPath();
context.font = 'bold 20px Arial';
context.fillStyle = "rgba(0,0,0,1)";
context.fillText('Carson Mann', 20, 550);
context.closePath();
</script>
</body>
</html>
Comments
Post a Comment