scrawl-canvas实现cavas圆点随鼠标移动交互动画效果代码
代码语言:html
所属分类:悬停
代码描述:scrawl-canvas实现cavas圆点随鼠标移动交互动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { font-family: sans-serif; text-align: center; } canvas { margin: 0 auto; } </style> </head> <body translate="no" > <h2>Worry beads</h2> <p>Let your mouse do the worrying ...</p> <canvas id="mycanvas" width="400" height="400"></canvas> <script type="module"> import scrawl from 'https://unpkg.com/scrawl-canvas@8.2.4'; let canvas = scrawl.library.canvas.mycanvas, here = canvas.here, halfWidth = 200, ringRadius = 120, beadRadius = 5, beadColor = 'red', beadBorder = 'black', beads = 36; canvas.set({ width: halfWidth * 2, height: halfWidth * 2, backgroundColor: 'aliceblue', }) let coord = scrawl.requestCoordinate(0, ringRadius), step = 360 / beads, pins = []; for (let i = 0; i < 360; i += step) { let [x, y] = coord; pins.push(scrawl.makeWheel({ name: `pin-${i}`, radius: beadRadius, startX: x + halfWidth, startY: y + halfWidth, handle: ['ce.........完整代码请登录后点击上方下载按钮下载查看
网友评论0