canvas细胞分裂液体融合动画效果代码
代码语言:html
所属分类:动画
代码描述:canvas细胞分裂液体融合动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> html {background:#1d233b} </style> </head> <body translate="no"> <canvas id="canvas" width="256" height="256"></canvas> <script type="text/javascript"> var canvas = document.getElementById("canvas"), ctx = canvas.getContext("2d"), tempCanvas = document.createElement("canvas"), tempCtx = tempCanvas.getContext("2d"), width = 600, height = 600, threshold = 210, colors = {r:255,g:0,b:0}, cycle = 0, points = []; canvas.width = tempCanvas.width = width; canvas.height= tempCanvas.height= height; for(var i = 0; i < 30; i++){ var x = Math.random()*width, y = Math.random()*height, vx = (Math.random()*2)-1, vy = (Math.random()*2)-1, size = Math.floor(Math.random()*40)+40; points.push({x:x,y:y,vx:vx,vy:vy, size:size}); }; function update(){ var len = points.length; tempCtx.clearRect(0,0,width,height); while(len--){ var point = points[len]; point.x+=point.vx; point.y+=point.vy; if(point.x > width+point.size){ point.x = 0-point.size; } if(point.x < 0-point.size){ .........完整代码请登录后点击上方下载按钮下载查看
网友评论0