In this post I'm going to demonstrate some of the new HTML5 techniques, using SVG animations, and integrating them into a nice themed button.
SVG animations aren't fully supported in all browsers yet, for now it's another technique that you can experiment with but can't really use for a work project for example. Unless of course you don't mind building several different versions of the same page and re-directing appropriately for each browser.
Below are two screenshots that I've just captured while hovering over the button. There are some basic circles that have a blur filter applied to them, along with some SVG animated scaling and opacity settings.
There's also a small circle that you can see in the bottom half of the button that moves up, down and across as it follows a path from left to right.
This is all done using the latest stuff. I've been visiting the w3.org site to get a better grasp of what's possible so I'd suggest you do the same if you're not sure what's happening.
And this time, rather than post all of the html here, just visit the demo page and view the source code. Be careful though, if you're going to copy it into your own html editor to play around with, it's very easy to mess it up if you change the wrong thing!
I'd suggest you just change the colour changes first, or the timing settings. Of course if you're confident enough, you can study what I've made an play away!
Try increasing the size of the divs and you can make a nice animated page background, which is where I'll be headed next.
If you've been reading up on SVG animation techniques then you can perhaps play around with some of other settings.
Below are a couple of examples. The original settings that I've used here can be found on the demo pages' source code starting at line 82 :-
<div id="Scalex4"><!--circle fading, changing to red and scaling by a factor of 4-->
<svg >
<defs>/*This is applying the blur filter*/
<filter height="200%" width="200%" y="-50%" x="-50%" id="svg_1_blur">
<feGaussianBlur stdDeviation="1.4" in="SourceGraphic"/>
</filter>
</defs>
<g>
/*This places the circle within the div at a certain position and are x and y coordinates. I've used the transform="translate" settings to position it, as it seems easier to use the cartesian coordinate system than the standard cy (circle y) and cx (circle x) settings. Try using both for yourself and see what happens.*/
<circle transform="translate(20, 0)" filter="url(#svg_1_blur)"r="5" cy="0" cx="0" stroke-width="0" stroke="#000000" />
Here are the animation settings.
/*The first sets the opacity of the circle to 0 so that the circle isn't showing once the page has been loaded.*/
<animate attributeName="opacity" attributeType="XML"
values="0;"
dur="100ms"
fill="freeze"
repeatCount="1"/>
/*This animates the colour of the circle as the mouse rolls over the div using red, green, blue and alpha values.*/
<animateColor attributeName="fill" attributeType="XML"
values="rgba(255,0,0,1); rgba(255,80,0,0) dur="1800ms"
repeatCount="indefinite"
begin="anim.mouseover"
end="anim.mouseout"/>
/*This changes the opacity value from the value that was set above to 1, and then back to 0 as the mouse rolls over the div.*/
<animate attributeName="opacity" attributeType="XML"
values="0;1;0;"
dur="1800ms"
begin="anim.mouseover"
end="anim.mouseout"
repeatCount="indefinite"/>
/*This scales the circle by a factor of 4.*/
<animateTransform attributeName="transform" attributeType="XML"
type="scale"
from="1" to="4"
dur="1800ms"
begin="anim.mouseover"
end="anim.mouseout"
repeatCount="indefinite"/><!-- more than one count and it messes up-->
</circle>
</g>
</svg>
</div>
SVG animations aren't fully supported in all browsers yet, for now it's another technique that you can experiment with but can't really use for a work project for example. Unless of course you don't mind building several different versions of the same page and re-directing appropriately for each browser.
Below are two screenshots that I've just captured while hovering over the button. There are some basic circles that have a blur filter applied to them, along with some SVG animated scaling and opacity settings.
There's also a small circle that you can see in the bottom half of the button that moves up, down and across as it follows a path from left to right.
Demo Here.. ( you 'll have to use the latest version of Googles' Chrome browser to see everything working )
This is all done using the latest stuff. I've been visiting the w3.org site to get a better grasp of what's possible so I'd suggest you do the same if you're not sure what's happening.
And this time, rather than post all of the html here, just visit the demo page and view the source code. Be careful though, if you're going to copy it into your own html editor to play around with, it's very easy to mess it up if you change the wrong thing!
I'd suggest you just change the colour changes first, or the timing settings. Of course if you're confident enough, you can study what I've made an play away!
Try increasing the size of the divs and you can make a nice animated page background, which is where I'll be headed next.
If you've been reading up on SVG animation techniques then you can perhaps play around with some of other settings.
Below are a couple of examples. The original settings that I've used here can be found on the demo pages' source code starting at line 82 :-
<div id="Scalex4"><!--circle fading, changing to red and scaling by a factor of 4-->
<svg >
<defs>/*This is applying the blur filter*/
<filter height="200%" width="200%" y="-50%" x="-50%" id="svg_1_blur">
<feGaussianBlur stdDeviation="1.4" in="SourceGraphic"/>
</filter>
</defs>
<g>
/*This places the circle within the div at a certain position and are x and y coordinates. I've used the transform="translate" settings to position it, as it seems easier to use the cartesian coordinate system than the standard cy (circle y) and cx (circle x) settings. Try using both for yourself and see what happens.*/
<circle transform="translate(20, 0)" filter="url(#svg_1_blur)"r="5" cy="0" cx="0" stroke-width="0" stroke="#000000" />
Here are the animation settings.
/*The first sets the opacity of the circle to 0 so that the circle isn't showing once the page has been loaded.*/
<animate attributeName="opacity" attributeType="XML"
values="0;"
dur="100ms"
fill="freeze"
repeatCount="1"/>
/*This animates the colour of the circle as the mouse rolls over the div using red, green, blue and alpha values.*/
<animateColor attributeName="fill" attributeType="XML"
values="rgba(255,0,0,1); rgba(255,80,0,0) dur="1800ms"
repeatCount="indefinite"
begin="anim.mouseover"
end="anim.mouseout"/>
/*This changes the opacity value from the value that was set above to 1, and then back to 0 as the mouse rolls over the div.*/
<animate attributeName="opacity" attributeType="XML"
values="0;1;0;"
dur="1800ms"
begin="anim.mouseover"
end="anim.mouseout"
repeatCount="indefinite"/>
/*This scales the circle by a factor of 4.*/
<animateTransform attributeName="transform" attributeType="XML"
type="scale"
from="1" to="4"
dur="1800ms"
begin="anim.mouseover"
end="anim.mouseout"
repeatCount="indefinite"/><!-- more than one count and it messes up-->
</circle>
</g>
</svg>
</div>
This piece of code is actually taken from a more complete post that I've nearly finished that shows the differences between CSS3, HTML5, SVG and Flash to create themed buttons.
Have a nice day!! :)
No comments:
Post a Comment