tangled
alpha
login
or
join now
moth11.net
/
xcvr
2
fork
atom
frontend for xcvr appview
2
fork
atom
overview
issues
pulls
pipelines
idk
moth11.net
6 months ago
c583499b
7e94afed
+11
-26
3 changed files
expand all
collapse all
unified
split
src
lib
components
CursorEffect.svelte
routes
+layout.svelte
settings
+page.svelte
+3
-18
src/lib/components/CursorEffect.svelte
···
3
3
import { browser } from "$app/environment";
4
4
import { Polyline, Renderer, Transform, Vec3, Color } from "ogl";
5
5
interface Props {
6
6
-
enabled: boolean;
7
6
colors?: Array<string>;
8
7
}
9
8
10
10
-
let { enabled, colors = ["#e18f39", "#c5c042", "#387f4d", "#1d4633"] } =
11
11
-
$props();
9
9
+
let { colors = ["#e18f39", "#c5c042", "#387f4d", "#1d4633"] } = $props();
12
10
13
11
let canvas: undefined | HTMLCanvasElement = $state();
14
12
const thickness: [number, number] = [14, 35];
···
74
72
premultipliedAlpha: true,
75
73
canvas,
76
74
});
77
77
-
if (!browser || !enabled) return;
75
75
+
if (!browser) return;
78
76
const gl = renderer.gl;
79
77
gl.clearColor(0, 0, 0, 0);
80
78
gl.enable(gl.BLEND);
···
124
122
);
125
123
}
126
124
function update() {
127
127
-
if (!enabled) {
128
128
-
animationId = null;
129
129
-
return;
130
130
-
}
131
125
animationId = requestAnimationFrame(update);
132
126
lines.forEach((line) => {
133
127
for (let i = line.points.length - 1; i >= 0; i--) {
···
158
152
animationId = null;
159
153
}
160
154
}
161
161
-
$effect(() => {
162
162
-
if (enabled) {
163
163
-
startAnimation();
164
164
-
} else {
165
165
-
stopAnimation();
166
166
-
}
167
167
-
});
168
155
onMount(() => {
169
156
if (!browser) return;
170
157
initializeCursorEffect();
···
179
166
});
180
167
</script>
181
168
182
182
-
{#if enabled}
183
183
-
<canvas bind:this={canvas} id="cursor-canvas"></canvas>
184
184
-
{/if}
169
169
+
<canvas bind:this={canvas} id="cursor-canvas"></canvas>
185
170
186
171
<style>
187
172
#cursor-canvas {
+3
-1
src/routes/+layout.svelte
···
146
146
</div>
147
147
</aside>
148
148
{@render children()}
149
149
-
<CursorEffect enabled={true} />
149
149
+
{#if cursorenabled}
150
150
+
<CursorEffect />
151
151
+
{/if}
150
152
</div>
151
153
152
154
{#if !isDesktop}
+5
-7
src/routes/settings/+page.svelte
···
34
34
: defaultCursor;
35
35
let cursor = $state(initialCursor === "t");
36
36
$effect(() => {
37
37
-
if (cursor !== undefined) {
38
38
-
window.localStorage.setItem("cursor", cursor ? "t" : "f");
39
39
-
if (cursor) {
40
40
-
cursorContext.setCursorTrue();
41
41
-
} else {
42
42
-
cursorContext.setCursorFalse();
43
43
-
}
37
37
+
window.localStorage.setItem("cursor", cursor ? "t" : "f");
38
38
+
if (cursor) {
39
39
+
cursorContext.setCursorTrue();
40
40
+
} else {
41
41
+
cursorContext.setCursorFalse();
44
42
}
45
43
});
46
44
</script>