The technique of simulating flame _javascript with JavaScript

Source: Internet
Author: User
Not quite like, and more cost original, do not know there is no better way =.=
<ptml> <pead> <title> Flame </title> <script language= "JavaScript" > Function Pixelaxis (left , bottom, width, height, color) {color = Color | | "#000000"; var pixels = []; for (var i = 0; I <= width; i++) {pixels[i] = []; for (var j = 0; j<=height; j + +) {var img = new Image (1, 1); Img.style.backgroundColor = color; Img.style.position = "absolute"; Img.style.left = left + i; Img.style.top = Bottom-j; PIXELS[I][J] = img; Document.body.appendChild (IMG); } return function (x, y, color) {pixels[x][y].style.backgroundcolor = color; } function Color (r, G, b) {R = R > 0xF r.tostring: "0" + r.tostring (16); g = g > 0xF? G.tostring (+): "0" + g.tostring (16); b = b > 0xF? B.tostring (+): "0" + b.tostring (16); Return "#" +R+G+B; } function Firecolor (Seed) {return color (seed, Math.floor (0.5*seed), 0); function spreadseeds (width, height) {var pixel = Pixelaxis (+, width, height); var FC = []; FC[0] = []; return function () {for (var i = 0; I <= width; i++) {var s = math.floor (255 * Math . random ()); Fc[0][i] = s; Pixel (i, 0, Firecolor (s)); for (var i = 1; i < height; i++) {fc[i] = []; for (var j = 0; J <= width; j + +) {var a = j > 0? fc[i-1][j-1]: 0; var b = fc[i-1][j]; var C = J < width? Fc[i-1][j+1]: 0; var s = Math.floor ((a+b+c)/3); alert (c); FC[I][J] = s; s = S-math.floor (i/height*255); s = s > 0? s:0; Pixel (j, I, Firecolor (s)); }}} &LT;/SCRIpt> </pead> <body bgcolor= "#000000" > </body> <script> var f = spreadseeds (60, 120); SetInterval ("F ()", 1); </script> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.