Created
April 11, 2011 02:50
-
-
Save dalmaer/913000 to your computer and use it in GitHub Desktop.
Paul Hayes' example of spheres with CSS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var panels = p || this.panels, | |
| rounds = r || this.rounds, | |
| rotationPerPanel = 360/panels, | |
| rotationPerRound = 360/2/rounds, | |
| yRotation, xRotation, | |
| width = this.panelWidth, | |
| zTranslate = (width/2) / Math.tan(rotationPerPanel * Math.PI/180), | |
| $container = this.el, | |
| $ul, $li, i, j; | |
| this.el.html(''); | |
| for(i = 0; i < rounds; i++) { | |
| $ul = $('<ul>'); | |
| xRotation = rotationPerRound * i; | |
| $ul[0].style.webkitTransform = "rotateX("+ xRotation + "deg)"; | |
| for(j = 0; j < panels; j++) { | |
| $li = $('<li>'); | |
| yRotation = rotationPerPanel * j; | |
| $li[0].style.webkitTransform = "rotateY("+ yRotation +"deg) | |
| translateZ("+ zTranslate +"px)"; | |
| $ul.append($li); | |
| } | |
| $container.append($ul); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment