canvas实现拖动绳子回弹滑块代码
代码语言:html
所属分类:其他
代码描述:canvas实现拖动绳子回弹滑块代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Jelly Slider</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
display: flex;
flex-direction: column;
align-items: center;
height: 100vh;
background: #1a1a2e;
font-family: sans-serif;
overflow: hidden;
}
canvas {
width: 100%;
height: 100%;
cursor: grab;
}
canvas:active { cursor: grabbing; }
#controls {
position: absolute;
top: 10px;
right: 10px;
background: rgba(0,0,0,0.6);
padding: 12px;
border-radius: 8px;
color: white;
font-size: 13px;
z-index: 10;
}
#controls label {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 6px;
}
#controls input[type="range"] { width: 100px; }
#controls input[type="color"] { width: 30px; height: 24px; border: none; cursor: pointer; }
#attribution {
position: absolute;
bottom: 10px;
left: 50%;
transform: translateX(-50%);
z-index: 2;
background: rgba(0,0,0,0.7);
color: white;
padding: 0.75rem 1rem;
border-radius: 10px;
font-size: 1rem;
text-align: center;
white-space: nowrap;
transition: opacity 0.5s;
}
#attribution a { color: #87ceeb; text-decoration: none; }
#attribution a:hover { text-decoration: underline; }
</style>
</head>
<body>
<div id="controls">
<label>Jelly Color <input type="color" id="jellyColor" value="#ff7312"></label>
<label>Light Angle <input type="range" id="lightAngle" min="0" max="100" value="0"></label>
<label>Arch Strength <input type="range" id="archStr" min="0" max="100" value="50"></label>
</div>
<div id="attribution">
Inspired by work of
<a href="https://x.com/cerpow/status/1964953851603358112" target="_blank">Voicu Apostol</a>
</div>
<canvas id="canvas"></canvas>
<script>
(function() {
const canvas = document.getElementById(.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0