Alex Rivera | Logout

How to Make a Picture rotate Continuously?

Asked 2012-04-12T12:35:35.297
9

) I have a star image in top-left of my screen want to rotate continuously. so can anyone tell me How can we make a Picture rotate Continuously for browsers Mozilla Firefox, Google chrome!? [Css Position type is 'Absolutely' and image resolution:25*25 ]

Edit
Report

1 Answer

3

You could use RaphaelJS, since it's cross-browser compatible. For example, this code should work:

<div id="paper" style="width:300px; height:200px"></div>

<script type="text/javascript" src="(link to downloaded copy of raphaeljs)"></script>

<script type="text/javascript">
var paper = Raphael("paper");
var good_cat = paper.image( "http://pp19dd.com/_old/lily.png",40,20,96, 145);
var evil_cat = paper.image( "http://pp19dd.com/_old/cookie.png",160,20,96, 145);
var angle = 0;

setInterval( function() {
    angle += 45;       
    good_cat.stop().animate( { "transform": "R" + angle }, 300, "<>" );
}, 500 );


setInterval( function() {
    r = parseInt(Math.random() * 359);
    evil_cat.stop().animate( { "transform": "R" + r }, 300, "<>" );
}, 1000 );
</script>

See http://jsfiddle.net/AJgrU/ for an example.

answered 2012-04-12T12:49:17.367

Your Answer