Monday, March 30, 2015

HTML

I chose to create a peace sign inside of a triangle for this project. I found this project the most difficult and time consuming!!

Here is the code:


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

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

//circle
var centerX = canvas.width/2
var centerY = canvas.height/2
var radius = 100;


//circle
context.beginPath();
context.arc(centerX, centerY, radius, 0,2*Math.PI,false);
context.lineWidth = 5;
context.stroke();

//peace sign-done
context.beginPath();
context.moveTo(400,200);
context.lineTo(400,400);
context.lineWidth = 5;
context.stroke();
context.closePath();


//line to peace sign right/left side
context.beginPath();
context.moveTo(490,349);
context.lineTo(400,290);
context.lineTo(311,350);
context.lineWidth = 5;
context.stroke();
context.closePath();


//triangle
context.beginPath();
context.moveTo(400, 100);
context.lineTo(620, 420);
context.lineTo(180, 420);
context.lineTo(400, 100);
context.lineWidth = 7;
context.stroke();
context.closePath();








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

};

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

No comments:

Post a Comment