js+css实现文字字母重力落下弹奏曲子代码
代码语言:html
所属分类:其他
代码描述:js+css实现文字字母重力落下弹奏曲子代码
代码标签: js css 文字 字母 重力 落下 弹奏 曲子 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
body {
background: #efefef;
overflow: hidden;
width: 100vw;
height: 100vh;
}
svg {
display: block;
width: 100vw;
height: 100vh; touch-action: none;
}
#hint {
position: fixed;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
font-family: sans-serif;
font-size: 18px;
letter-spacing: 0.08em;
color: #999;
opacity: 0;
pointer-events: none;
transition: opacity 0.6s ease;
}
#flash {
position: fixed;
inset: 0;
background: radial-gradient(
circle at 50%,
rgba(255, 255, 255, 1),
rgba(255, 255, 255, 0.6),
rgba(255, 255, 255, 0)
);
opacity: 0;
pointer-events: none;
}
.cut-line {
animation: dash-flow 0.3s linear infinite;
}
@keyframes dash-flow {
to {
stroke-dashoffset: -10;
}
}
button {
font: 13px monospace;
padding: 6px 10px;
cursor: pointer;
}
#controls {
position: fixed;
top: 12px;
right: 12px;
z-index: 10;
}
</style>
</head>
<body translate="no">
<div id="flash"></div>
<svg id="canvas" viewBox="0 0 1000 1000"></svg>
<div id="controls">
<button id="toggle">grid</button>
<button id="mute">mute</button>
<button id="balldrop">surprise!</button>
</div>
<script type="module">
import opentype from "https://esm.sh/opentype.js";
import Matter from "https://esm.sh/matter-js";
import decomp from "https://esm.sh/poly-decomp";
console.clear();
Matter.Common.setDecomp(decomp);
const { Engine, Bodies, Body, Composite, Vertices, Query, Constraint } = Matter;
const CONFIG = {
idleLetters: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
fontSize: window.innerWidth < 700 ? 34 : window.innerWidth > 1000 ? 70 : 50,
// Pin grid, expressed relative to fontSize so letters keep fitting through
pinSpacingX: 2.2, // * fontSize
pinSpacingY: 1.7, // * fontSize
pinRadius: 8,
pinTopOffset: 2.5, // * fontSize, empty drop zone above .........完整代码请登录后点击上方下载按钮下载查看















网友评论0