@lvl99dotcom/paintcanvas 0.0.0-stage → 0.3.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/LICENSE +201 -0
- package/README.md +131 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -0
- package/dist/lib/brushes/BrushTipCache/index.d.ts +32 -0
- package/dist/lib/brushes/BrushTipCache/index.js +60 -0
- package/dist/lib/brushes/StrokeEngine/index.d.ts +171 -0
- package/dist/lib/brushes/StrokeEngine/index.js +324 -0
- package/dist/lib/brushes/StrokePath/index.d.ts +53 -0
- package/dist/lib/brushes/StrokePath/index.js +161 -0
- package/dist/lib/brushes/StrokeSampler/index.d.ts +55 -0
- package/dist/lib/brushes/StrokeSampler/index.js +75 -0
- package/dist/lib/brushes/authors/index.d.ts +55 -0
- package/dist/lib/brushes/authors/index.js +60 -0
- package/dist/lib/brushes/configRanges/index.d.ts +52 -0
- package/dist/lib/brushes/configRanges/index.js +206 -0
- package/dist/lib/brushes/index.d.ts +5 -0
- package/dist/lib/brushes/index.js +19 -0
- package/dist/lib/brushes/params/index.d.ts +108 -0
- package/dist/lib/brushes/params/index.js +139 -0
- package/dist/lib/brushes/presetFile/index.d.ts +32 -0
- package/dist/lib/brushes/presetFile/index.js +55 -0
- package/dist/lib/brushes/presets/drawing/brush-pen.js +3 -0
- package/dist/lib/brushes/presets/drawing/felt-pen.js +3 -0
- package/dist/lib/brushes/presets/drawing/index.d.ts +13 -0
- package/dist/lib/brushes/presets/drawing/index.js +88 -0
- package/dist/lib/brushes/presets/drawing/pencil-2b.js +3 -0
- package/dist/lib/brushes/presets/drawing/pencil-hb.js +3 -0
- package/dist/lib/brushes/presets/painting/grass.js +3 -0
- package/dist/lib/brushes/presets/painting/hair.js +3 -0
- package/dist/lib/brushes/presets/painting/index.d.ts +18 -0
- package/dist/lib/brushes/presets/painting/index.js +118 -0
- package/dist/lib/brushes/presets/painting/splatter.js +3 -0
- package/dist/lib/brushes/presets/painting/textured-paint.js +3 -0
- package/dist/lib/brushes/presets/painting/watery-paint.js +3 -0
- package/dist/lib/brushes/presets/round/index.d.ts +9 -0
- package/dist/lib/brushes/presets/round/index.js +44 -0
- package/dist/lib/brushes/presets/round/round.js +3 -0
- package/dist/lib/brushes/presets/round/soft-round.js +3 -0
- package/dist/lib/brushes/presets/sized/index.d.ts +20 -0
- package/dist/lib/brushes/presets/sized/index.js +30 -0
- package/dist/lib/brushes/presets/sketching/index.d.ts +14 -0
- package/dist/lib/brushes/presets/sketching/index.js +107 -0
- package/dist/lib/brushes/presets/square/index.d.ts +7 -0
- package/dist/lib/brushes/presets/square/index.js +22 -0
- package/dist/lib/brushes/presets/square/square.js +3 -0
- package/dist/lib/brushes/shapeImage/index.d.ts +40 -0
- package/dist/lib/brushes/shapeImage/index.js +61 -0
- package/dist/lib/brushes/types/index.d.ts +243 -0
- package/dist/lib/brushes/types/index.js +20 -0
- package/dist/lib/classes/BackgroundWork/index.d.ts +55 -0
- package/dist/lib/classes/BackgroundWork/index.js +97 -0
- package/dist/lib/classes/BrushSettings/index.d.ts +91 -0
- package/dist/lib/classes/BrushSettings/index.js +152 -0
- package/dist/lib/classes/CustomPresets/index.d.ts +53 -0
- package/dist/lib/classes/CustomPresets/index.js +71 -0
- package/dist/lib/classes/ExternalSheets/index.d.ts +64 -0
- package/dist/lib/classes/ExternalSheets/index.js +112 -0
- package/dist/lib/classes/GestureTracker/index.d.ts +62 -0
- package/dist/lib/classes/GestureTracker/index.js +122 -0
- package/dist/lib/classes/History/index.d.ts +83 -0
- package/dist/lib/classes/History/index.js +126 -0
- package/dist/lib/classes/HistoryGuard/index.d.ts +58 -0
- package/dist/lib/classes/HistoryGuard/index.js +97 -0
- package/dist/lib/classes/InputSettings/index.d.ts +74 -0
- package/dist/lib/classes/InputSettings/index.js +101 -0
- package/dist/lib/classes/KeyboardShortcuts/index.d.ts +48 -0
- package/dist/lib/classes/KeyboardShortcuts/index.js +137 -0
- package/dist/lib/classes/Layer/index.d.ts +86 -0
- package/dist/lib/classes/Layer/index.js +111 -0
- package/dist/lib/classes/LayerAutosave/index.d.ts +180 -0
- package/dist/lib/classes/LayerAutosave/index.js +346 -0
- package/dist/lib/classes/LayerStack/index.d.ts +177 -0
- package/dist/lib/classes/LayerStack/index.js +394 -0
- package/dist/lib/classes/PaintCanvas/index.d.ts +537 -0
- package/dist/lib/classes/PaintCanvas/index.js +965 -0
- package/dist/lib/classes/StrokeLog/index.d.ts +149 -0
- package/dist/lib/classes/StrokeLog/index.js +257 -0
- package/dist/lib/classes/Viewport/index.d.ts +108 -0
- package/dist/lib/classes/Viewport/index.js +194 -0
- package/dist/lib/document/index.d.ts +17 -0
- package/dist/lib/document/index.js +25 -0
- package/dist/lib/document/schema.d.ts +132 -0
- package/dist/lib/document/schema.js +110 -0
- package/dist/lib/i18n/index.d.ts +131 -0
- package/dist/lib/i18n/index.js +277 -0
- package/dist/lib/image/index.d.ts +90 -0
- package/dist/lib/image/index.js +147 -0
- package/dist/lib/messages/PatchSender/index.d.ts +75 -0
- package/dist/lib/messages/PatchSender/index.js +125 -0
- package/dist/lib/messages/index.d.ts +26 -0
- package/dist/lib/messages/index.js +59 -0
- package/dist/lib/messages/schema.d.ts +1775 -0
- package/dist/lib/messages/schema.js +192 -0
- package/dist/lib/presets/index.d.ts +32 -0
- package/dist/lib/presets/index.js +35 -0
- package/dist/lib/presets/schema.d.ts +753 -0
- package/dist/lib/presets/schema.js +181 -0
- package/dist/lib/rendering/BrushTip/index.d.ts +63 -0
- package/dist/lib/rendering/BrushTip/index.js +112 -0
- package/dist/lib/rendering/checkerboard/index.d.ts +22 -0
- package/dist/lib/rendering/checkerboard/index.js +31 -0
- package/dist/lib/rendering/compositing/index.d.ts +64 -0
- package/dist/lib/rendering/compositing/index.js +124 -0
- package/dist/lib/rendering/cursor/index.d.ts +14 -0
- package/dist/lib/rendering/cursor/index.js +39 -0
- package/dist/lib/rendering/cursors/index.d.ts +18 -0
- package/dist/lib/rendering/cursors/index.js +23 -0
- package/dist/lib/rendering/maskOutline/index.d.ts +22 -0
- package/dist/lib/rendering/maskOutline/index.js +78 -0
- package/dist/lib/rendering/outline/index.d.ts +36 -0
- package/dist/lib/rendering/outline/index.js +120 -0
- package/dist/lib/rendering/sample/index.d.ts +55 -0
- package/dist/lib/rendering/sample/index.js +83 -0
- package/dist/lib/rendering/screenshot/index.d.ts +67 -0
- package/dist/lib/rendering/screenshot/index.js +96 -0
- package/dist/lib/rendering/transformBox/index.d.ts +10 -0
- package/dist/lib/rendering/transformBox/index.js +57 -0
- package/dist/lib/selection/Lasso/index.d.ts +70 -0
- package/dist/lib/selection/Lasso/index.js +156 -0
- package/dist/lib/selection/Selection/index.d.ts +86 -0
- package/dist/lib/selection/Selection/index.js +228 -0
- package/dist/lib/selection/geometry/index.d.ts +37 -0
- package/dist/lib/selection/geometry/index.js +57 -0
- package/dist/lib/storage/index.d.ts +63 -0
- package/dist/lib/storage/index.js +114 -0
- package/dist/lib/transform/Transformer/index.d.ts +124 -0
- package/dist/lib/transform/Transformer/index.js +286 -0
- package/dist/lib/transform/geometry/index.d.ts +95 -0
- package/dist/lib/transform/geometry/index.js +258 -0
- package/dist/lib/utils/array/index.d.ts +10 -0
- package/dist/lib/utils/array/index.js +21 -0
- package/dist/lib/utils/gestures/index.d.ts +35 -0
- package/dist/lib/utils/gestures/index.js +81 -0
- package/dist/lib/utils/navigation/index.d.ts +51 -0
- package/dist/lib/utils/navigation/index.js +59 -0
- package/dist/lib/utils/random/index.d.ts +18 -0
- package/dist/lib/utils/random/index.js +27 -0
- package/dist/lib/utils/shortcuts/index.d.ts +74 -0
- package/dist/lib/utils/shortcuts/index.js +189 -0
- package/dist/lib/validation/validators.generated.d.ts +27 -0
- package/dist/lib/validation/validators.generated.js +19826 -0
- package/dist/locales/en-GB.js +181 -0
- package/dist/locales/en-US.js +181 -0
- package/dist/locales/fr.js +181 -0
- package/dist/locales/ja.js +181 -0
- package/dist/locales/ko.js +181 -0
- package/dist/locales/zh-Hans.js +181 -0
- package/dist/locales/zh-Hant.js +181 -0
- package/dist/package.js +3 -0
- package/dist/testing/app.d.ts +7 -0
- package/dist/testing/app.js +16 -0
- package/dist/testing/elements.d.ts +42 -0
- package/dist/testing/elements.js +58 -0
- package/dist/testing/fakeCanvas.d.ts +21 -0
- package/dist/testing/fakeCanvas.js +26 -0
- package/dist/testing/layerStore.d.ts +26 -0
- package/dist/testing/layerStore.js +43 -0
- package/dist/testing/locks.d.ts +15 -0
- package/dist/testing/locks.js +41 -0
- package/dist/testing/recordingCanvas.d.ts +14 -0
- package/dist/testing/recordingCanvas.js +28 -0
- package/dist/testing/recordingContext.d.ts +10 -0
- package/dist/testing/recordingContext.js +19 -0
- package/dist/ui/ChangeController/index.d.ts +40 -0
- package/dist/ui/ChangeController/index.js +62 -0
- package/dist/ui/base/index.d.ts +69 -0
- package/dist/ui/base/index.js +94 -0
- package/dist/ui/elements/PaintCanvas/index.d.ts +249 -0
- package/dist/ui/elements/PaintCanvas/index.js +584 -0
- package/dist/ui/elements/PaintCanvas/style.js +3 -0
- package/dist/ui/elements/PcBrushConfig/index.d.ts +130 -0
- package/dist/ui/elements/PcBrushConfig/index.js +465 -0
- package/dist/ui/elements/PcBrushConfig/style.js +3 -0
- package/dist/ui/elements/PcBrushMenu/index.d.ts +121 -0
- package/dist/ui/elements/PcBrushMenu/index.js +362 -0
- package/dist/ui/elements/PcBrushMenu/style.js +3 -0
- package/dist/ui/elements/PcBrushTest/index.d.ts +71 -0
- package/dist/ui/elements/PcBrushTest/index.js +136 -0
- package/dist/ui/elements/PcBrushTest/style.js +3 -0
- package/dist/ui/elements/PcButton/index.d.ts +57 -0
- package/dist/ui/elements/PcButton/index.js +124 -0
- package/dist/ui/elements/PcButtonGroup/index.d.ts +44 -0
- package/dist/ui/elements/PcButtonGroup/index.js +93 -0
- package/dist/ui/elements/PcCanvas/index.d.ts +356 -0
- package/dist/ui/elements/PcCanvas/index.js +1004 -0
- package/dist/ui/elements/PcCanvas/style.js +3 -0
- package/dist/ui/elements/PcCanvasMap/index.d.ts +96 -0
- package/dist/ui/elements/PcCanvasMap/index.js +187 -0
- package/dist/ui/elements/PcCanvasMap/style.js +3 -0
- package/dist/ui/elements/PcContextMenu/index.d.ts +72 -0
- package/dist/ui/elements/PcContextMenu/index.js +148 -0
- package/dist/ui/elements/PcDialog/index.d.ts +63 -0
- package/dist/ui/elements/PcDialog/index.js +114 -0
- package/dist/ui/elements/PcIcon/index.d.ts +36 -0
- package/dist/ui/elements/PcIcon/index.js +43 -0
- package/dist/ui/elements/PcIconToggle/index.d.ts +46 -0
- package/dist/ui/elements/PcIconToggle/index.js +87 -0
- package/dist/ui/elements/PcInfoTip/index.d.ts +40 -0
- package/dist/ui/elements/PcInfoTip/index.js +95 -0
- package/dist/ui/elements/PcInputSettings/index.d.ts +69 -0
- package/dist/ui/elements/PcInputSettings/index.js +154 -0
- package/dist/ui/elements/PcLayerItem/index.d.ts +221 -0
- package/dist/ui/elements/PcLayerItem/index.js +561 -0
- package/dist/ui/elements/PcLayerItem/style.js +3 -0
- package/dist/ui/elements/PcLayersMenu/index.d.ts +108 -0
- package/dist/ui/elements/PcLayersMenu/index.js +208 -0
- package/dist/ui/elements/PcLayersMenu/style.js +3 -0
- package/dist/ui/elements/PcMatch/index.d.ts +31 -0
- package/dist/ui/elements/PcMatch/index.js +58 -0
- package/dist/ui/elements/PcPanel/index.d.ts +43 -0
- package/dist/ui/elements/PcPanel/index.js +51 -0
- package/dist/ui/elements/PcPopover/index.d.ts +48 -0
- package/dist/ui/elements/PcPopover/index.js +86 -0
- package/dist/ui/elements/PcSlider/index.d.ts +57 -0
- package/dist/ui/elements/PcSlider/index.js +88 -0
- package/dist/ui/elements/PcStats/index.d.ts +54 -0
- package/dist/ui/elements/PcStats/index.js +144 -0
- package/dist/ui/elements/PcThemePicker/index.d.ts +56 -0
- package/dist/ui/elements/PcThemePicker/index.js +134 -0
- package/dist/ui/elements/PcToast/index.d.ts +58 -0
- package/dist/ui/elements/PcToast/index.js +110 -0
- package/dist/ui/elements/PcToggleCheckbox/index.d.ts +37 -0
- package/dist/ui/elements/PcToggleCheckbox/index.js +105 -0
- package/dist/ui/elements/PcToolSettings/index.d.ts +128 -0
- package/dist/ui/elements/PcToolSettings/index.js +549 -0
- package/dist/ui/elements/PcToolSettings/style.js +3 -0
- package/dist/ui/elements/PcToolbar/index.d.ts +71 -0
- package/dist/ui/elements/PcToolbar/index.js +190 -0
- package/dist/ui/elements/PcToolbar/style.js +3 -0
- package/dist/ui/icons/images/brush.js +3 -0
- package/dist/ui/icons/images/circle-mask.js +3 -0
- package/dist/ui/icons/images/clipboard.js +3 -0
- package/dist/ui/icons/images/cursor.js +3 -0
- package/dist/ui/icons/images/eraser.js +3 -0
- package/dist/ui/icons/images/eyedropper.js +3 -0
- package/dist/ui/icons/images/flip-horizontal.js +3 -0
- package/dist/ui/icons/images/flip-vertical.js +3 -0
- package/dist/ui/icons/images/focus-pen.js +3 -0
- package/dist/ui/icons/images/freehand-mask.js +3 -0
- package/dist/ui/icons/images/hidden.js +3 -0
- package/dist/ui/icons/images/layers.js +3 -0
- package/dist/ui/icons/images/linked.js +3 -0
- package/dist/ui/icons/images/locked.js +3 -0
- package/dist/ui/icons/images/moon.js +3 -0
- package/dist/ui/icons/images/pan.js +3 -0
- package/dist/ui/icons/images/polygon-mask.js +3 -0
- package/dist/ui/icons/images/pressure.js +3 -0
- package/dist/ui/icons/images/randomise.js +3 -0
- package/dist/ui/icons/images/rectangle-mask.js +3 -0
- package/dist/ui/icons/images/redo.js +3 -0
- package/dist/ui/icons/images/rotate-90-left.js +3 -0
- package/dist/ui/icons/images/rotate-90-right.js +3 -0
- package/dist/ui/icons/images/smoothing-bezier-cubic.js +3 -0
- package/dist/ui/icons/images/smoothing-bezier-quad.js +3 -0
- package/dist/ui/icons/images/smoothing-linear.js +3 -0
- package/dist/ui/icons/images/star.js +3 -0
- package/dist/ui/icons/images/sun.js +3 -0
- package/dist/ui/icons/images/tilt.js +3 -0
- package/dist/ui/icons/images/undo.js +3 -0
- package/dist/ui/icons/images/unlinked.js +3 -0
- package/dist/ui/icons/images/unlocked.js +3 -0
- package/dist/ui/icons/images/visible.js +3 -0
- package/dist/ui/icons/images/zoom-in.js +3 -0
- package/dist/ui/icons/images/zoom-out.js +3 -0
- package/dist/ui/icons/images/zoom.js +3 -0
- package/dist/ui/icons/index.d.ts +42 -0
- package/dist/ui/icons/index.js +130 -0
- package/dist/ui/index.d.ts +21 -0
- package/dist/ui/index.js +22 -0
- package/dist/ui/layout/index.d.ts +88 -0
- package/dist/ui/layout/index.js +96 -0
- package/dist/ui/styles/index.d.ts +13 -0
- package/dist/ui/styles/index.js +195 -0
- package/dist/ui/tokens/index.d.ts +29 -0
- package/dist/ui/tokens/index.js +114 -0
- package/locales/en-GB.json +179 -0
- package/locales/en-US.json +179 -0
- package/locales/fr.json +179 -0
- package/locales/ja.json +179 -0
- package/locales/ko.json +179 -0
- package/locales/zh-Hans.json +179 -0
- package/locales/zh-Hant.json +179 -0
- package/package.json +97 -3
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { type PropertyValues } from "lit";
|
|
2
|
+
import { PcElement } from "../../base";
|
|
3
|
+
import { Tool, type default as PaintCanvas } from "../../../lib/classes/PaintCanvas";
|
|
4
|
+
import type { Insets, Point, Rect } from "../../../lib/classes/Viewport";
|
|
5
|
+
import type { LassoKind } from "../../../lib/selection/Lasso";
|
|
6
|
+
/** Toolbar width in CSS pixels (kept clear when fitting the canvas) */
|
|
7
|
+
export declare const TOOLBAR_WIDTH = 50;
|
|
8
|
+
/** Share of the screen width taken by the chat panel (kept clear when fitting the canvas) */
|
|
9
|
+
export declare const CHAT_WIDTH_RATIO = 0.375;
|
|
10
|
+
/** Lasso kind for each lasso tool */
|
|
11
|
+
export declare const LASSO_TOOLS: Partial<Record<Tool, LassoKind>>;
|
|
12
|
+
/** Distance (CSS pixels) within which a transform handle can be grabbed */
|
|
13
|
+
export declare const HANDLE_GRAB_DISTANCE = 8;
|
|
14
|
+
/** Milliseconds between steps of the crawling ants animation */
|
|
15
|
+
export declare const ANTS_INTERVAL = 100;
|
|
16
|
+
/** In focus pen mode, how long after a pen lifts touches are still ignored (milliseconds) */
|
|
17
|
+
export declare const PEN_LIFT_GRACE_MS = 500;
|
|
18
|
+
/**
|
|
19
|
+
* Space covered by the toolbar and chat on a screen of the given width.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* interfaceInsets(1000, true); // { top: 0, right: 375, bottom: 0, left: 50 }
|
|
23
|
+
*/
|
|
24
|
+
export declare const interfaceInsets: (width: number, interfaceVisible: boolean) => Insets;
|
|
25
|
+
/**
|
|
26
|
+
* CSS cursor for a tool. The brush and eraser hide the cursor because their outline is drawn on the canvas; rectangle and circle lassos
|
|
27
|
+
* use the "+" crosshair; zoom uses the magnifier with "+" or "-".
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* cursorFor(Tool.Zoom, { dragging: false, altKey: true }); // "zoom-out"
|
|
31
|
+
*/
|
|
32
|
+
/** How far above a finger the sampling window sits, so the finger doesn't cover it (screen pixels) */
|
|
33
|
+
export declare const TOUCH_SAMPLER_GAP = 40;
|
|
34
|
+
/** The sampling window's size: the colour on top of the enlarged pixels (screen pixels) */
|
|
35
|
+
export declare const SAMPLER_WIDTH: number;
|
|
36
|
+
export declare const SAMPLER_HEIGHT: number;
|
|
37
|
+
/**
|
|
38
|
+
* Where the colour sample tool's window goes (its top left, in screen pixels): with a mouse or pen, so the outlined
|
|
39
|
+
* pixel in its enlarged view is on the pointer (which is hidden); with touch, centred above the finger. Kept on screen.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* samplerPosition({ x: 100, y: 200 }, false, 1000, 800); // { x: 72.5, y: 122.5 }
|
|
43
|
+
*/
|
|
44
|
+
export declare const samplerPosition: (point: Point, touch: boolean, width: number, height: number) => Point;
|
|
45
|
+
export declare const cursorFor: (tool: Tool, { dragging, altKey }: {
|
|
46
|
+
dragging: boolean;
|
|
47
|
+
altKey: boolean;
|
|
48
|
+
}) => string;
|
|
49
|
+
/**
|
|
50
|
+
* The drawing area: a full-size canvas showing the composited layers through the viewport.
|
|
51
|
+
*
|
|
52
|
+
* Handles drawing with the brush and eraser (mouse, pen with pressure and tilt, or touch), and navigation: dragging with the pan tool (or while Space is held, or with the middle mouse button), clicking with the zoom tool (Alt to zoom out), scrolling or two-finger dragging to pan, and pinching or Cmd/Ctrl + scrolling to zoom (each as the user's settings allow).
|
|
53
|
+
* Taps and swipes with two or three fingers undo, redo, copy or paste, as the user's touch gesture settings say (see
|
|
54
|
+
* `GestureTracker`); two-finger pan and pinch wait until a finger moves further than a tap allows.
|
|
55
|
+
* In focus pen mode (a user setting), one finger does nothing (only pens draw), and touches are ignored altogether while
|
|
56
|
+
* a pen is down or for `PEN_LIFT_GRACE_MS` after it lifts, so a resting hand can't draw, pan or undo.
|
|
57
|
+
* The Move tool shows the transform box: drag inside it to move, a square handle to scale, or the round handle to rotate.
|
|
58
|
+
* The colour sample tool sets the current colour from what's shown under the pointer, or the average of a dragged area,
|
|
59
|
+
* showing a sampling window while sampling (see `drawSampler`).
|
|
60
|
+
* Lasso tools build mask shapes (see `Lasso`); the mask's outline is drawn as animated black and white "crawling ants".
|
|
61
|
+
* The mask outline and lasso shape are drawn on their own canvas; the brush cursor on an overlay that inverts what is underneath.
|
|
62
|
+
* Redraws at most once per animation frame, only when something changed. The first time it has a size, it fits the canvas beside the toolbar and chat.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* html`<pc-canvas .app=${app}></pc-canvas>`
|
|
66
|
+
*/
|
|
67
|
+
export declare class PcCanvas extends PcElement {
|
|
68
|
+
static properties: {
|
|
69
|
+
app: {
|
|
70
|
+
attribute: boolean;
|
|
71
|
+
};
|
|
72
|
+
insets: {
|
|
73
|
+
attribute: boolean;
|
|
74
|
+
};
|
|
75
|
+
translations: {
|
|
76
|
+
attribute: boolean;
|
|
77
|
+
};
|
|
78
|
+
icons: {
|
|
79
|
+
attribute: boolean;
|
|
80
|
+
};
|
|
81
|
+
theme: {
|
|
82
|
+
type: StringConstructor;
|
|
83
|
+
reflect: boolean;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
static styles: import("lit").CSSResultGroup[];
|
|
87
|
+
app?: PaintCanvas;
|
|
88
|
+
/**
|
|
89
|
+
* Space covered by the interface on each side (CSS pixels), kept clear when fitting or centring the canvas. Without
|
|
90
|
+
* it, a toolbar on the left and (with the interface shown) a panel taking 37.5% on the right are assumed.
|
|
91
|
+
*/
|
|
92
|
+
insets?: Insets;
|
|
93
|
+
/** The insets in effect (see `insets`) */
|
|
94
|
+
private get activeInsets();
|
|
95
|
+
/** Device pixels per CSS pixel (replaceable for tests) */
|
|
96
|
+
pixelRatio: () => number;
|
|
97
|
+
private changes;
|
|
98
|
+
/** Whether anything but the stroke in progress changed since the last update (so everything is redrawn) */
|
|
99
|
+
private fullChange;
|
|
100
|
+
/** The area the stroke in progress changed since the last update */
|
|
101
|
+
private strokeArea?;
|
|
102
|
+
/** Whether a finished stroke is being written into its layer (its layer change needs no redraw) */
|
|
103
|
+
private committing;
|
|
104
|
+
/** Whether the next frame redraws everything */
|
|
105
|
+
private drawAll;
|
|
106
|
+
/** The area the next frame redraws, if not everything */
|
|
107
|
+
private drawArea?;
|
|
108
|
+
/**
|
|
109
|
+
* Transform drag in progress: what is being changed, the box and pointer when it started, the pointer now, and (when
|
|
110
|
+
* scaling) whether "Constrain proportions" was on when it started
|
|
111
|
+
*/
|
|
112
|
+
private transformDrag;
|
|
113
|
+
/** Crawling ants animation timer while a mask is active */
|
|
114
|
+
private antsTimer?;
|
|
115
|
+
/** Current crawling ants dash offset */
|
|
116
|
+
private antsOffset;
|
|
117
|
+
/** Viewport that has been fitted once (so resizing doesn't refit) */
|
|
118
|
+
private fittedViewport?;
|
|
119
|
+
private frame;
|
|
120
|
+
/** Animation frame drawing only the brush cursor, if requested */
|
|
121
|
+
private overlayFrame;
|
|
122
|
+
private resizeObserver?;
|
|
123
|
+
private drag;
|
|
124
|
+
/** Pointer drawing the current stroke, and the layer it draws on */
|
|
125
|
+
private stroke;
|
|
126
|
+
/** Pointer position over the stage (for the brush cursor), or null when outside */
|
|
127
|
+
private hover;
|
|
128
|
+
/** Name of the key held to zoom with the scroll wheel (replaceable for tests) */
|
|
129
|
+
modifier: "Cmd" | "Ctrl";
|
|
130
|
+
/** Touches on the stage by pointer ID, for two-finger pan and pinch */
|
|
131
|
+
private readonly touches;
|
|
132
|
+
/** The two-finger gesture in progress: where its touches' midpoint and spread were last */
|
|
133
|
+
private pinch;
|
|
134
|
+
/**
|
|
135
|
+
* A colour sample in progress: the pointer, whether it's a finger, where it started and is now (canvas pixels), and
|
|
136
|
+
* where it is on screen
|
|
137
|
+
*/
|
|
138
|
+
private sampling;
|
|
139
|
+
/** Recognises taps and swipes with two or three fingers, for the actions in the user's touch gesture settings */
|
|
140
|
+
private readonly gestureTracker;
|
|
141
|
+
/** Pens touching the stage, by pointer ID */
|
|
142
|
+
private readonly pens;
|
|
143
|
+
/** When a pen last lifted (event time) */
|
|
144
|
+
private penLiftedAt;
|
|
145
|
+
/** Touches ignored altogether in focus pen mode (they touched while a pen was down or had just lifted) */
|
|
146
|
+
private readonly ignoredTouches;
|
|
147
|
+
/** Touches that can only pan, pinch and make gestures in focus pen mode (one finger does nothing) */
|
|
148
|
+
private readonly navigationTouches;
|
|
149
|
+
/** Zoom when a Safari trackpad pinch started */
|
|
150
|
+
private gestureZoom;
|
|
151
|
+
private altKey;
|
|
152
|
+
private readonly onModifierKey;
|
|
153
|
+
/** The screen canvas */
|
|
154
|
+
get canvas(): HTMLCanvasElement | null;
|
|
155
|
+
/** The canvas for the colour sample tool's window and area */
|
|
156
|
+
get sampler(): HTMLCanvasElement | null;
|
|
157
|
+
/** The overlay canvas for the brush cursor */
|
|
158
|
+
get overlay(): HTMLCanvasElement | null;
|
|
159
|
+
/** The canvas for the mask outline and lasso shape (no blend mode: drawn in black and white) */
|
|
160
|
+
get outlines(): HTMLCanvasElement | null;
|
|
161
|
+
connectedCallback(): void;
|
|
162
|
+
disconnectedCallback(): void;
|
|
163
|
+
firstUpdated(): void;
|
|
164
|
+
/**
|
|
165
|
+
* Note what changed: the stroke in progress (and the area it changed), or anything else.
|
|
166
|
+
*/
|
|
167
|
+
private sceneChanged;
|
|
168
|
+
updated(changed: PropertyValues): void;
|
|
169
|
+
/**
|
|
170
|
+
* Match the canvas's pixel size to its on-screen size and pixel ratio, and update the viewport. Fits the canvas the
|
|
171
|
+
* first time. Returns whether the canvas was resized (which clears it).
|
|
172
|
+
*/
|
|
173
|
+
syncSize(): boolean;
|
|
174
|
+
/**
|
|
175
|
+
* Schedule a redraw of everything, or of an area of the canvas, on the next animation frame (repeated requests are
|
|
176
|
+
* combined; redrawing everything wins).
|
|
177
|
+
*/
|
|
178
|
+
requestDraw(area?: Rect): void;
|
|
179
|
+
/**
|
|
180
|
+
* Draw the scene now (with the stroke in progress, if any), or only an area of the canvas, then the brush cursor.
|
|
181
|
+
*/
|
|
182
|
+
draw(area?: Rect): void;
|
|
183
|
+
/**
|
|
184
|
+
* Schedule drawing the brush cursor on the next animation frame (repeated requests are combined, and a scene redraw
|
|
185
|
+
* draws it too).
|
|
186
|
+
*/
|
|
187
|
+
requestOverlay(): void;
|
|
188
|
+
/**
|
|
189
|
+
* Draw the brush cursor on the overlay: a 1:1 outline of the brush or eraser shape at the pointer. For presets that
|
|
190
|
+
* snap to the pixel grid, the outline covers the pixels the stamp will.
|
|
191
|
+
*/
|
|
192
|
+
drawOverlay(): void;
|
|
193
|
+
/**
|
|
194
|
+
* Draw the mask outline (crawling ants) and the lasso shape in progress in black and white on their own canvas.
|
|
195
|
+
*/
|
|
196
|
+
private drawOutlines;
|
|
197
|
+
/**
|
|
198
|
+
* The square handles of the transform box (the 8 scale handles) while the Move tool is in use, or none.
|
|
199
|
+
*/
|
|
200
|
+
private transformHandles;
|
|
201
|
+
/**
|
|
202
|
+
* What the pointer is over in the transform box: the rotate handle, a scale handle, inside the box, or none of them.
|
|
203
|
+
*/
|
|
204
|
+
private transformPart;
|
|
205
|
+
/**
|
|
206
|
+
* Start rotating, scaling or moving the transform box, depending on where the pointer is: on the round handle, a
|
|
207
|
+
* square handle, or anywhere else (moving).
|
|
208
|
+
*/
|
|
209
|
+
private beginTransformDrag;
|
|
210
|
+
/**
|
|
211
|
+
* Update the transform box while dragging.
|
|
212
|
+
*/
|
|
213
|
+
private continueTransformDrag;
|
|
214
|
+
/**
|
|
215
|
+
* Change the transform box for the drag in progress, with the modifier keys held now. While scaling, "Constrain
|
|
216
|
+
* proportions" is turned on while Shift is held (if it was off when the drag started), or off while Alt is held (if
|
|
217
|
+
* it was on), and shows so in the settings bar.
|
|
218
|
+
*/
|
|
219
|
+
private applyTransformDrag;
|
|
220
|
+
/**
|
|
221
|
+
* End the transform drag of a pointer, if it has one: "Constrain proportions" goes back to how it was when a scale
|
|
222
|
+
* drag started.
|
|
223
|
+
*/
|
|
224
|
+
private endTransformDrag;
|
|
225
|
+
/**
|
|
226
|
+
* Cursor while hovering with the Move tool: the grab cursor over the rotate handle, a two-way arrow along a scale
|
|
227
|
+
* handle's direction (turned with the box), four-way arrows inside the box, and the default cursor elsewhere.
|
|
228
|
+
*/
|
|
229
|
+
private transformCursor;
|
|
230
|
+
/**
|
|
231
|
+
* Start or stop the crawling ants animation.
|
|
232
|
+
*/
|
|
233
|
+
private animateAnts;
|
|
234
|
+
/**
|
|
235
|
+
* Handle a lasso tool press: start a shape, add a polygon node, or close a polygon on its first node.
|
|
236
|
+
*/
|
|
237
|
+
private lassoDown;
|
|
238
|
+
/**
|
|
239
|
+
* Draw the last stroke's recorded points (circles) and stamp positions (dots) for tuning how brushes feel.
|
|
240
|
+
*/
|
|
241
|
+
private drawDebugTrace;
|
|
242
|
+
/**
|
|
243
|
+
* The brush or eraser settings for the tool in use, if it draws.
|
|
244
|
+
*/
|
|
245
|
+
private brushSettings;
|
|
246
|
+
/**
|
|
247
|
+
* Convert a pointer event to a stroke point in canvas pixels, with pen pressure and tilt.
|
|
248
|
+
*/
|
|
249
|
+
private strokePoint;
|
|
250
|
+
/**
|
|
251
|
+
* Start a brush or eraser stroke on the active layer (cancelling any other stroke in progress), logging how long it
|
|
252
|
+
* took. Hidden layers cannot be drawn on.
|
|
253
|
+
*/
|
|
254
|
+
private beginStroke;
|
|
255
|
+
/**
|
|
256
|
+
* Get a pointer's position relative to the stage.
|
|
257
|
+
*/
|
|
258
|
+
private pointerPoint;
|
|
259
|
+
/**
|
|
260
|
+
* Start panning, or zoom, depending on the tool and button. In focus pen mode, touches only pan, pinch and make
|
|
261
|
+
* gestures, and are ignored while a pen is down or just lifted (see `focusPenTouch`).
|
|
262
|
+
*/
|
|
263
|
+
private onPointerDown;
|
|
264
|
+
/**
|
|
265
|
+
* Continue a stroke (using every in-between event the browser recorded), pan while dragging, and move the brush cursor.
|
|
266
|
+
*/
|
|
267
|
+
private onPointerMove;
|
|
268
|
+
/**
|
|
269
|
+
* Finish a stroke (writing it into the layer) or stop panning.
|
|
270
|
+
*/
|
|
271
|
+
private onPointerUp;
|
|
272
|
+
/**
|
|
273
|
+
* Abandon a stroke or pan when the browser cancels the pointer (e.g. a system gesture).
|
|
274
|
+
*/
|
|
275
|
+
private onPointerCancel;
|
|
276
|
+
/**
|
|
277
|
+
* Keep the browser from handling touches on the canvas itself while the brush or eraser is in use (e.g. Safari on
|
|
278
|
+
* iPad holding back quick Apple Pencil strokes while it checks for its own gestures). Other tools keep the browser's
|
|
279
|
+
* handling, so a double tap still closes a polygon lasso. Pointer events are unaffected.
|
|
280
|
+
*/
|
|
281
|
+
private readonly onTouchStart;
|
|
282
|
+
/**
|
|
283
|
+
* Note a pen touching down. In focus pen mode, touches already on the stage are ignored from now on, abandoning any
|
|
284
|
+
* pan, pinch or gesture they were making (e.g. a palm resting on the screen).
|
|
285
|
+
*/
|
|
286
|
+
private penDown;
|
|
287
|
+
/** Note a pen lifting (or being cancelled), and when */
|
|
288
|
+
private penUp;
|
|
289
|
+
/**
|
|
290
|
+
* In focus pen mode, why a touch is ignored altogether: a pen is down, or lifted less than `PEN_LIFT_GRACE_MS` ago
|
|
291
|
+
* (a hand landing as the pen lifts). Undefined if the touch counts.
|
|
292
|
+
*/
|
|
293
|
+
private focusPenTouch;
|
|
294
|
+
/**
|
|
295
|
+
* Note a touch. A second touch stops any stroke or pan and starts a two-finger gesture; a third stops two-finger pan
|
|
296
|
+
* and pinch, for three-finger gestures. Returns whether the touch is part of a gesture (and so does nothing else).
|
|
297
|
+
*/
|
|
298
|
+
private touchDown;
|
|
299
|
+
/**
|
|
300
|
+
* Start sampling a colour with the colour sample tool: the pointer is hidden while the sampling window shows.
|
|
301
|
+
*/
|
|
302
|
+
private beginSample;
|
|
303
|
+
/**
|
|
304
|
+
* Set the current colour from the sample: the pixel under the pointer, or the average of every pixel in the area.
|
|
305
|
+
* Nothing changes if it's outside the canvas.
|
|
306
|
+
*/
|
|
307
|
+
private finishSample;
|
|
308
|
+
/** Stop sampling and close the sampling window */
|
|
309
|
+
private endSample;
|
|
310
|
+
/**
|
|
311
|
+
* Draw the colour sample tool's window while sampling (see `samplerPosition`): the sampled colour on top (the area's
|
|
312
|
+
* average while dragging an area, worked out from at most `PREVIEW_MAX_PIXELS` across), and the pixels around the
|
|
313
|
+
* pointer enlarged below, with the sampled pixel outlined. An area being sampled is outlined on the canvas.
|
|
314
|
+
*/
|
|
315
|
+
private drawSampler;
|
|
316
|
+
/**
|
|
317
|
+
* Do what the user's touch gesture settings say a gesture does: undo, redo, copy or paste.
|
|
318
|
+
*/
|
|
319
|
+
private runGesture;
|
|
320
|
+
/**
|
|
321
|
+
* Pan by how far the two touches' midpoint moved and zoom by how much their spread changed, around the midpoint.
|
|
322
|
+
*/
|
|
323
|
+
private movePinch;
|
|
324
|
+
/**
|
|
325
|
+
* Forget a lifted touch; the gesture ends once fewer than two touches are left.
|
|
326
|
+
*/
|
|
327
|
+
private touchUp;
|
|
328
|
+
/**
|
|
329
|
+
* Pan with the wheel or two-finger scroll, and zoom around the pointer with a pinch or Cmd/Ctrl + scroll (see
|
|
330
|
+
* `wheelAction`). The page itself never scrolls or zooms.
|
|
331
|
+
*/
|
|
332
|
+
private onWheel;
|
|
333
|
+
/**
|
|
334
|
+
* Start a Safari trackpad pinch (Safari reports these as gesture events, not Ctrl + wheel). Touch screens use the
|
|
335
|
+
* pointer events instead.
|
|
336
|
+
*/
|
|
337
|
+
private onGestureStart;
|
|
338
|
+
/**
|
|
339
|
+
* Zoom with a Safari trackpad pinch, around the pointer.
|
|
340
|
+
*/
|
|
341
|
+
private onGestureChange;
|
|
342
|
+
/**
|
|
343
|
+
* Hide the brush cursor (and the user's shared cursor) when the pointer leaves the stage.
|
|
344
|
+
*/
|
|
345
|
+
private onPointerLeave;
|
|
346
|
+
/**
|
|
347
|
+
* Tell the app where the pointer is on the canvas, in whole canvas pixels (undefined when off the canvas), so it can be
|
|
348
|
+
* shared with others in a session.
|
|
349
|
+
*/
|
|
350
|
+
private reportPointer;
|
|
351
|
+
/**
|
|
352
|
+
* Show the cursor for the tool in use.
|
|
353
|
+
*/
|
|
354
|
+
private updateCursor;
|
|
355
|
+
render(): import("lit").TemplateResult<1>;
|
|
356
|
+
}
|