canvas牛顿摆动画效果代码
代码语言:html
所属分类:动画
代码描述:canvas牛顿摆动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { width: 100vw; height: 100vh; margin: 0; overflow: hidden; } .container { width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; background: #0d0d0d; } .canvas { width: 600px; height: 600px; background: antiquewhite; border: 10px solid dimgrey; } </style> </head> <body > <div class="container"> <canvas class="canvas"></canvas> </div> <script > const $canvas = document.querySelector('.canvas'); const context = $canvas.getContext('2d'); const pixelRatio = window.devicePixelRatio || 1; const canvasStyleWidth = $canvas.clientWidth; const canvasStyleHeight = $canvas.clientHeight; $canvas.width = canvasStyleWidth * pixelRatio; $canvas.height = canvasStyleHeight * pixelRatio; context.scale(pixelRatio, pixelRatio); const middleX = canvasStyleWidth / .........完整代码请登录后点击上方下载按钮下载查看
网友评论0