canvas粒子文字字母点击爆炸效果代码
代码语言:html
所属分类:粒子
代码描述:canvas粒子文字字母点击爆炸效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> * { margin: 0; box-sizing: border-box; overflow: hidden; } body { background: #222; width: 100%; height: 100vh; display: flex; justify-content: center; align-items: center; } body canvas { box-shadow: 0.2em 0.2em 2em #0008; border: none; outline: none; } </style> </head> <body > <canvas id="canvas"></canvas> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/processing.min.js"></script> <script > var sketchProc = function(processingInstance) { with (processingInstance) { size(600, 600); frameRate(60); smooth(); var fontSize = 80; var content = "PARTICLES\nARE COOL"; textFont(createFont("Arial Bold"), fontSize); textAlign(CENTER, CENTER); fill(0); text(content, 10, 10, 580, 580); var particleColors = [ color(247, 52, 72), color(245, 235, 88), color(36, 112, 166), color(72, 191, 242), color(192, 93, 245) ]; var particles = (function() { var arr = []; for(var x = 0; x <= 600; x+= fontSize * 0.04) { for(var y = 0; y <= 600; y+= fontSize * 0.04) { if(get(x, y) === -16777216) { arr.push({ x: x, y: y, bx: x, by: y, tx: 0, ty: 0, vx: 0.1, vy: 0.1, xoff: random(-5, 5), yoff: random(-5, 5), angle: radians(random(360)) | 0, rot: random(-5, 5), .........完整代码请登录后点击上方下载按钮下载查看
网友评论0