canvas粒子运动动画效果代码
代码语言:html
所属分类:粒子
代码描述:canvas粒子运动动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> html,body{background-color:black;text-align:center} </style> </head> <body><canvas id="display"></canvas> <script> var width = 640; var height = 480; var vbuf; var pstart; var nump; var canvasElement; var gl; window.onload = function() { canvasElement = document.getElementById("display"); canvasElement.width = width; canvasElement.height = height; gl = canvasElement.getContext("webgl"); if (!gl) { gl = canvasElement.getContext("experimental-webgl"); if (!gl) { alert("WebGL not supported!") } } nump = 48000; pstart = new Float32Array(nump * 2); var b = pstart.length; while (b--) { pstart[b] = 0; while (pstart[b] * pstart[b] < 0.3) { pstart[b] = Math.random() * 2 - 1 } } vbuf = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, vbuf); gl.bufferData(gl.ARRAY_BUFFER, pstart, gl.STATIC_DRAW); var e = gl.createShader(gl.VERTEX_SHADER); gl.shaderSource(e, "\nprecision mediump float;attribute vec2 Vertex; varying vec2 V; uniform float T;void main(void) {gl_PointSize = .........完整代码请登录后点击上方下载按钮下载查看
网友评论0