Set up the walls and balls today!

Today I coded up some walls in Matter.js and added them to the Mathogen window. I added some code to create an image from a string of text.

I’m curious to know if the JS string can hold a Hiragana character?

Here’s the javascript code to create an image in javascript from a text string.

// Creates an image from a string

functioncreateImage($string) {

letdrawing=document.createElement("canvas");

drawing.width='150'

drawing.height='150'

letctx=drawing.getContext("2d");

ctx.fillStyle="black";

//ctx.fillRect(0, 0, 150, 150);

ctx.beginPath();

ctx.arc(75, 75, 20, 0, Math.PI*2, true);

ctx.closePath();

ctx.fill();

ctx.fillStyle="#fff";

ctx.font="20pt sans-serif";

ctx.textAlign="center";

ctx.fillText($string, 75, 85);

// ctx.strokeText("Canvas Rocks!", 5, 130);

returndrawing.toDataURL("image/png");

}

Leave a comment

Your email address will not be published. Required fields are marked *