Init
This commit is contained in:
commit
0ad405c26e
78 changed files with 9127 additions and 0 deletions
57
src/lib/components/InkLayer.svelte
Normal file
57
src/lib/components/InkLayer.svelte
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<script lang="ts">
|
||||
import { svgPath, HIGHLIGHTER_OPACITY } from '$lib/ink/stroke';
|
||||
import type { Stroke } from '$lib/model/types';
|
||||
|
||||
interface Props {
|
||||
width: number;
|
||||
height: number;
|
||||
strokes: Stroke[];
|
||||
/** Stroke being drawn right now (points mutate; `tick` changes). */
|
||||
live?: Stroke | null;
|
||||
tick?: number;
|
||||
/** Strokes hidden while an eraser gesture is in progress. */
|
||||
erasing?: Set<string>;
|
||||
}
|
||||
|
||||
let { width, height, strokes, live = null, tick = 0, erasing }: Props = $props();
|
||||
|
||||
const livePath = $derived.by(() => {
|
||||
void tick;
|
||||
return live ? svgPath(live, true) : '';
|
||||
});
|
||||
</script>
|
||||
|
||||
<svg class="ink" viewBox="0 0 {width} {height}" preserveAspectRatio="none" aria-hidden="true">
|
||||
{#each strokes as s (s.id)}
|
||||
{#if !erasing?.has(s.id)}
|
||||
<path
|
||||
d={svgPath(s)}
|
||||
fill={s.color}
|
||||
fill-opacity={s.tool === 'highlighter' ? HIGHLIGHTER_OPACITY : 1}
|
||||
class:hl={s.tool === 'highlighter'}
|
||||
/>
|
||||
{/if}
|
||||
{/each}
|
||||
{#if live}
|
||||
<path
|
||||
d={livePath}
|
||||
fill={live.color}
|
||||
fill-opacity={live.tool === 'highlighter' ? HIGHLIGHTER_OPACITY : 1}
|
||||
class:hl={live.tool === 'highlighter'}
|
||||
/>
|
||||
{/if}
|
||||
</svg>
|
||||
|
||||
<style>
|
||||
.ink {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
overflow: hidden;
|
||||
}
|
||||
.hl {
|
||||
mix-blend-mode: multiply;
|
||||
}
|
||||
</style>
|
||||
Loading…
Add table
Add a link
Reference in a new issue