svg+js实现流体合成器带音效代码
代码语言:html
所属分类:动画
代码描述:svg+js实现流体合成器带音效代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;500;800&display=swap" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/tone/14.8.49/Tone.js"></script>
<style>
/* fluid css concepts with min, max, clamp */
/* Code Writed by: holasoymalva */
:root {
--bg-color: #05050a;
--panel-bg: rgba(20, 20, 30, 0.4);
--panel-border: rgba(255, 255, 255, 0.08);
--text-primary: #ffffff;
--text-secondary: #888899;
--accent: #00ffcc;
--accent-glow: rgba(0, 255, 204, 0.5);
/* Dynamic variables updated by JS */
--hue: 280;
--blob-size: 150px;
--anim-speed: 20s;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: "Outfit", sans-serif;
background-color: var(--bg-color);
background-image: radial-gradient(
circle at 10% 20%,
rgba(20, 10, 50, 0.5) 0%,
transparent 40%
),
radial-gradient(circle at 90% 80%, rgba(10, 40, 40, 0.4) 0%, transparent 40%);
color: var(--text-primary);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
/* CSS clamp() for safe body padding, it never gets too small or too large */
padding: clamp(1rem, 3vw, 3rem);
overflow-x: hidden;
}
.app-container {
/* Using max() and clamp() for responsive width */
width: 100%;
width: clamp(320px, 90vw, 1200px);
display: flex;
flex-direction: column;
gap: clamp(1rem, 2vw, 2rem);
}
.header {
text-align: center;
}
.header h1 {
/* CSS clamp() for fluid typography */
font-size: clamp(2.5rem, 5vw, 4rem);
font-weight: 800;
letter-spacing: -1px;
background: linear-gradient(90deg, #fff, var(--text-secondary));
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
margin-bottom: 0.5rem;
}
.header p {
font-size: clamp(0.9rem, 1.5vw, 1.1rem);
color: var(--text-secondary);
font-weight: 300;
}
.header span {
color: var(--accent);
font-weight: 500;
}
.main-content {
display: grid;
/* Use CSS Grid minmax() to automatically switch from 1 column (mobile) to 2 columns (desktop) */
grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr));
gap: clamp(1.5rem, 3vw, 2.5rem);
align-items: stretch;
}
/* --- Artboard (The Visual part) --- */
.artboard-wrapper {
background: var(--panel-bg);
border: 1px solid var(--panel-border);
border-radius: 24px;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
position: relative;
/* max() ensures the box is never too small vertically */
min-height: max(400px, 50vh);
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4),
inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.artboard {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
filter: url("#gooey");
}
.blob {
position: absolute;
/* CSS max() ensures it never gets smaller than 50px */
width: max(50px, var(--blob-size));
height: max(50px, var(--blob-size));
border-radius: 50%;
background: .........完整代码请登录后点击上方下载按钮下载查看
















网友评论0