p5多圆环折叠运行动画效果
代码语言:html
所属分类:动画
代码描述:p5多圆环折叠运行动画效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> body { margin: 0; overflow: hidden; display: flex; height: 100vh; background: black; } canvas { margin: auto; touch-action: none; } input { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); width: 80%; height: 34px; max-width: 400px; background: transparent; -webkit-appearance: none; appearance: none; } input:active { cursor: grabbing; } input::-webkit-slider-runnable-track { box-sizing: border-box; height: 6px; background: #fff; -webkit-appearance: none; appearance: none; } input::-moz-range-track { box-sizing: border-box; height: 6px; background: #fff; -webkit-appearance: none; appearance: none; } input::-ms-track { box-sizing: border-box; height: 6px; background: #fff; -webkit-appearance: none; appearance: none; } input::-webkit-slider-thumb { margin-top: -12px; box-sizing: border-box; width: 30px; height: 30px; border-radius: 50%; background: #fff; border: 2px solid black; -webkit-appearance: none; appearance: none; cursor: grab; } input::-moz-range-thumb { box-sizing: border-box; width: 30px; height: 30px; border-radius: 50%; background: #fff; border: 2px solid black; -webkit-appearance: none; appearance: none; cursor: grab; } input::-ms-thumb { margin-top: 0px; box-sizing: border-box; width: 30px; height: 30px; border-radius: 50%; background: #fff; border: 2px solid black; -webkit-appearance: none; appearance: none; cursor: grab; } section { box-sizing: border-box; font-size: 30px; color: white; position: fixed; left: 0; top: 20px; width: 100%; text-align: center; padding: 10px 10%; z-index: 10; pointer-events: none; text-shadow: 0 0 3px black, 0 0 4px black, 0 0 5px black; background: rgba(0, 0, 0, 0.7); font-family: 'Montserrat', sans-serif; } section p { margin: 0; } @media (max-width: 500px) { section { font-size: 24px; } } code { white-space: nowrap; } </style> </head> <body translate="no"> <input type="range" min="1" max="7" step="1" id="step" value="1"> <section> <p>Draw a circle</p> <p>Pick 6 evenly spaced points along the circle</p> <p>Draw circles from each point with the same radius</p> <p>Animate the radius of the inner circle</p> <p>Increase the amount of petals and hide the inner circle</p> <p>Use a different color for each petal</p> <p>Add even more petals and use a blend mode of type 'screen'</p> </section> <script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/p5.js"></script> <script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/gsap.min.js"></script> <script> let canvas; let anim = { petalRadius: 0.5 }; console.clear(); /* ====== STEP 1 ====== */ function goToStep1 () { blendMode(SCREEN); noLoop(); strokeWeight(2); } function step1 () { clear(); noFill(); stroke(255); const r = min(width, height) * 0.4; circle(width/2, height/2, r); } /* ====== STEP 2 ====== */ function goToStep2 () { blendMode(SCREEN); noLoop(); strokeWeight(2); } function step2 () { clear(); noFill(); stroke(255); const r = min(width, height) * 0.4; circle(width/2, height/2, r); const petals = 6; for (let i = 0; i < petals; i++) { const x = sin(i / petals * TWO_PI) * (r * 0.5) + width / 2; const y = cos(i / petals * TWO_PI) * (r * 0.5) + height / 2; fill(255); circle(x, y, 10); } } /* ====== STEP 3 ====== */ let step3Index = 0; function goToStep3 () { blendMode(SCREEN); loop();.........完整代码请登录后点击上方下载按钮下载查看
网友评论0