matter+Tone模拟小球重力下落触碰音乐按键发声效果代码
代码语言:html
所属分类:其他
代码描述:matter+Tone模拟小球重力下落触碰音乐按键发声效果代码
代码标签: matter Tone 模拟 小球 重力 下落 触碰 音乐 按键 发声 效果 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600&display=swap" rel="stylesheet"> <style> html { font-family: "Montserrat", sans-serif; } body { background-color: #14151f; } button { font-family: inherit; font-weight: 600; cursor: pointer; opacity: 0.8; } button:hover { opacity: 1; } button:active { opacity: 0.8; } .controls { display: grid; grid-template-columns: 0.5fr 1fr 1fr 1fr 0.5fr; align-items: center; justify-content: center; margin-top: 1em; gap: 1em; } .controls .drop-container { display: flex; justify-content: center; } .controls .drop-container .drop { position: relative; display: inline-flex; } .controls .drop-container .drop button { flex-shrink: 0; border: none; border-radius: 10px; padding: 1em 1em 1em 1em; background: lime; width: 7em; } .controls .drop-container .drop input[type=checkbox] { display: none; } .controls .drop-container .drop input[type=checkbox]:not(:checked) + label .checked { visibility: hidden; } .controls .drop-container .drop label[for=checkbox] { position: absolute; left: calc(100%); height: 100%; cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: 0 10px 10px 0; padding: 0 0.5em; opacity: 0.8; } .controls .drop-container .drop label[for=checkbox]:hover { opacity: 1; } .controls .drop-container .drop label[for=checkbox]:hover .box { background-color: rgba(255, 255, 255, 0.1); } .controls .drop-container .drop label[for=checkbox]:active { opacity: 0.8; } .controls .drop-container .drop label[for=checkbox] .box { position: relative; background-color: rgba(255, 255, 255, 0.1); border-radius: 0.2em; width: 0.8em; height: 0.8em; } .controls .drop-container .drop label[for=checkbox] .box:after { font-size: 0.6em; vertical-align: middle; position: absolute; left: calc(100% + 0.4em); color: #fff; content: "auto"; } .controls .drop-container .drop label[for=checkbox] .box svg { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); } #balls, #multiplier { position: relative; font-weight: 900; font-size: 2.2em; margin-right: auto; color: rgba(255, 255, 255, 0.2); } #balls:before, #multiplier:before { content: "-"; position: absolute; bottom: 100%; font-size: 0.3em; font-weight: 400; } #balls:before { content: "Balls"; } #multiplier { text-align: right; } #multiplier:before { content: "Drop"; right: 0; } .canvas-container { display: flex; align-items: center; justify-content: center; } .canvas-container canvas { display: block; margin: auto; } .notes { display: flex; align-items: flex-end; justify-content: center; gap: 5px; } .notes .note { display: flex; align-items: center; justify-content: center; width: 27px; aspect-ratio: 30/26; border-radius: 5px; background-color: gray; flex-shrink: 0; border-bottom: solid 4px yellow; text-align: center; font-size: 0.8em; font-weight: 600; } .notes .note[data-pressed=true] { animation: press 0.5s; } @keyframes press { 0% { border-bottom-width: 4px; } 50% { border-bottom-width: 0; } 100% { border-bottom-width: 4px; } } .notes .note:nth-child(1), .notes .note:nth-child(17) { background-color: #0f3; border-color: #0a0; } .notes .note:nth-child(2), .notes .note:nth-child(16) { background-color: #1f3; border-color: #0a0; } .notes .note:nth-child(3), .notes .note:nth-child(15) { background-color: #3f2; border-color: #0a0; } .notes .note:nth-child(4), .notes .note:nth-child(14) { background-color: #4f2; border-color: #0a0; } .notes .note:nth-child(5), .notes .note:nth-child(13) { background-color: #6f2; border-color: #0a0; } .notes .note:nth-child(6), .notes .note:nth-child(12) { background-color: #7f1; border-color: #3a0; } .notes .note:nth-child(7), .notes .note:nth-child(11) { background-color: #9f1; border-color: #4a0; } .notes .note:nth-child(8), .notes .note:nth-child(10) { background-color: #af0; border-color: #6a0; } .notes .note:nth-child(9) { background-color: #cf0; border-color: #7a0; } </style> </head> <body translate="no"> <div class="controls"> <div></div> <div> <div id="balls">-</div> </div> <div class="drop-container"> <div class="drop"> <button id="drop-button" type="button">Drop</button> <input id="checkbox" type="checkbox" /> <label for="checkbox"> <div class="box"> <svg class="checked" xmlns="http://www.w3.org/2000/svg" width="8px" height="8px" viewBox="0 0 24 24"> <path fill="#ffffff" d="M20.285 2l-11.285 11.567-5.286-5.011-3.714 3.716 9 8.728 15-15.285z" /> </svg> </div> </label> </div> </div> <div> <div id="multiplier">1</div> </div> <div></div> </div> <div class="canvas-container"> <canvas id="canvas"></canvas> </div> <div class="notes"> <div type="button" class="note" id="note-0">110</div> <div type="button" class="note" id="note-1">41x</div> <div type="button" class="note" id="note-2">10x</div> <div type="button" class="note" id="note-3">5x</div> <div type="button" class="note" id="note-4">3x</div> <div type="button" class="note" id="note-5">1.5x</div> <div type="button" class="note" id="note-6">1x</div> <div type="button" class="note" id="note-7">.5x</div> <div type="button" class="note" id="note-8">.3x</div> <div type="button" class="note" id="note-9">.5x</div> <div type="button" class="note" id="note-10">1x</div> <div type="button" class="note" id="note-11">1.5x</div> <div type="button" class="note" id="note-12">3x</div> <div type="button" class="note" id="note-13">5x</div> <div type="button" class="note" id="note-14">10x</div> <div type="button" class="note" id="note-15">41x</div> <div type="button" class="note" id="note-16">110</div> </div> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/matter.0.19.0.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/j.........完整代码请登录后点击上方下载按钮下载查看
网友评论0