Init
This commit is contained in:
commit
0ad405c26e
78 changed files with 9127 additions and 0 deletions
43
src/lib/state/tools.svelte.ts
Normal file
43
src/lib/state/tools.svelte.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import type { PageData } from '$lib/model/types';
|
||||
import { settings } from './settings.svelte';
|
||||
|
||||
export type Tool = 'text' | 'pen' | 'highlighter' | 'eraser';
|
||||
|
||||
export const PEN_WIDTHS = [1.2, 2, 3.5];
|
||||
export const HIGHLIGHTER_WIDTHS = [10, 16, 24];
|
||||
|
||||
class Tools {
|
||||
tool = $state<Tool>('text');
|
||||
penColor = $state(settings.data.penColors[0]);
|
||||
penWidth = $state(PEN_WIDTHS[1]);
|
||||
highlighterColor = $state(settings.data.highlighterColors[0]);
|
||||
highlighterWidth = $state(HIGHLIGHTER_WIDTHS[1]);
|
||||
eraserRadius = $state(8);
|
||||
|
||||
/** Pages of an imported PDF waiting to be placed on the canvas. */
|
||||
placing = $state.raw<{ name: string; pages: PageData[] } | null>(null);
|
||||
|
||||
get inking() {
|
||||
return this.tool !== 'text';
|
||||
}
|
||||
|
||||
get color() {
|
||||
return this.tool === 'highlighter' ? this.highlighterColor : this.penColor;
|
||||
}
|
||||
|
||||
set color(c: string) {
|
||||
if (this.tool === 'highlighter') this.highlighterColor = c;
|
||||
else this.penColor = c;
|
||||
}
|
||||
|
||||
get width() {
|
||||
return this.tool === 'highlighter' ? this.highlighterWidth : this.penWidth;
|
||||
}
|
||||
|
||||
set width(w: number) {
|
||||
if (this.tool === 'highlighter') this.highlighterWidth = w;
|
||||
else this.penWidth = w;
|
||||
}
|
||||
}
|
||||
|
||||
export const tools = new Tools();
|
||||
Loading…
Add table
Add a link
Reference in a new issue