Tuesday, February 21, 2012

Project 2

Week two. I went of course this week, and started looking at other tutorials. I came across a text one and decided to create a reflection of it. Here it the code:
window.onload = function(){
var canvas = document.getElementById("test");
var context = canvas.getContext("2d");

context.translate(canvas.width / 2, canvas.height / 2);
context.font = "30pt Calibri";
context.scale(-1, 1);
context.textAlign = "center";
context.fillStyle = "#A52A2A";
context.shadowColor = "#800000";
context.shadowBlur = 20;
context.fillText("RACECAR", 0, 0);
}

And the outcome is available here.

Explanation:
To put the text in the canvas we need the:
context.fillText
to have a shadow we put:
context.shadowColor
and for the mirror:
context.scale(-1, 1)

1 comment:

  1. Nice. But don't leave us hanging... When you say "I came across a", we want to see what you saw!

    ReplyDelete