canvas实现彩色棍子上下波浪波动动画效果代码
代码语言:html
所属分类:动画
代码描述:canvas实现彩色棍子上下波浪波动动画效果代码
代码标签: canvas 彩色 棍子 上下 波浪 波动 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> *{ padding:0; margin:0; boz-sizing:border-box; } #c{ background-color:#01295f; } </style> </head> <body> <canvas id="c"></canvas> <script> let w = window.innerWidth; let h = window.innerHeight; let cw = w / 2; let ch = h / 2; let colorsArr = ['#437F97', '#849324', '#FFB30F', '#FD151B', '#013E3f', '#dedede']; // let colorsArr = ['#bbb','#eee'] let canvas = document.querySelector('#c'); canvas.width = w; canvas.height = h; let ctx = canvas.getContext('2d'); let counter = 0; let speed = 0.07; let waveH = h / 13; let freq = 4; // how many waves; value = length, so smaller number = more waves (2-20) .........完整代码请登录后点击上方下载按钮下载查看
网友评论0