The amazing effect of the 3D Christmas tree below is Spain.ProgramMember Roman Cortes's js1k programming competition entries. It is also a good test of the browser's JavaScript Engine capabilities. Only modern browsers (programmers, you know) can be viewed normally.
After testing, Chrome is very smooth (download and installation), opera 11 is normal, Firefox is slow, ie 9 is very slow, and versions earlier than IE 9 cannot be displayed.
The 3D Christmas tree consists of JavaScript within 1024 bytes.CodeThe Code is as follows:
M = math; q = m. random; j = []; u = 16; t = m. sin; E = m. SQRT; For (O = k = 0; X = z = J = I = k <200;) with (M [k] = K? C. clonenode (0): C) {width = height = K? 32: W = 446; with (getcontext ('2d ') if (k> 10 |! K) for (font = '60px impact ', V = 'rgba ('; I = I * u, fillstyle = K? K = 13? V + '2014,. 15) ': V + (205,205,215 + I) +', '+ (K % 2? 128 + I: 0) + ',' + I + ',. 5) ':' # CCA ', I <7;) beginpath (fill (ARC (u-I/3, 24-I/2, K = 13? 4-(I ++)/2: 8-I ++, 0, M. pI * 2, 1); else for (; X = T (I), Y = Q () * 2-1, D = x * x + y * y, B = E (D-x /. 9-1.5 * Y + 1), r = 67 * (B + 1) * (L = K/9 +. 8)> 1, I ++ <W;) if (d <1) beginpath (strokestyle = V + R + ', '+ (R + B * L> 0) +', 40 ,. 1) '), moveTo (U + x * 8, U + y * 8), lineto (U + x * u, u + y * U), stroke (); for (y = H = K + E (K ++) * 25, r = Q () * w; P = 3, j
For implementation principles, refer to the author's blog.
This article is from: csdn