-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
376 lines (352 loc) · 15.6 KB
/
Copy pathindex.html
File metadata and controls
376 lines (352 loc) · 15.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Scape.js — Animated Background Runtime</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link
href="https://fonts.googleapis.com/css2?family=Bebas+Neue&family=IBM+Plex+Mono:ital,wght@0,400;0,500;1,400&family=DM+Sans:wght@300;400;500&display=swap"
rel="stylesheet" />
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<!-- Fixed background canvas -->
<canvas id="bg-canvas"></canvas>
<!-- NAV -->
<nav>
<div class="nav-brand">Scape.js</div>
<div class="nav-links">
<a href="#how">How it works</a>
<a href="#shapes">Shapes</a>
<a href="#api">API</a>
<a href="demo/index.html">Demo</a>
<a href="https://github.com/Ali-Cheikh/scape.js" target="_blank">GitHub</a>
</div>
<button class="mobile-nav-toggle" id="mobileNavToggle" aria-expanded="false" aria-controls="mobileNavMenu">
Menu
</button>
<a href="https://cdn.jsdelivr.net/gh/Ali-Cheikh/scape.js@main/scape.js" class="nav-cta">Get CDN Link</a>
<div class="mobile-nav" id="mobileNavMenu">
<a href="#how">How it works</a>
<a href="#shapes">Shapes</a>
<a href="#api">API</a>
<a href="demo/index.html">Demo</a>
<a href="https://github.com/Ali-Cheikh/scape.js" target="_blank">GitHub</a>
<a href="https://cdn.jsdelivr.net/gh/Ali-Cheikh/scape.js@main/scape.js" class="mobile-nav-cta">Get CDN Link</a>
</div>
</nav>
<!-- HERO -->
<header class="hero">
<div class="hero-left">
<div class="hero-eyebrow fade-up d1">Background Runtime v1.0.3</div>
<h1 class="hero-title fade-up d2">Scape<span>.</span>js</h1>
<p class="hero-sub fade-up d3">
Lightweight (~5KB) animated background engine.<br />
19 shape primitives, image nodes, config-driven motion.<br />
Zero dependencies. Drop in and go.
</p>
<div class="hero-actions fade-up d4">
<a href="#how" class="btn-primary">Get Started</a>
<a href="demo/index.html" class="btn-primary">Open Demo</a>
<a href="https://github.com/Ali-Cheikh/scape.js" target="_blank" class="btn-ghost">View Source</a>
</div>
</div>
<div class="hero-right fade-up d3">
<div class="live-box">
<div class="live-box-label">● Live Preview</div>
<canvas id="preview-canvas"></canvas>
</div>
<div class="stats-row">
<div class="stat">
<div class="stat-num">~5</div>
<div class="stat-label">KB Gzipped</div>
</div>
<div class="stat">
<div class="stat-num">19</div>
<div class="stat-label">Shape Primitives</div>
</div>
<div class="stat">
<div class="stat-num">0</div>
<div class="stat-label">Dependencies</div>
</div>
</div>
</div>
</header>
<!-- MARQUEE -->
<div class="marquee-track" aria-hidden="true">
<div class="marquee-inner">
<span>Circle <em>○</em></span>
<span>Hexagon <em>⬡</em></span>
<span>Heart <em>♥</em></span>
<span>Diamond <em>◆</em></span>
<span>Star <em>★</em></span>
<span>Triangle <em>▲</em></span>
<span>Pentagon <em>⬠</em></span>
<span>Snowflake <em>✶</em></span>
<span>Tesseract <em>◈</em></span>
<span>Fractal <em>◎</em></span>
<span>Circle <em>○</em></span>
<span>Hexagon <em>⬡</em></span>
<span>Heart <em>♥</em></span>
<span>Diamond <em>◆</em></span>
<span>Star <em>★</em></span>
<span>Triangle <em>▲</em></span>
<span>Pentagon <em>⬠</em></span>
<span>Snowflake <em>✶</em></span>
<span>Tesseract <em>◈</em></span>
<span>Fractal <em>◎</em></span>
</div>
</div>
<!-- HOW IT WORKS -->
<section class="how-section" id="how">
<div class="section-inner">
<div class="section-label">// How It Works</div>
<div class="how-grid">
<div>
<h2 class="how-heading">Drop.<br />Config.<br />Done.</h2>
<p class="how-desc">
Scape resolves your config object, mounts DOM-backed shape nodes,
and drives them with lightweight CSS animation hooks. No canvas API
to wrestle with. No build step required.
</p>
<div class="steps">
<div class="step">
<div class="step-num">01</div>
<div>
<div class="step-title">Include the script</div>
<div class="step-body">One CDN tag. That's the entire install surface.</div>
</div>
</div>
<div class="step">
<div class="step-num">02</div>
<div>
<div class="step-title">Set window.ScapeConfig</div>
<div class="step-body">Declare shape type, count, colors, animation timing before the script loads.
</div>
</div>
</div>
<div class="step">
<div class="step-num">03</div>
<div>
<div class="step-title">Background initializes</div>
<div class="step-body">Scape auto-mounts on DOMContentLoaded and responds to window resize.</div>
</div>
</div>
</div>
</div>
<div>
<div class="code-panel">
<div class="code-bar">
<div class="code-dot" style="background:#ff5f56"></div>
<div class="code-dot" style="background:#ffbd2e"></div>
<div class="code-dot" style="background:#27c93f"></div>
<span class="code-filename">config.js</span>
</div>
<div class="code-body">
<span class="c">// Set this BEFORE loading scape.js</span><br />
<span class="k">window</span>.<span class="n">ScapeConfig</span> <span class="p">=</span> {<br />
<span class="n">type</span><span class="p">:</span> <span class="s">'shape'</span>,<br />
<span class="n">shape</span><span class="p">:</span> <span class="s">'star'</span>,<br />
<span class="n">count</span><span class="p">:</span> 30,<br />
<span class="n">size</span><span class="p">:</span> 24,<br />
<span class="n">fillColor</span><span class="p">:</span> <span class="s">'hsla(200, 90%, 60%,
0.8)'</span>,<br />
<span class="n">strokeColor</span><span class="p">:</span> <span class="s">'rgba(255, 255,
255, 0.5)'</span>,<br />
<span class="n">strokeWidth</span><span class="p">:</span> 2,<br />
<span class="n">animationDuration</span><span class="p">:</span> <span
class="s">'6s'</span>,<br />
<span class="n">floatDistance</span><span class="p">:</span> 16,<br />
<span class="n">rotationRange</span><span class="p">:</span> 180,<br />
<span class="n">opacity</span><span class="p">:</span> 0.8<br />
};<br /><br />
<span class="c">// For image-based backgrounds:</span><br />
<span class="k">window</span>.<span class="n">ScapeConfig</span> <span class="p">=</span> {<br />
<span class="n">type</span><span class="p">:</span> <span class="s">'image'</span>,<br />
<span class="n">imageUrl</span><span class="p">:</span> <span
class="s">'path/to/logo.png'</span>,<br />
<span class="n">count</span><span class="p">:</span> 20,<br />
<span class="n">size</span><span class="p">:</span> 50<br />
};
</div>
</div>
<div class="code-panel" style="margin-top:1px">
<div class="code-bar">
<div class="code-dot" style="background:#ff5f56"></div>
<div class="code-dot" style="background:#ffbd2e"></div>
<div class="code-dot" style="background:#27c93f"></div>
<span class="code-filename">index.html</span>
</div>
<div class="code-body">
<span class="c"><!-- 1. Config first --></span><br />
<span class="k"><script</span> <span class="n">src</span><span class="p">=</span><span
class="s">"config.js"</span><span class="k">></script></span><br /><br />
<span class="c"><!-- 2. Then Scape --></span><br />
<span class="k"><script</span> <span class="n">src</span><span class="p">=</span><span
class="s">"https://cdn.jsdelivr.net/gh/<br /> Ali-Cheikh/scape.js@main/scape.js"</span><br />
<span class="k">></script></span>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- SHAPES -->
<section class="shapes-section" id="shapes">
<div class="section-inner">
<div class="shapes-header">
<div>
<div class="section-label">// Shape Primitives</div>
<h2 class="shapes-heading">Every shape<br />you need.</h2>
</div>
<div class="shape-count-label">
<strong>19</strong>
Primitives
</div>
</div>
<div class="shapes-grid" id="shapes-grid"></div>
</div>
</section>
<!-- API -->
<section class="api-section" id="api">
<div class="section-inner">
<div class="section-label">// Runtime API</div>
<div class="api-grid">
<div>
<h2 class="api-heading">Control at<br />runtime.</h2>
<p class="how-desc">
Every method is available on the global <code
style="color:var(--acid);font-family:'IBM Plex Mono',monospace;font-size:0.85em">ScapeJs</code> object.
Call them after DOMContentLoaded.
</p>
<div class="code-panel" style="margin-top:2rem">
<div class="code-bar">
<div class="code-dot" style="background:#ff5f56"></div>
<div class="code-dot" style="background:#ffbd2e"></div>
<div class="code-dot" style="background:#27c93f"></div>
<span class="code-filename">runtime.js</span>
</div>
<div class="code-body">
<span class="n">document</span>.<span class="k">addEventListener</span>(<span
class="s">'DOMContentLoaded'</span>, () <span class="p">=></span> {<br /><br />
<span class="c">// Swap to hearts on a button click</span><br />
<span class="n">ScapeJs</span>.<span class="k">updateConfig</span>({ <span
class="n">shape</span><span class="p">:</span> <span class="s">'heart'</span> });<br /><br />
<span class="c">// Pause on modal open</span><br />
<span class="n">ScapeJs</span>.<span class="k">pause</span>();<br /><br />
<span class="c">// Resume on modal close</span><br />
<span class="n">ScapeJs</span>.<span class="k">resume</span>();<br /><br />
<span class="c">// Swap background image</span><br />
<span class="n">ScapeJs</span>.<span class="k">setImage</span>(<span
class="s">'logo.png'</span>);<br /><br />
});
</div>
</div>
</div>
<div>
<div class="method-list">
<div class="method-item">
<div class="method-name">ScapeJs.refresh()</div>
<div class="method-desc">Regenerates the background</div>
</div>
<div class="method-item">
<div class="method-name">ScapeJs.updateConfig(obj)</div>
<div class="method-desc">Merges config and re-renders</div>
</div>
<div class="method-item">
<div class="method-name">ScapeJs.destroy()</div>
<div class="method-desc">Removes all mounted nodes</div>
</div>
<div class="method-item">
<div class="method-name">ScapeJs.setImage(url)</div>
<div class="method-desc">Swaps image at runtime</div>
</div>
<div class="method-item">
<div class="method-name">ScapeJs.pause()</div>
<div class="method-desc">Freezes all animations</div>
</div>
<div class="method-item">
<div class="method-name">ScapeJs.resume()</div>
<div class="method-desc">Restores animation playback</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- USE CASES -->
<section class="use-section">
<div class="section-inner">
<div class="section-label">// Use Cases</div>
<h2 class="use-heading">Where it lives.</h2>
<div class="use-grid">
<div class="use-card">
<div class="use-num">01</div>
<div class="use-title">Brand Motion Layers</div>
<div class="use-body">Make product surfaces feel premium. Ambient geometry that reads as designed, not
decorative noise.</div>
</div>
<div class="use-card">
<div class="use-num">02</div>
<div class="use-title">Error Surfaces</div>
<div class="use-body">Turn 404s and empty states into intentional experiences with reactive floating shapes.
</div>
</div>
<div class="use-card">
<div class="use-num">03</div>
<div class="use-title">Portfolio Systems</div>
<div class="use-body">Showcase creative work with custom shapes and animation profiles that reflect your
aesthetic.</div>
</div>
</div>
</div>
</section>
<!-- FOOTER -->
<footer>
<div class="footer-brand">Scape.js</div>
<div class="footer-meta">
MIT Licensed · v1.0.3 · Made by <a href="https://github.com/Ali-Cheikh"
target="_blank">Ali Cheikh</a><br />
No dependencies · ~5KB gzipped · Works everywhere
</div>
<div class="footer-cta">
<a href="https://github.com/Ali-Cheikh/scape.js" target="_blank">View on GitHub →</a>
</div>
</footer>
<!-- Load modular scripts -->
<script src="js/shapes.js"></script>
<script src="js/canvas.js"></script>
<script>
// Initialize all components on DOMContentLoaded
document.addEventListener('DOMContentLoaded', () => {
// Initialize canvas animations
CanvasAnimations.init();
// Render shapes grid
ShapeRenderer.renderGrid('shapes-grid');
// Mobile nav toggle
const nav = document.querySelector('nav');
const mobileToggle = document.getElementById('mobileNavToggle');
const mobileMenu = document.getElementById('mobileNavMenu');
if (nav && mobileToggle && mobileMenu) {
mobileToggle.addEventListener('click', () => {
const isOpen = nav.classList.toggle('nav-open');
mobileToggle.setAttribute('aria-expanded', String(isOpen));
});
mobileMenu.querySelectorAll('a').forEach((link) => {
link.addEventListener('click', () => {
nav.classList.remove('nav-open');
mobileToggle.setAttribute('aria-expanded', 'false');
});
});
window.addEventListener('resize', () => {
if (window.innerWidth > 900) {
nav.classList.remove('nav-open');
mobileToggle.setAttribute('aria-expanded', 'false');
}
});
}
});
</script>
</body>
</html>