canvas实现线条交织动画效果代码
代码语言:html
所属分类:动画
代码描述:canvas实现线条交织动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body, html { margin: 0; padding: 0; } body { min-height: 100vh; } .container { width: 100vw; height: 100vh; display: flex; justify-content: center; align-items: center; } </style> </head> <body > <div class="container"> <canvas class="canvas js-canvas"></canvas> </div> <script > const ctx = document.querySelector('canvas').getContext('2d'); const { canvas } = ctx; const TAU = Math.PI * 2; const W = 500; const H = W; const R = W >> 1; const R2 = R * 0.25; const NUM_LINES = 100; const LINE_ANGLE_STEP = TAU / NUM_LINES; const LINE_WIDTH_ANGLE = 0.02; let phase = 0; canvas.width = W; canvas.height = H; const drawCircle = (scale = 1, iteration) => { .........完整代码请登录后点击上方下载按钮下载查看
网友评论0