神奇的曼德布罗特粒子效果
代码语言:html
所属分类:粒子
代码描述:神奇的曼德布罗特粒子效果,拖动鼠标试试
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> </head> <body style='margin:0;overflow:hidden'> <canvas id="c"></canvas> <script > // Magic Mandelbrot Particles - An Interactive Fractal Particle Simulation // - Mouse controls where points are spawned // - Click anywhere to clear trails // - Press any key to clear points // Created by Frank Force // License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. randomness = .005; // how much randomness for each point alpha = .05; // background alpha, controls trails life = 500; // how long to keep particles alive maxCount = 2e3; // maximum number of particles scale = .9; // size of mandelbrot set offset = .2; // offset of mandelbrot set spawnCount = 5; // how many particles to spawn each frame updateCount = 1; // how many updates each frame juliaMode = 0; // juia set mode testMode = 0; // fully random mode for testing warmUp = 1; // some random points on start so it's not blank t = 0; a = []; A = B = 2e3; x = c.getContext`2d`; x.fillRect(0, 0, c.width, c.height); requestAnimationFrame(u = _ => { if (warmUp == 1) { warmUp = 2; for (k = 100; k--;) u(); warmUp = 0; } if (!warmUp) requestAnimationFrame(u); if (c.width != innerWidth || c.height != innerHeight) { // match canvas to inner size c.width = innerWidth; c.height = innerHeight; x.fillRect(0, 0, c.width, c.height); } // background fill for trails x.globalCompositeOperation = 'source-over'; x.fillStyle = `hsl(0,.........完整代码请登录后点击上方下载按钮下载查看
网友评论0