Home | ISP | Novels 1, 2, 3 | Shorts | Poetry | Cartoon | DHTML | Other | |
|
Normal DHTML pages
are limited by their number of layers. More than fifteen is unusual -
the file size gets too high. So why not get JavaScript to write all the
HTML for the layers using its Write function and a few equations? Amazingly,
it works. The result is hundreds of layers and weird and wonderful patterns
produced by a tiny file (<2k). Simple
demos - should be OK on IE 4 Circular
pattern Wide
circular pattern Bonus demo (2006) - only suitable for modern browsers How it worksHere is the ordinary code for a layer: <div id="Layer1" style="position:absolute; left:301px; top:174px; width:50px; height:50px; z-index:1"><img src="images/red.GIF" width="50" height="50"></div> Now here's the JavaScript code for generating a series of these layers: <script language="JavaScript"> function genlayer()
{ As you can see, it's
an iteration from k=0 to k = 19, producing 20 layers. The k variable gives
each layer its layer ID, its z-index (level of visual dominance) and through
maths its position on the page. In this case the maths is very simple
and the result is a sloping line. The fun starts when you add more complicated
maths to determine the position, especially sine and cosine functions. |