Static text fill using HTML5 Canvas.


Making the transparent letter was discussed and source code shown several weeks ago.  Animated Text Fill but no link was created demonstrating the effect. The desired effect is of course to make the text stand out and be read / recalled for a longer period of time. Movement grabs attention. A simple static fill can be used for the

<canvas id="fill" width="960" height="300"></canvas>

In the example created the width is now 400 with a height of 200 the id is now static

<canvas id="static" width="400" height="200"></canvas>

the script to create the static is

<script>
function noise() {
 	var idstatic = document.getElementById("static");
	var ctxstatic = idstatic.getContext("2d");

   	var TempImage = ctxstatic.getImageData(0, 0, 400, 200);
 	var ImgData = TempImage.data;
 	for (var y = 0; y < 200; y += 1) {
		for ( var x = 0 ; x < 400 ; x += 1 ) {
			var i = (x * 4) + (y * 400 * 4);
			r = Math.random();
			var v = 64+(Math.floor(196 * r ));
			ImgData[i] = v;
			ImgData[i+1] = v;
			ImgData[i+2] = v;

			ImgData[i+3] = 255;
		}
 	}
 	ctxstatic.putImageData(TempImage, 0, 0);
	setTimeout(noise, 30);
}

  	noise(); 

</script>
It is being demonstrated at http://wsmith-animations.tk/canvas/
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: