Sunday, March 20, 2016

HTML Project


For my first HTML project I made a cartoon bear. This project was definitely the most challenging project I have done this semester because I have never attempted to do coding on Text Wrangler before. To make this bear, I eyed a chart to find the x and y values but I didn't actually draw this image on the chart first and then find the numbers. I did a lot of guessing on the numbers and found that to be easier for me than doing the math to get  the numbers. Here is the complete code I used to make this bear:

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

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


//background
context.beginPath();
context.rect(0, 0, 800, 600);
context.fillStyle = '#FFCCFF';
context.fill();


//head
context.beginPath();
context.arc(400, 275, 150, 0, 2*Math.PI, false);
context.fillStyle = '#663300';
context.fill();


//nose
context.beginPath();
context.arc(400, 285, 50, 0, 2*Math.PI, false);
context.fillStyle = '#996600';
context.fill();


//ears
context.beginPath();
context.arc(300, 115, 40, 0, 2*Math.PI, false);
context.fillStyle = '#996600';
context.fill();
context.beginPath();
context.arc(500, 115, 40, 0, 2*Math.PI, false);
context.fillStyle = '#996600';
context.fill();


//nostrils
context.beginPath();
context.arc(380, 290, 15, 0, 2*Math.PI, false);
context.fillStyle = 'black';
context.fill();
context.beginPath();
context.arc(420, 290, 15, 0, 2*Math.PI, false);
context.fillStyle = 'black';
context.fill();


//mouth
context.beginPath();
context.moveTo(300, 325)
context.quadraticCurveTo(400, 475, 500, 325);
context.lineWidth = 6;
context.lineCap = 'round'
context.stroke();


//eyes
context.beginPath();
context.arc(350, 205, 20, 0, 2*Math.PI, false);
context.fillStyle = 'white';
context.fill();
context.beginPath();
context.arc(460, 205, 20, 0, 2*Math.PI, false);
context.fillStyle = 'white';
context.fill();


//pupils
context.beginPath();
context.arc(350, 205, 12, 0, 2*Math.PI, false);
context.fillStyle = 'black';
context.fill();
context.beginPath();
context.arc(460, 205, 12, 0, 2*Math.PI, false);
context.fillStyle = 'black';
context.fill();



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

};

</script>
</head>
<body>
<canvas id="myCanvas" width="800" height="600"></canvas>
</body>
</html>

No comments:

Post a Comment