@lvl99dotcom/paintcanvas 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/lib/brushes/StrokeEngine/index.d.ts +2 -2
- package/dist/lib/brushes/StrokeEngine/index.js +26 -28
- package/dist/lib/classes/BrushSettings/index.d.ts +24 -0
- package/dist/lib/classes/BrushSettings/index.js +35 -1
- package/dist/lib/classes/KeyboardShortcuts/index.d.ts +17 -6
- package/dist/lib/classes/KeyboardShortcuts/index.js +81 -18
- package/dist/lib/classes/PaintCanvas/index.d.ts +77 -27
- package/dist/lib/classes/PaintCanvas/index.js +141 -41
- package/dist/lib/classes/PaintCanvas/tool.d.ts +15 -0
- package/dist/lib/classes/PaintCanvas/tool.js +18 -0
- package/dist/lib/classes/Palette/index.d.ts +58 -0
- package/dist/lib/classes/Palette/index.js +92 -0
- package/dist/lib/classes/SettingsAutosave/index.d.ts +52 -0
- package/dist/lib/classes/SettingsAutosave/index.js +96 -0
- package/dist/lib/classes/ShortcutSettings/index.d.ts +63 -0
- package/dist/lib/classes/ShortcutSettings/index.js +110 -0
- package/dist/lib/palette/index.d.ts +49 -0
- package/dist/lib/palette/index.js +82 -0
- package/dist/lib/palette/schema.d.ts +45 -0
- package/dist/lib/palette/schema.js +41 -0
- package/dist/lib/rendering/cursors/index.d.ts +2 -0
- package/dist/lib/rendering/cursors/index.js +3 -1
- package/dist/lib/rendering/sample/index.js +3 -2
- package/dist/lib/settings/index.d.ts +63 -0
- package/dist/lib/settings/index.js +91 -0
- package/dist/lib/settings/schema.d.ts +150 -0
- package/dist/lib/settings/schema.js +102 -0
- package/dist/lib/storage/index.d.ts +36 -5
- package/dist/lib/storage/index.js +87 -29
- package/dist/lib/utils/colour/index.d.ts +72 -0
- package/dist/lib/utils/colour/index.js +154 -0
- package/dist/lib/utils/shortcuts/index.d.ts +174 -11
- package/dist/lib/utils/shortcuts/index.js +391 -145
- package/dist/lib/validation/validators.generated.d.ts +5 -0
- package/dist/lib/validation/validators.generated.js +872 -1
- package/dist/locales/en-GB.js +87 -1
- package/dist/locales/en-US.js +87 -1
- package/dist/locales/fr.js +87 -1
- package/dist/locales/ja.js +87 -1
- package/dist/locales/ko.js +87 -1
- package/dist/locales/zh-Hans.js +87 -1
- package/dist/locales/zh-Hant.js +87 -1
- package/dist/package.js +1 -1
- package/dist/ui/elements/PaintCanvas/index.d.ts +49 -47
- package/dist/ui/elements/PaintCanvas/index.js +121 -171
- package/dist/ui/elements/PaintCanvas/style.js +1 -1
- package/dist/ui/elements/PcAppSettings/index.d.ts +59 -0
- package/dist/ui/elements/PcAppSettings/index.js +222 -0
- package/dist/ui/elements/PcCanvas/index.d.ts +1 -1
- package/dist/ui/elements/PcCanvas/index.js +7 -5
- package/dist/ui/elements/PcColourPair/index.d.ts +43 -0
- package/dist/ui/elements/PcColourPair/index.js +125 -0
- package/dist/ui/elements/PcContextMenu/index.d.ts +70 -33
- package/dist/ui/elements/PcContextMenu/index.js +128 -97
- package/dist/ui/elements/PcLayerItem/index.d.ts +13 -34
- package/dist/ui/elements/PcLayerItem/index.js +39 -91
- package/dist/ui/elements/PcLayerItem/style.js +1 -1
- package/dist/ui/elements/PcMenu/index.d.ts +93 -0
- package/dist/ui/elements/PcMenu/index.js +204 -0
- package/dist/ui/elements/PcPane/index.d.ts +118 -0
- package/dist/ui/elements/PcPane/index.js +357 -0
- package/dist/ui/elements/PcPanel/index.d.ts +26 -8
- package/dist/ui/elements/PcPanel/index.js +76 -8
- package/dist/ui/elements/{PcBrushMenu → PcPanelBrushes}/index.d.ts +20 -6
- package/dist/ui/elements/{PcBrushMenu → PcPanelBrushes}/index.js +18 -14
- package/dist/ui/elements/PcPanelBrushes/style.js +3 -0
- package/dist/ui/elements/PcPanelColours/index.d.ts +171 -0
- package/dist/ui/elements/PcPanelColours/index.js +650 -0
- package/dist/ui/elements/PcPanelColours/style.js +3 -0
- package/dist/ui/elements/{PcLayersMenu → PcPanelLayers}/index.d.ts +17 -4
- package/dist/ui/elements/{PcLayersMenu → PcPanelLayers}/index.js +17 -10
- package/dist/ui/elements/PcPanelLayers/style.js +3 -0
- package/dist/ui/elements/PcShortcutSettings/index.d.ts +69 -0
- package/dist/ui/elements/PcShortcutSettings/index.js +273 -0
- package/dist/ui/elements/PcToolSettings/index.js +2 -1
- package/dist/ui/elements/PcToolbar/index.d.ts +47 -12
- package/dist/ui/elements/PcToolbar/index.js +77 -56
- package/dist/ui/elements/PcToolbar/style.js +1 -1
- package/dist/ui/index.d.ts +7 -1
- package/dist/ui/index.js +8 -2
- package/dist/ui/tokens/index.js +3 -1
- package/locales/en-GB.json +87 -1
- package/locales/en-US.json +87 -1
- package/locales/fr.json +87 -1
- package/locales/ja.json +87 -1
- package/locales/ko.json +87 -1
- package/locales/zh-Hans.json +87 -1
- package/locales/zh-Hant.json +87 -1
- package/package.json +1 -1
- package/dist/ui/elements/PcBrushMenu/style.js +0 -3
- package/dist/ui/elements/PcLayersMenu/style.js +0 -3
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { nothing, type PropertyValues } from "lit";
|
|
2
|
+
import { PcPanel } from "../PcPanel";
|
|
3
|
+
import "../PcColourPair";
|
|
4
|
+
import "../PcMenu";
|
|
5
|
+
import "../PcDialog";
|
|
6
|
+
import type { default as PaintCanvas } from "../../../lib/classes/PaintCanvas";
|
|
7
|
+
import { type Hsl, type Rgb } from "../../../lib/utils/colour";
|
|
8
|
+
import { type SaveMethod } from "../../../lib/rendering/screenshot";
|
|
9
|
+
/** The colour models the sliders can show */
|
|
10
|
+
export type ColourModel = "rgb" | "hsl";
|
|
11
|
+
/**
|
|
12
|
+
* The CSS gradient a channel's slider track shows: the colours its values give, from the lowest to the highest, keeping
|
|
13
|
+
* the colour's other values. Red, green and blue go from none to all of that channel (e.g. red from `rgb(0, g, b)` to
|
|
14
|
+
* `rgb(255, g, b)`), saturation from grey to full colour, and lightness from black through the colour to white. Hue goes
|
|
15
|
+
* through every hue at full saturation, so it never shows as grey.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* channelGradient("r", { r: 0, g: 128, b: 255 }, { h: 210, s: 100, l: 50 }); // "linear-gradient(to right, #0080ff, #ff80ff)"
|
|
19
|
+
* channelGradient("s", { r: 77, g: 179, b: 77 }, { h: 120, s: 40, l: 50 }); // "linear-gradient(to right, #808080, #00ff00)"
|
|
20
|
+
*/
|
|
21
|
+
export declare const channelGradient: (key: string, rgb: Rgb, hsl: Hsl) => string;
|
|
22
|
+
/** How long a touch is held on a saved colour to open its menu (milliseconds) */
|
|
23
|
+
export declare const LONG_PRESS_MS = 500;
|
|
24
|
+
/**
|
|
25
|
+
* The colour palette menu: the foreground and background colours (the selected one is configured), its hex value, RGB
|
|
26
|
+
* and HSL sliders, the saved colours, and buttons to import and export them as a JSON file.
|
|
27
|
+
*
|
|
28
|
+
* - Pressing the foreground or background colour selects it.
|
|
29
|
+
* - Pressing a saved colour sets the selected colour; [+] saves the selected colour.
|
|
30
|
+
* - A saved colour is deleted, after asking, by clicking it with Alt/Option held (the cursor shows an "X"), from its
|
|
31
|
+
* menu (right-click, a long press on touch screens, or the context menu key), or with Delete or Backspace. Arrow keys,
|
|
32
|
+
* Home and End move between saved colours.
|
|
33
|
+
* - Escape closes it (closes the canvas's open panel).
|
|
34
|
+
*
|
|
35
|
+
* Fires `pc-toast` after importing, or when importing or exporting fails.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* html`<pc-panel-colours .app=${app}></pc-panel-colours>`
|
|
39
|
+
*/
|
|
40
|
+
export declare class PcPanelColours extends PcPanel {
|
|
41
|
+
static properties: {
|
|
42
|
+
app: {
|
|
43
|
+
attribute: boolean;
|
|
44
|
+
};
|
|
45
|
+
model: {
|
|
46
|
+
type: StringConstructor;
|
|
47
|
+
};
|
|
48
|
+
hexDraft: {
|
|
49
|
+
state: boolean;
|
|
50
|
+
};
|
|
51
|
+
menu: {
|
|
52
|
+
state: boolean;
|
|
53
|
+
};
|
|
54
|
+
confirming: {
|
|
55
|
+
state: boolean;
|
|
56
|
+
};
|
|
57
|
+
icon: {
|
|
58
|
+
type: StringConstructor;
|
|
59
|
+
};
|
|
60
|
+
label: {
|
|
61
|
+
type: StringConstructor;
|
|
62
|
+
};
|
|
63
|
+
badge: {
|
|
64
|
+
type: BooleanConstructor;
|
|
65
|
+
reflect: boolean;
|
|
66
|
+
};
|
|
67
|
+
translations: {
|
|
68
|
+
attribute: boolean;
|
|
69
|
+
};
|
|
70
|
+
icons: {
|
|
71
|
+
attribute: boolean;
|
|
72
|
+
};
|
|
73
|
+
theme: {
|
|
74
|
+
type: StringConstructor;
|
|
75
|
+
reflect: boolean;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
static styles: import("lit").CSSResultGroup[];
|
|
79
|
+
app?: PaintCanvas;
|
|
80
|
+
/** The colour model the sliders show */
|
|
81
|
+
model: ColourModel;
|
|
82
|
+
/** The hex value being typed, while it differs from the colour */
|
|
83
|
+
hexDraft?: string;
|
|
84
|
+
/** The saved colour whose menu is open, and where */
|
|
85
|
+
menu?: {
|
|
86
|
+
index: number;
|
|
87
|
+
x: number;
|
|
88
|
+
y: number;
|
|
89
|
+
};
|
|
90
|
+
/** The saved colour being deleted, while asking */
|
|
91
|
+
confirming?: number;
|
|
92
|
+
/** Saves exported files (replaceable for tests) */
|
|
93
|
+
saveFile: (blob: Blob, name: string) => Promise<SaveMethod | undefined>;
|
|
94
|
+
/** The HSL values shown, kept while they give the selected colour (so hue stays put for greys) */
|
|
95
|
+
private hsl;
|
|
96
|
+
/** The saved colour that is reached with Tab (the others with arrow keys) */
|
|
97
|
+
private focusIndex;
|
|
98
|
+
/** A touch being held on a saved colour, until it opens its menu */
|
|
99
|
+
private press?;
|
|
100
|
+
/** Whether a long press opened a menu, so the click that follows is ignored */
|
|
101
|
+
private longPressed;
|
|
102
|
+
private changes;
|
|
103
|
+
private readonly onKey;
|
|
104
|
+
private readonly onBlur;
|
|
105
|
+
constructor();
|
|
106
|
+
connectedCallback(): void;
|
|
107
|
+
disconnectedCallback(): void;
|
|
108
|
+
/** The selected colour's value, e.g. `#000000` */
|
|
109
|
+
get colour(): string;
|
|
110
|
+
protected willUpdate(changed: PropertyValues<this>): void;
|
|
111
|
+
/** Set the selected colour */
|
|
112
|
+
private setColour;
|
|
113
|
+
/** Select the pressed colour */
|
|
114
|
+
private onColourClick;
|
|
115
|
+
/** Follow the hex value as it's typed, setting the colour once it's a full 6-digit value */
|
|
116
|
+
private onHexInput;
|
|
117
|
+
/** Set the colour from a typed hex value (including 3 digits) when done, or show the colour again if it isn't one */
|
|
118
|
+
private onHexChange;
|
|
119
|
+
/** Switch colour model with the arrow keys, Home and End, as tabs do */
|
|
120
|
+
private onTabKeyDown;
|
|
121
|
+
/** Show a colour model's sliders */
|
|
122
|
+
private selectModel;
|
|
123
|
+
/** Change one channel of the colour model shown */
|
|
124
|
+
private onChannel;
|
|
125
|
+
/** Set the selected colour from a saved colour, or ask to delete it with Alt/Option held */
|
|
126
|
+
private onSwatchClick;
|
|
127
|
+
/** Open a saved colour's menu where it was right-clicked */
|
|
128
|
+
private onSwatchContextMenu;
|
|
129
|
+
/** Start waiting for a touch held on a saved colour to open its menu */
|
|
130
|
+
private onSwatchPointerDown;
|
|
131
|
+
/** Stop waiting for a long press when the touch moves away */
|
|
132
|
+
private onSwatchPointerMove;
|
|
133
|
+
/** Stop waiting for a long press */
|
|
134
|
+
private cancelPress;
|
|
135
|
+
/**
|
|
136
|
+
* Move between saved colours, ask to delete one, or open its menu, with the keyboard. Keys used here don't reach the
|
|
137
|
+
* keyboard shortcuts (e.g. Delete doesn't also delete the masked image data).
|
|
138
|
+
*/
|
|
139
|
+
private onSwatchKeyDown;
|
|
140
|
+
/** How many saved colours fit in a row */
|
|
141
|
+
private columns;
|
|
142
|
+
/** Focus a saved colour */
|
|
143
|
+
private focusSwatch;
|
|
144
|
+
/** Save the selected colour */
|
|
145
|
+
private onAdd;
|
|
146
|
+
/** Delete the saved colour that was asked about, if confirmed */
|
|
147
|
+
private onConfirm;
|
|
148
|
+
/** Close the palette with Escape (unless a dialog or menu is open, which closes first) */
|
|
149
|
+
private onKeyDown;
|
|
150
|
+
/**
|
|
151
|
+
* Import the colours in a colour palette file, adding them after the saved ones (leaving out ones already saved).
|
|
152
|
+
*/
|
|
153
|
+
importFile(file: File): Promise<void>;
|
|
154
|
+
/**
|
|
155
|
+
* Export the saved colours as a colour palette file.
|
|
156
|
+
*/
|
|
157
|
+
exportFile(): Promise<void>;
|
|
158
|
+
/** Show a palette file error (one of `PALETTE_FILE_ERRORS`) in the chosen language */
|
|
159
|
+
private toastError;
|
|
160
|
+
/** The colour model tabs and the selected model's sliders */
|
|
161
|
+
private renderChannels;
|
|
162
|
+
/** The saved colours and the [+] button */
|
|
163
|
+
private renderSwatches;
|
|
164
|
+
/** The saved colour's menu, while open */
|
|
165
|
+
private renderMenu;
|
|
166
|
+
/** The dialog asking before deleting a saved colour, while asking */
|
|
167
|
+
private renderConfirmation;
|
|
168
|
+
protected get defaultIcon(): string;
|
|
169
|
+
protected get defaultLabel(): string;
|
|
170
|
+
protected renderBody(): import("lit").TemplateResult<1> | typeof nothing;
|
|
171
|
+
}
|