Quotes help make search much faster. Example: "Practice Makes Perfect"

Monday, December 31, 2012

Codecademy Sample Solution: Projects Adding Text



var my_canvas=document.getElementById('canvas');
var context=my_canvas.getContext('2d');
context.beginPath();
context.fillStyle = 'blue';
context.fillRect(50, 80, 100, 20);
context.font = "25px Calibri";
context.fillText("Kumbaya",53,50);
context.fillText("Sharky!",65,150);

context.fillStyle = "blue";
context.beginPath();
context.arc(50, 100, 20, Math.PI, (1.5)*Math.PI);
context.lineTo(50, 100);
context.closePath();
context.fill();
context.lineWidth = 1;
context.stroke();
context.fillStyle = "black";

context.fillStyle = "blue";
context.beginPath();
context.arc(100, 80, 20, Math.PI, (1.5)*Math.PI);
context.lineTo(100, 80);
context.closePath();
context.fill();
context.lineWidth = 1;
context.stroke();
context.fillStyle = "black";

context.fillStyle = "blue";
context.beginPath();
context.arc(170, 90, 20, 0.5*Math.PI, 1.5*Math.PI);
context.lineTo(170, 90);
context.closePath();
context.fill();
context.lineWidth = 1;
context.stroke();
context.fillStyle = "black";

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts