Could always change the rotator to rotate through embed code and one of the embeds is the canvas tag in stead, it's pretty easy to do actually, I'll write some example code.
Rotating Logo Example - Keep hitting refresh for a new image
I optimised it so images are 9.9KB smaller than the default logo and the code is now 1.6KB obfuscated, so the HTML5 animated logo is 8.3KB smaller than the default logo, just say if you want the optimised version of this (Code is obfuscated so it's difficult to modify).
I could further optimise the PNGs by making it a chip-set sheet, but I don't really have the time right now.
Take a look at logo.php's code to see how it is set up
DOWNLOAD CODE UNCOMPRESSED (Easy to edit)Download code compressed (Harder to edit, smaller file size)Here it is in code form for implementing into the forum theme, read all the comments and stuff to understand how to customise it and where to put the code and files:
PHP code to put in the top of the forum theme code (Or you can put it in it's own php file and write an include for it in the forum's theme PHP code).
-
- <?php
- /* Variables Begin */
- $urlJavaScript = "canvasPaint.js"; // JavaScript URL for painting to canvas
- $urlLogoBase = "http://www.hbgames.org/forums/images/slogans/HBlogo-"; // Logo base URL
-
- $imgCount = 39; // How many images are there
- $canvasPercent = 50; // Percentage chance of getting the canvas element, this can be changed to 1 / ($imgCount + 1) * 100 to make it the same percentage chance as the other images
-
- $altStrring = "HBGames Logo"; // Logo alt text
- $embedString = "<img src='".$urlLogoBase."01.png' alt='".$altStrring."' style='max-width: 671px !important;'>"; // Default fall-back
- /* Variables End */
-
- if (rand(0, 99) >= $canvasPercent) // This is where we use the % chance of getting the canvas embed
- {
- $imageNum = rand(1, $imgCount); // One of the random images
- $embedString = "<img src='".$urlLogoBase.sprintf("%02d",$imageNum).".png' alt='".$altStrring."' style='max-width: 671px !important;'>"; // Build the random image URL
-
- }
- else
- {
- $onloadString = "onload='init();'";
- $headString = "<script type='text/JavaScript' src='".$urlJavaScript."'></script>";
- $embedString = "<canvas id='canvas' width='671' height='190'><img src='".$urlLogoBase."01.png' alt='".$altStrring."' style='max-width: 671px !important;'/></canvas>";
- }
- /*
- So now we have:
- The string for the header to include the JS (Will be blank for the random images) - $headString
- The string for the embed code (Will be either canvas or img) - $embedString
- The string for the load code - $onloadString
-
- Insert them into the correct places with <?php echo $headString ?> and <?php echo $embedString?> and <?php echo $onloadString ?>
- */
- ?>
-
Expand to see the code.
Put the above code at the top of the PHP theme code, then put the <?php echo $headString ?> anywhere in the header and the <?php echo $embedString?> between the <a href="index.php"> </a> of the forum logo.
Put <?php echo $onloadString ?> inside the body tag as an element: <body <?php echo $onloadString ?> >
And the canvasPaint.js code:
-
- var logo = new Image();
- var HB = new Image();
- var ecs = new Image();
- var bar = new Image();
- var games = new Image();
- var cogWhite = new Image();
- var cogShadow = new Image();
- var rot = 0.0;
- var barDist = 0;
- var gameDist = 114;
- var eAlpha = 0.0;
- var cAlpha = 0.0;
- var sAlpha = 0.0;
- var spd = 14.5;
-
- // Edit these sources to reflect the image paths
- function init()
- {
- logo.src = 'images/HBlogo-01.png';
- HB.src = 'images/HB.png';
- ecs.src = 'images/ecs.png';
- bar.src = 'images/bar.png';
- games.src = 'images/games.png';
- cogWhite.src = 'images/cogWhite.png';
- cogShadow.src = 'images/cogShadow.png';
- setInterval(draw,60);
- }
-
- function draw()
- {
- var ctx = document.getElementById('canvas').getContext('2d');
- ctx.clearRect(0,0,671,190);
- //ctx.drawImage(logo,0,0);
-
- ctx.save();
- ctx.translate(143, 69);
- ctx.translate(55, 55);
- ctx.rotate(rot);
- ctx.globalAlpha = 0.9;
- ctx.drawImage(cogShadow,-55,-55);
- ctx.restore();
-
- ctx.drawImage(HB,8,17);
- if (barDist > -437) ctx.drawImage(bar,437 + barDist,0,1 - barDist,21, 227, 108, 1 - barDist,21);
- else ctx.drawImage(bar,227, 108);
-
- ctx.save();
- ctx.translate(142, 68);
- ctx.translate(51, 51);
- ctx.rotate(rot);
- ctx.drawImage(cogWhite,-51,-51);
- ctx.restore();
-
- if (gameDist == 0)
- {
- if (eAlpha < 2.0) eAlpha += 0.1;
- ctx.save();
- ctx.globalAlpha = eAlpha;
- ctx.drawImage(ecs,0, 0,153, 33, 262, 130, 153, 33);
- ctx.restore();
-
- if (eAlpha >= 2.0)
- {
- if (cAlpha < 2.0) cAlpha += 0.1;
- ctx.save();
- ctx.globalAlpha = cAlpha;
- ctx.drawImage(ecs,153, 0,126, 33, 262 + 153, 130, 126, 33);
- ctx.restore();
- }
-
- if (cAlpha >= 2.0)
- {
- if (sAlpha < 1.0) sAlpha += 0.1;
- ctx.save();
- ctx.globalAlpha = sAlpha;
- ctx.drawImage(ecs,153 + 126, 0,108, 33, 262 + 153 + 126, 130, 108, 33);
- ctx.restore();
- }
- }
-
- if (barDist < -437 && gameDist > -93)
- {
- gameDist -= spd;
- spd--;
- if (spd <= 1) spd = 2;
- if (gameDist < 0) gameDist = 0;
-
- ctx.drawImage(games,0, 0,422, 93 - gameDist, 240, 19 + gameDist, 422, 94 - gameDist);
- }
-
- if (barDist > -437) rot += 0.25;
- barDist -= 10;
- if (barDist < -437) barDirst = -437;
- }
-
Expand to see the code.
And here's all the imagesEDIT: It'll take a bit more to accept images in a directory, if that's really needed I'm sure some inject code can be written in PHP to run a script that's in the directory, it would be a lot more logic code but it would be as simple as dropping that in the image directory in stead of dealing with the forum theme code.