Tone+skrollr实现滚动鼠标弹奏钢琴效果代码

代码语言:html

所属分类:其他

代码描述:Tone+skrollr实现滚动鼠标弹奏钢琴效果代码,利用skrollr来捕获滚动,利用Tone来模拟钢琴发声。

代码标签: Tone skrollr 滚动 鼠标 弹奏 钢琴

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1">

<style>
    body {
  background: #000;
}
body .background {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background-image: url(//repo.bfw.wiki/bfwrepo/icon/62abac9d2c755.gif);
  background-size: cover;
  background-position: center;
  opacity: 0.15;
}

.mask {
  position: fixed;
  top: calc(50% - 0.1rem);
  left: 0;
  height: 0.2rem;
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  z-index: 7;
}

#container {
  padding: 50vh 0 60vh;
  box-sizing: border-box;
  position: relative;
  z-index: 8;
}

#autoscroll,
#current-chord {
  font-weight: light;
  position: fixed;
  bottom: 1rem;
  line-height: 1;
  z-index: 10;
  font-size: 20px;
  font-weight: 100;
}

#autoscroll {
  cursor: pointer;
  text-decoration: none;
  transition: opacity 500ms ease-out, color 500ms ease-out;
  color: white;
  left: 50%;
  transform: trnaslateX(-50%);
}
#autoscroll::after {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 200px;
  text-align: center;
  display: block;
  transform: translateX(-50%);
  content: "Enable Auto Scroll";
}
#autoscroll.active {
  color: rgba(255, 255, 255, 0.2);
}
#autoscroll.active::after {
  content: "Enable Manual Scroll";
}
#autoscroll:hover {
  color: rgba(255, 255, 255, 0.5);
}

#current-chord {
  color: rgba(255, 255, 255, 0.5);
  right: 1rem;
}

section {
  position: relative;
  margin: 2rem auto;
  width: 98%;
}
section.active span {
  transform: scaleX(1.4);
}
section._1_32 {
  height: 7vh;
}
section._2_32 {
  height: 14vh;
}
section._3_32 {
  height: 21vh;
}
section._4_32 {
  height: 28vh;
}
section._5_32 {
  height: 35vh;
}
section._6_32 {
  height: 42vh;
}
section._7_32 {
  height: 49vh;
}
section._8_32 {
  height: 56vh;
}
section._9_32 {
  height: 63vh;
}
section._10_32 {
  height: 70vh;
}
section._11_32 {
  height: 77vh;
}
section._12_32 {
  height: 84vh;
}
section._13_32 {
  height: 91vh;
}
section._14_32 {
  height: 98vh;
}
section._15_32 {
  height: 105vh;
}
section._16_32 {
  height: 112vh;
}
section._17_32 {
  height: 119vh;
}
section._18_32 {
  height: 126vh;
}
section._19_32 {
  height: 133vh;
}
section._20_32 {
  height: 140vh;
}
section._21_32 {
  height: 147vh;
}
section._22_32 {
  height: 154vh;
}
section._23_32 {
  height: 161vh;
}
section._24_32 {
  height: 168vh;
}
section._25_32 {
  height: 175vh;
}
section._26_32 {
  height: 182vh;
}
section._27_32 {
  height: 189vh;
}
section._28_32 {
  height: 196vh;
}
section._29_32 {
  height: 203vh;
}
section._30_32 {
  height: 210vh;
}
section._31_32 {
  height: 217vh;
}
section._32_32 {
  height: 224vh;
}
section span, section div {
  transition: transform 100ms ease-in-out;
}
section span {
  position: absolute;
  width: 0.5208333333%;
  top: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.05);
  color: white;
  transition: background 250ms ease-in-out, box-shadow 250ms ease-out;
}
section span.C2 {
  left: 0.5208333333%;
  box-shadow: 0px 0px 12px rgba(230, 26, 26, 0);
}
section.active span.C2 {
  background: #e61a1a;
  box-shadow: 0px 0px 12px #e61a1a;
}
section span.Db2 {
  left: 2.6041666667%;
  box-shadow: 0px 0px 12px rgba(230, 51, 26, 0);
}
section.active span.Db2 {
  background: #e6331a;
  box-shadow: 0px 0px 12px #e6331a;
}
section span.D2 {
  left: 4.6875%;
  box-shadow: 0px 0px 12px rgba(230, 77, 26, 0);
}
section.active span.D2 {
  background: #e64d1a;
  box-shadow: 0px 0px 12px #e64d1a;
}
section span.Eb2 {
  left: 6.7708333333%;
  box-shadow: 0px 0px 12px rgba(230, 102, 26, 0);
}
section.active span.Eb2 {
  background: #e6661a;
  box-shadow: 0px 0px 12px #e6661a;
}
section span.E2 {
  left: 8.8541666667%;
  box-shadow: 0px 0px 12px rgba(230, 128, 26, 0);
}
section.active span.E2 {
  background: #e6801a;
  box-shadow: 0px 0px 12px #e6801a;
}
section span.F2 {
  left: 10.9375%;
  box-shadow: 0px 0px 12px rgba(230, 153, 26, 0);
}
section.active span.F2 {
  background: #e6991a;
  box-shadow: 0px 0px 12px #e6991a;
}
section span.Gb2 {
  left: 13.0208333333%;
  box-shadow: 0px 0px 12px rgba(230, 179, 26, 0);
}
section.active span.Gb2 {
  background: #e6b31a;
  box-shadow: 0px 0px 12px #e6b31a;
}
section span.G2 {
  left: 15.1041666667%;
  box-shadow: 0px 0px 12px rgba(230, 204, 26, 0);
}
section.active span.G2 {
  background: #e6cc1a;
  box-shadow: 0px 0px 12px #e6cc1a;
}
section span.Ab2 {
  left: 17.1875%;
  box-shadow: 0px 0px 12px rgba(230, 230, 26, 0);
}
section.active span.Ab2 {
  background: #e6e61a;
  box-shadow: 0px 0px 12px #e6e61a;
}
section span.A2 {
  left: 19.2708333333%;
  box-shadow: 0px 0px 12px rgba(204, 230, 26, 0);
}
section.active span.A2 {
  background: #cce61a;
  box-shadow: 0px 0px 12px #cce61a;
}
section span.Bb2 {
  left: 21.3541666667%;
  box-shadow: 0px 0px 12px rgba(179, 230, 26, 0);
}
section.active span.Bb2 {
  background: #b3e61a;
  box-shadow: 0px 0px 12px #b3e61a;
}
section span.B2 {
  left: 23.4375%;
  box-shadow: 0px 0px 12px rgba(153, 230, 26, 0);
}
section.active span.B2 {
  background: #99e61a;
  box-shadow: 0px 0px 12px #99e61a;
}
section span.C3 {
  left: 25.5208333333%;
  box-shadow: 0px 0px 12px rgba(128, 230, 26, 0);
}
section.active span.C3 {
  background: #80e61a;
  box-shadow: 0px 0px 12px #80e61a;
}
section span.Db3 {
  left: 27.6041666667%;
  box-shadow: 0px 0px 12px rgba(102, 230, 26, 0);
}
section.active span.Db3 {
  background: #66e61a;
  box-shadow: 0px 0px 12px #66e61a;
}
section span.D3 {
  left: 29.6875%;
  box-shadow: 0px 0px 12px rgba(77, 230, 26, 0);
}
section.active span.D3 {
  background: #4de61a;
  box-shadow: 0px 0px 12px #4de61a;
}
section span.Eb3 {
  left: 31.7708333333%;
  box-shadow: 0px 0px 12px rgba(51, 230, 26, 0);
}
section.active span.Eb3 {
  background: #33e61a;
  box-shadow: 0px 0px 12px #33e61a;
}
section span.E3 {
  left: 33.8541666667%;
  box-shadow: 0px 0px 12px rgba(26, 230, 26, 0);
}
section.active span.E3 {
  background: #1ae61a;
  box-shadow: 0px 0px 12px #1ae61a;
}
section span.F3 {
  left: 35.9375%;
  box-shadow: 0px 0px 12px rgba(26, 230, 51, 0);
}
section.active span.F3 {
  background: #1ae633;
  box-shadow: 0px 0px 12px #1ae633;
}
section span.Gb3 {
  left: 38.0208333333%;
  box-shadow: 0px 0px 12px rgba(26, 230, 77, 0);
}
section.active span.Gb3 {
  background: #1ae64d;
  box-shadow: 0px 0px 12px #1ae64d;
}
section span.G3 {
  left: 40.1041666667%;
  box-shadow: 0px 0px 12px rgba(26, 230, 102, 0);
}
section.active span.G3 {
  background: #1ae666;
  box-shadow: 0px 0px 12px #1ae666;
}
section span.Ab3 {
  left: 42.1875%;
  box-shadow: 0px 0px 12px rgba(26, 230, 128, 0);
}
section.active span.Ab3 {
  background: #1ae680;
  box-shadow: 0px 0px 12px #1ae680;
}
section span.A3 {
  left: 44.2708333333%;
  box-shadow: 0px 0px 12px rgba(26, 230, 153, 0);
}
section.active span.A3 {
  background: #1ae699;
  box-shadow: 0px 0px 12px #1ae699;
}
section span.Bb3 {
  left: 46.3541666667%;
  box-shadow: 0px 0px 12px rgba(26, 230, 179, 0);
}
section.active span.Bb3 {
  background: #1ae6b3;
  box-shadow: 0px 0px 12px #1ae6b3;
}
section span.B3 {
  left: 48.4375%;
  box-shadow: 0px 0px 12px rgba(26, 230, 204, 0);
}
section.active span.B3 {
  background: #1ae6cc;
  box-shadow: 0px 0px 12px #1ae6cc;
}
section span.C4 {
  left: 50.5208333333%;
  box-shadow: 0px 0px 12px rgba(26, 230, 230, 0);
}
section.active span.C4 {
  background: #1ae6e6;
  box-shadow: 0px 0px 12px #1ae6e6;
}
section span.Db4 {
  left: 52.6041666667%;
  box-shadow: 0px 0px 12px rgba(26, 204, 230, 0);
}
section.active span.Db4 {
  background: #1acce6;
  box-shadow: 0px 0px 12px #1acce6;
}
section span.D4 {
  left: 54.6875%;
  box-shadow: 0px 0px 12px rgba(26, 179, 230, 0);
}
section.active span.D4 {
  background: #1ab3e6;
  box-shadow: 0px 0px 12px #1ab3e6;
}
section span.Eb4 {
  left: 56.7708333333%;
  box-shadow: 0px 0px 12px rgba(26, 153, 230, 0);
}
section.active span.Eb4 {
  background: #1a99e6;
  box-shadow: 0px 0px 12px #1a99e6;
}
section span.E4 {
  left: 58.8541666667%;
  box-shadow: 0px 0px 12px rgba(26, 128, 230, 0);
}
section.active span.E4 {
  background: #1a80e6;
  box-shadow: 0px 0px 12px #1a80e6;
}
section span.F4 {
  left: 60.9375%;
  box-shadow: 0px 0px 12px rgba(26, 102, 230, 0);
}
section.active span.F4 {
  background: #1a66e6;
  box-shadow: 0px 0px 12px #1a66e6;
}
section span.Gb4 {
  left: 63.0208333333%;
  box-shadow: 0px 0px 12px rgba(26, 77, 230, 0);
}
section.active span.Gb4 {
  background: #1a4de6;
  box-shadow: 0px 0px 12px #1a4de6;
}
section span.G4 {
  left: 65.1041666667%;
  box-shadow: 0px 0px 12px rgba(26, 51, 230, 0);
}
section.active span.G4 {
  background: #1a33e6;
  box-shadow: 0px 0px 12px #1a33e6;
}
section span.Ab4 {
  left: 67.1875%;
  box-shadow: 0px 0px 12px rgba(26, 26, 230, 0);
}
section.active span.Ab4 {
  background: #1a1ae6;
  box-shadow: 0px 0px 12px #1a1ae6;
}
section span.A4 {
  left: 69.2708333333%;
  box-shadow: 0px 0px 12px rgba(51, 26, 230, 0);
}
section.active span.A4 {
  background: #331ae6;
  box-shadow: 0px 0px 12px #331ae6;
}
section span.Bb4 {
  left: 71.3541666667%;
  box-shadow: 0px 0px 12px rgba(77, 26, 230, 0);
}
section.active span.Bb4 {
  background: #4d1ae6;
  box-shadow: 0px 0px 12px #4d1ae6;
}
section span.B4 {
  left: 73.4375%;
  box-shadow: 0px 0px 12px rgba(102, 26, 230, 0);
}
section.active span.B4 {
  background: #661ae6;
  box-shadow: 0px 0px 12px #661ae6;
}
section span.C5 {
  left: 75.5208333333%;
  box-shadow: 0px 0px 12px rgba(128, 26, 230, 0);
}
section.active span.C5 {
  background: #801ae6;
  box-shadow: 0px 0px 12px #801ae6;
}
section span.Db5 {
  left: 77.6041666667%;
  box-shadow: 0px 0px 12px rgba(153, 26, 230, 0);
}
section.active span.Db5 {
  background: #991ae6;
  box-shadow: 0px 0px 12px #991ae6;
}
section span.D5 {
  left: 79.6875%;
  box-shadow: 0px 0px 12px rgba(179, 26, 230, 0);
}
section.active span.D5 {
  background: #b31ae6;
  box-shadow: 0px 0px 12px #b31ae6;
}
section span.Eb5 {
  left: 81.7708333333%;
  box-shadow: 0px 0px 12px rgba(204, 26, 230, 0);
}
section.active span.Eb5 {
  background: #cc1ae6;
  box-shadow: 0px 0px 12px #cc1ae6;
}
section span.E5 {
  left: 83.8541666667%;
  box-shadow: 0px 0px 12px rgba(230, 26, 230, 0);
}
section.active span.E5 {
  background: #e61ae6;
  box-shadow: 0px 0px 12px #e61ae6;
}
section span.F5 {
  left: 85.9375%;
  box-shadow: 0px 0px 12px rgba(230, 26, 204, 0);
}
section.active span.F5 {
  background: #e61acc;
  box-shadow: 0px 0px 12px #e61acc;
}
section span.Gb5 {
  left: 88.0208333333%;
  box-shadow: 0px 0px 12px rgba(230, 26, 179, 0);
}
section.active span.Gb5 {
  background: #e61ab3;
  box-shadow: 0px 0px 12px #e61ab3;
}
section span.G5 {
  left: 90.1041666667%;
  box-shadow: 0px 0px 12px rgba(230, 26, 153, 0);
}
section.active span.G5 {
  background: #e61a99;
  box-shadow: 0px 0px 12px #e61a99;
}
section span.Ab5 {
  left: 92.1875%;
  box-shadow: 0px 0px 12px rgba(230, 26, 128, 0);
}
section.active span.Ab5 {
  background: #e61a80;
  box-shadow: 0px 0px 12px #e61a80;
}
section span.A5 {
  left: 94.2708333333%;
  box-shadow: 0px 0px 12px rgba(230, 26, 102, 0);
}
section.active span.A5 {
  background: #e61a66;
  box-shadow: 0px 0px 12px #e61a66;
}
section span.Bb5 {
  left: 96.3541666667%;
  box-shadow: 0px 0px 12px rgba(230, 26, 77, 0);
}
section.active span.Bb5 {
  background: #e61a4d;
  box-shadow: 0px 0px 12px #e61a4d;
}
section span.B5 {
  left: 98.4375%;
  box-shadow: 0px 0px 12px rgba(230, 26, 51, 0);
}
section.active span.B5 {
  background: #e61a33;
  box-shadow: 0px 0px 12px #e61a33;
}
section span.C6 {
  left: 100.5208333333%;
  box-shadow: 0px 0px 12px rgba(230, 26, 26, 0);
}
section.active span.C6 {
  background: #e61a1a;
  box-shadow: 0px 0px 12px #e61a1a;
}
section span.Db6 {
  left: 102.6041666667%;
  box-shadow: 0px 0px 12px rgba(230, 51, 26, 0);
}
section.active span.Db6 {
  background: #e6331a;
  box-shadow: 0px 0px 12px #e6331a;
}
section span.D6 {
  left: 104.6875%;
  box-shadow: 0px 0px 12px rgba(230, 77, 26, 0);
}
section.active span.D6 {
  background: #e64d1a;
  box-shadow: 0px 0px 12px #e64d1a;
}
section span.Eb6 {
  left: 106.7708333333%;
  box-shadow: 0px 0px 12px rgba(230, 102, 26, 0);
}
section.active span.Eb6 {
  .........完整代码请登录后点击上方下载按钮下载查看

网友评论0