Tag Archives: canvas

A Flood-Fill Implementation in JavaScript

Below is a simple implementation of a floodfill algorithm in JavaScript. When run, the program will draw a green background on a canvas, render the word “FLOOD” over it in orange, and then flood-fill the background with cyan, leaving the … Continue reading

Posted in Uncategorized | Tagged , , , | Leave a comment

Drawing a Rotated Image to an HTML5 Canvas

The JavaScript code below, when run, prompts the user to specify an image file to be uploaded, and then displays that image, scaled to 100 x 100 pixels and rotated 45 degrees clockwise in the center of an HTML5 canvas.

Posted in Uncategorized | Tagged , , , , | Leave a comment

Text Layout and Justification on an HTML5 Canvas

The JavaScript code below, when run, will automatically split a simple poem across three different rectangles on an HTML5 canvas, and render the justified text. ┬áTo see it in action, copy it into an .html file and open that file … Continue reading

Posted in Uncategorized | Tagged , , , , , | Leave a comment