Wednesday, July 20, 2011

Render text with canvas 2D | WebGL Factory

Render text with canvas 2D | WebGL Factory: "function writeTextToCanvas(text, idx){
context2D.save();

context2D.clearRect ( 0 , 0 , 300 , 300);
context2D.fillStyle = faceColors[idx];
context2D.fillRect(0,0, 300, 300);

context2D.fillStyle = 'rgba(255, 255, 255, 255)';
context2D.strokeText(text, 150, 150);
context2D.fillText(text, 150, 150);

setTextureFromCanvas(context2D.canvas, textures[idx], idx);

context2D.restore();"