@lvl99dotcom/paintcanvas 0.0.0-stage → 0.2.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 +94 -0
- package/dist/lib/i18n/index.js +182 -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 +188 -0
- package/dist/locales/en-US.js +188 -0
- package/dist/locales/fr.js +188 -0
- package/dist/locales/ja.js +188 -0
- package/dist/locales/ko.js +188 -0
- package/dist/locales/zh-Hans.js +188 -0
- package/dist/locales/zh-Hant.js +188 -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 +463 -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 +150 -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 +141 -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 +543 -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 +186 -0
- package/locales/en-US.json +186 -0
- package/locales/fr.json +186 -0
- package/locales/ja.json +186 -0
- package/locales/ko.json +186 -0
- package/locales/zh-Hans.json +186 -0
- package/locales/zh-Hant.json +186 -0
- package/package.json +97 -3
|
@@ -0,0 +1,537 @@
|
|
|
1
|
+
import StrokeLog from "../StrokeLog";
|
|
2
|
+
import BackgroundWork from "../BackgroundWork";
|
|
3
|
+
import type { DrawableLayer } from "../../rendering/compositing";
|
|
4
|
+
import BrushSettings from "../BrushSettings";
|
|
5
|
+
import LayerStack from "../LayerStack";
|
|
6
|
+
import type History from "../History";
|
|
7
|
+
import Viewport, { type Point, type Rect } from "../Viewport";
|
|
8
|
+
import StrokeEngine from "../../brushes/StrokeEngine";
|
|
9
|
+
import BrushTipCache from "../../brushes/BrushTipCache";
|
|
10
|
+
import Selection from "../../selection/Selection";
|
|
11
|
+
import Lasso, { type LassoResult } from "../../selection/Lasso";
|
|
12
|
+
import Transformer from "../../transform/Transformer";
|
|
13
|
+
import { type CanvasFactory, type LayerConfig } from "../Layer";
|
|
14
|
+
import LayerAutosave, { type AutosaveOptions } from "../LayerAutosave";
|
|
15
|
+
import type { LayerStoreLike } from "../../storage";
|
|
16
|
+
import type { AssetAuthor, BrushConfig } from "../../brushes/types";
|
|
17
|
+
import CustomPresets, { type PresetStoreLike } from "../CustomPresets";
|
|
18
|
+
import InputSettings from "../InputSettings";
|
|
19
|
+
import ExternalSheets from "../ExternalSheets";
|
|
20
|
+
import { type CanvasMessage, type PatchMessage, type StrokeMessage } from "../../messages";
|
|
21
|
+
import { type BoundingBox } from "../../image";
|
|
22
|
+
import { type PaintCanvasDocument } from "../../document";
|
|
23
|
+
/** Drawing and navigation tools */
|
|
24
|
+
export declare enum Tool {
|
|
25
|
+
Brush = "brush",
|
|
26
|
+
Eraser = "eraser",
|
|
27
|
+
/** Move, scale and rotate */
|
|
28
|
+
Move = "move",
|
|
29
|
+
RectangleLasso = "rectangle-lasso",
|
|
30
|
+
CircleLasso = "circle-lasso",
|
|
31
|
+
PolygonLasso = "polygon-lasso",
|
|
32
|
+
FreeformLasso = "freeform-lasso",
|
|
33
|
+
Pan = "pan",
|
|
34
|
+
Zoom = "zoom",
|
|
35
|
+
/** Set the current colour from the canvas (eyedropper) */
|
|
36
|
+
ColourSample = "colour-sample"
|
|
37
|
+
}
|
|
38
|
+
/** How the colour sample tool samples: the pixel under the pointer, or the average of a dragged rectangle */
|
|
39
|
+
export type SampleMode = "point" | "area";
|
|
40
|
+
/** Toggleable panels */
|
|
41
|
+
export declare enum Panel {
|
|
42
|
+
Brush = "brush",
|
|
43
|
+
Eraser = "eraser",
|
|
44
|
+
Layers = "layers",
|
|
45
|
+
/** The implementer's own app menu */
|
|
46
|
+
Menu = "menu"
|
|
47
|
+
}
|
|
48
|
+
/** Panels opened by tools */
|
|
49
|
+
export declare const TOOL_PANELS: Partial<Record<Tool, Panel>>;
|
|
50
|
+
/** Canvas width and height when none is given */
|
|
51
|
+
export declare const DEFAULT_CANVAS_SIZE = 2000;
|
|
52
|
+
/** Largest canvas width or height allowed when the `maxCanvasSize` option isn't given */
|
|
53
|
+
export declare const MAX_CANVAS_SIZE = 2000;
|
|
54
|
+
/** Drawing colour to start with */
|
|
55
|
+
export declare const DEFAULT_COLOUR = "#000000";
|
|
56
|
+
/** Owner of the custom presets when the `ownerId` option isn't given */
|
|
57
|
+
export declare const DEFAULT_OWNER_ID = "local";
|
|
58
|
+
/** Author name of presets made with `newPreset` when the `presetAuthor` option isn't given */
|
|
59
|
+
export declare const DEFAULT_AUTHOR = "Unknown";
|
|
60
|
+
/** Names the implementer can change: what users see and what files are called */
|
|
61
|
+
export interface PaintCanvasNames {
|
|
62
|
+
/** The app's name, e.g. the heading of the brush presets that come with it */
|
|
63
|
+
app: string;
|
|
64
|
+
/** Start of the names of saved files, e.g. screenshots and exported presets */
|
|
65
|
+
filePrefix: string;
|
|
66
|
+
/** The `format` written in exported brush preset files */
|
|
67
|
+
presetFileFormat: string;
|
|
68
|
+
/** Author name of presets made by a user without a handle, e.g. from `presetAuthor` */
|
|
69
|
+
unknownAuthor: string;
|
|
70
|
+
}
|
|
71
|
+
/** PaintCanvas's own names */
|
|
72
|
+
export declare const DEFAULT_NAMES: Readonly<PaintCanvasNames>;
|
|
73
|
+
/** How much the canvas holds, e.g. to show in a stats panel */
|
|
74
|
+
export interface CanvasStats {
|
|
75
|
+
/** Canvas width in pixels */
|
|
76
|
+
width: number;
|
|
77
|
+
/** Canvas height in pixels */
|
|
78
|
+
height: number;
|
|
79
|
+
/** Number of the user's layers */
|
|
80
|
+
layers: number;
|
|
81
|
+
/** Number of drawings from elsewhere */
|
|
82
|
+
externalSheets: number;
|
|
83
|
+
/** Memory the layers and drawings from elsewhere take as pixels (bytes, estimated: 4 per pixel) */
|
|
84
|
+
memoryBytes: number;
|
|
85
|
+
/** Undo steps recorded */
|
|
86
|
+
historySteps: number;
|
|
87
|
+
/** Most undo steps kept */
|
|
88
|
+
historyLimit: number;
|
|
89
|
+
}
|
|
90
|
+
/** Receives the drawing messages PaintCanvas sends; a returned promise that rejects means a patch wasn't delivered */
|
|
91
|
+
export type MessageListener = (message: CanvasMessage) => void | Promise<void>;
|
|
92
|
+
/** Options for sending drawing messages (see `startSending`) */
|
|
93
|
+
export interface SendingOptions {
|
|
94
|
+
/** Send patches of the user's drawing (default true) */
|
|
95
|
+
patches?: boolean;
|
|
96
|
+
/** Send each finished stroke (default false) */
|
|
97
|
+
strokes?: boolean;
|
|
98
|
+
/** How long to wait after a change before sending a patch, so quick changes go together (milliseconds) */
|
|
99
|
+
delayMs?: number;
|
|
100
|
+
}
|
|
101
|
+
/** A stroke to draw: what a stroke message holds, without the protocol details */
|
|
102
|
+
export type StrokeData = Omit<StrokeMessage, "protocol" | "type" | "step" | "layer">;
|
|
103
|
+
export interface PaintCanvasOptions {
|
|
104
|
+
/** Canvas width in pixels */
|
|
105
|
+
width?: number;
|
|
106
|
+
/** Canvas height in pixels */
|
|
107
|
+
height?: number;
|
|
108
|
+
/** Largest canvas width or height allowed (default `MAX_CANVAS_SIZE`) */
|
|
109
|
+
maxCanvasSize?: number;
|
|
110
|
+
/** Most layers the user can have (default `DEFAULT_MAX_LAYERS`) */
|
|
111
|
+
maxLayers?: number;
|
|
112
|
+
/** Creates layer canvases (replaceable for tests) */
|
|
113
|
+
createCanvas?: CanvasFactory;
|
|
114
|
+
/** Where custom brush presets are kept (defaults to keeping them in memory only) */
|
|
115
|
+
presetStore?: PresetStoreLike;
|
|
116
|
+
/** Who the custom presets belong to, passed to the preset store (default `DEFAULT_OWNER_ID`) */
|
|
117
|
+
ownerId?: string;
|
|
118
|
+
/** Gives the author of presets made with `newPreset` (asked each time, so it can follow name changes) */
|
|
119
|
+
presetAuthor?: () => AssetAuthor;
|
|
120
|
+
/** Names to use instead of PaintCanvas's own (see `DEFAULT_NAMES`) */
|
|
121
|
+
names?: Partial<PaintCanvasNames>;
|
|
122
|
+
/** Where to keep the user's layers so the drawing survives reloading the page (see `useLayerStore`) */
|
|
123
|
+
layerStore?: LayerStoreLike;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The painting engine: canvas size, layers, brush and eraser settings, custom presets, the selected tool, colour,
|
|
127
|
+
* selection, transforms, clipboard, undo/redo history, viewport and input settings. Where its data is kept and who it
|
|
128
|
+
* is shared with are up to the implementer (see `onMessage` and `receive`).
|
|
129
|
+
*
|
|
130
|
+
* Dispatches a `change` event whenever its own state changes. Layers, brushes and selection dispatch their own `change`
|
|
131
|
+
* events. Also dispatches `pointer` when the pointer moves over the canvas.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* const canvas = new PaintCanvas({ width: 1000, height: 800 });
|
|
135
|
+
* canvas.selectTool(Tool.Brush, { fromToolbar: true });
|
|
136
|
+
* canvas.setColour("#ff0000");
|
|
137
|
+
*/
|
|
138
|
+
export default class PaintCanvas extends EventTarget {
|
|
139
|
+
/** Brush settings */
|
|
140
|
+
readonly brush: BrushSettings;
|
|
141
|
+
/** Eraser settings */
|
|
142
|
+
readonly eraser: BrushSettings;
|
|
143
|
+
/** The user's own and imported brush presets, listed with the brush and eraser presets */
|
|
144
|
+
readonly customPresets: CustomPresets;
|
|
145
|
+
/** Lasso shape in progress */
|
|
146
|
+
readonly lasso: Lasso;
|
|
147
|
+
/** Brush shapes, loaded per preset */
|
|
148
|
+
readonly tips: BrushTipCache;
|
|
149
|
+
/** Log of strokes started, ended, cancelled and ignored, with timings, for debugging */
|
|
150
|
+
readonly strokeLog: StrokeLog;
|
|
151
|
+
/** Whether the debug log shows (see `showDebugLog`) */
|
|
152
|
+
protected debugLogShown: boolean;
|
|
153
|
+
/** Slow work that waits for pauses in drawing (syncing, the canvas map and layer thumbnails, saving) */
|
|
154
|
+
readonly background: BackgroundWork;
|
|
155
|
+
/** How the user's input devices control the canvas (scrolling, pinching, touch gestures, focus pen mode) */
|
|
156
|
+
readonly input: InputSettings;
|
|
157
|
+
/** The user's pointer position over the canvas, in canvas pixels (undefined when off the canvas) */
|
|
158
|
+
pointer?: Point;
|
|
159
|
+
/** Selected tool */
|
|
160
|
+
tool: Tool;
|
|
161
|
+
/** Tool used temporarily while a key is held (e.g. Space for pan), overriding the selected tool */
|
|
162
|
+
heldTool: Tool | null;
|
|
163
|
+
/** Open panel, if any */
|
|
164
|
+
panel: Panel | null;
|
|
165
|
+
/** Whether the interface (toolbar, panels and anything the implementer adds) is visible ("tab" key) */
|
|
166
|
+
interfaceVisible: boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Whether scaling the Move tool's box keeps its proportions ("Constrain proportions"), from its settings bar and when
|
|
169
|
+
* dragging a handle. Off by default; while drag-scaling, holding Shift turns it on (when off) and Alt turns it off
|
|
170
|
+
* (when on), until released.
|
|
171
|
+
*/
|
|
172
|
+
constrainProportions: boolean;
|
|
173
|
+
/** How the colour sample tool samples ("point" by default) */
|
|
174
|
+
sampleMode: SampleMode;
|
|
175
|
+
private canvasWidth;
|
|
176
|
+
private canvasHeight;
|
|
177
|
+
private layerStack;
|
|
178
|
+
private view;
|
|
179
|
+
private strokeEngine;
|
|
180
|
+
private currentSelection;
|
|
181
|
+
private transformer;
|
|
182
|
+
private readonly onLayersOrMaskChange;
|
|
183
|
+
private readonly onStrokeBegin;
|
|
184
|
+
private readonly onStrokeEnd;
|
|
185
|
+
private readonly onStrokeCommit;
|
|
186
|
+
private readonly onHistoryStep;
|
|
187
|
+
/** Whether drawing messages are sent (see `startSending`) */
|
|
188
|
+
private isSending;
|
|
189
|
+
/** Whether finished strokes are sent (see `startSending`) */
|
|
190
|
+
private sendingStrokes;
|
|
191
|
+
/** Whether a stroke from elsewhere is being drawn (it isn't sent again) */
|
|
192
|
+
private replaying;
|
|
193
|
+
private currentColour;
|
|
194
|
+
/** Image data copied with cut or copy, and the area it was copied from */
|
|
195
|
+
private clipboard?;
|
|
196
|
+
/** Drawings from elsewhere */
|
|
197
|
+
private externalSheets;
|
|
198
|
+
/** Who receives the drawing messages this canvas sends */
|
|
199
|
+
private readonly messageListeners;
|
|
200
|
+
/** Sends patches while sending (see `startSending`) */
|
|
201
|
+
private sender?;
|
|
202
|
+
/** The layer stack whose changes are being sent */
|
|
203
|
+
private sendingLayers?;
|
|
204
|
+
private readonly onLayersChangeToSend;
|
|
205
|
+
/** Creates the canvases the app draws on (fake ones in tests) */
|
|
206
|
+
readonly createCanvas: CanvasFactory;
|
|
207
|
+
/** Who the custom presets belong to (passed to the preset store) */
|
|
208
|
+
readonly ownerId: string;
|
|
209
|
+
/** The largest canvas width or height allowed */
|
|
210
|
+
readonly maxCanvasSize: number;
|
|
211
|
+
/** Most layers the user can have */
|
|
212
|
+
readonly maxLayers: number;
|
|
213
|
+
/** Names users see and saved files are called by (see `PaintCanvasNames`) */
|
|
214
|
+
readonly names: Readonly<PaintCanvasNames>;
|
|
215
|
+
/** Gives the author of presets made with `newPreset` */
|
|
216
|
+
private readonly presetAuthor;
|
|
217
|
+
/** Keeps the user's layers in a store, while one is used */
|
|
218
|
+
private layerAutosave?;
|
|
219
|
+
constructor(options?: PaintCanvasOptions);
|
|
220
|
+
/** Canvas width in pixels */
|
|
221
|
+
get width(): number;
|
|
222
|
+
/** Canvas height in pixels */
|
|
223
|
+
get height(): number;
|
|
224
|
+
/** Drawings from elsewhere (e.g. other people's), drawn under the user's own layers (see `receive`) */
|
|
225
|
+
get external(): ExternalSheets;
|
|
226
|
+
/** Everything drawn on the canvas, top first: the user's own layers, then drawings from elsewhere */
|
|
227
|
+
get drawables(): readonly DrawableLayer[];
|
|
228
|
+
/**
|
|
229
|
+
* Listen for the drawing messages this canvas sends, e.g. to pass them to other people. Returns a function that stops
|
|
230
|
+
* listening.
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* const stop = canvas.onMessage((message) => transport.send(message));
|
|
234
|
+
* canvas.startSending();
|
|
235
|
+
*/
|
|
236
|
+
onMessage(listener: MessageListener): () => void;
|
|
237
|
+
/**
|
|
238
|
+
* Give a message to every listener. Rejects if any listener's delivery fails.
|
|
239
|
+
*/
|
|
240
|
+
private emit;
|
|
241
|
+
/**
|
|
242
|
+
* Start sending drawing messages to `onMessage` listeners:
|
|
243
|
+
* - patches (by default): shortly after the user's layers change (and once drawing pauses), the area of their drawing
|
|
244
|
+
* that changed
|
|
245
|
+
* - strokes (when asked): each finished brush or eraser stroke
|
|
246
|
+
* - undo and redo: the step undone or redone
|
|
247
|
+
*
|
|
248
|
+
* Changing the canvas size stops sending.
|
|
249
|
+
*/
|
|
250
|
+
startSending(options?: SendingOptions): void;
|
|
251
|
+
/**
|
|
252
|
+
* Stop sending patches. Changes waiting to be sent are dropped.
|
|
253
|
+
*/
|
|
254
|
+
stopSending(): void;
|
|
255
|
+
/** Whether drawing messages are being sent (see `startSending`) */
|
|
256
|
+
get sending(): boolean;
|
|
257
|
+
/**
|
|
258
|
+
* Send a patch of what changed now instead of waiting. Resolves once sent (or straight away when not sending
|
|
259
|
+
* patches).
|
|
260
|
+
*/
|
|
261
|
+
sendNow(): Promise<void>;
|
|
262
|
+
/**
|
|
263
|
+
* Count pixels of the user's drawing as already sent, so they aren't sent again (e.g. their earlier work, restored
|
|
264
|
+
* from a shared drawing's history).
|
|
265
|
+
*/
|
|
266
|
+
markSent(area: BoundingBox, rgba: Uint8ClampedArray): void;
|
|
267
|
+
/**
|
|
268
|
+
* A patch of the user's whole drawing (all their layers, flattened), e.g. for someone who joins late. Undefined if
|
|
269
|
+
* nothing is drawn.
|
|
270
|
+
*/
|
|
271
|
+
snapshot(): Promise<PatchMessage | undefined>;
|
|
272
|
+
/**
|
|
273
|
+
* Apply a drawing message received from a source (an ID the implementer chooses, e.g. a user ID): a patch is drawn
|
|
274
|
+
* onto that source's sheet. Messages are checked first; invalid ones are ignored. Resolves to whether it was applied.
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* transport.onMessage((from, message) => canvas.receive(from, message));
|
|
278
|
+
*/
|
|
279
|
+
receive(source: string, message: unknown): Promise<boolean>;
|
|
280
|
+
/**
|
|
281
|
+
* The drawing as a document: its size, the user's layers and drawings from elsewhere, with PNG images (see
|
|
282
|
+
* `PaintCanvasDocument`). Turn it into JSON to save it as a file.
|
|
283
|
+
*
|
|
284
|
+
* @example
|
|
285
|
+
* const json = JSON.stringify(await canvas.exportDocument());
|
|
286
|
+
*/
|
|
287
|
+
exportDocument(): Promise<PaintCanvasDocument>;
|
|
288
|
+
/**
|
|
289
|
+
* Replace the drawing with a document (e.g. read from a file): its size, layers and drawings from elsewhere. Undo
|
|
290
|
+
* history starts again. Returns whether it was loaded: not when the document is invalid or an image can't be
|
|
291
|
+
* decoded, and then nothing changes.
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* await canvas.importDocument(JSON.parse(text));
|
|
295
|
+
*/
|
|
296
|
+
importDocument(document: unknown): Promise<boolean>;
|
|
297
|
+
/**
|
|
298
|
+
* Replace the canvas size and the user's layers (top first, each with its image) and select one by ID. Undo history
|
|
299
|
+
* starts again. Throws if the size or number of layers isn't allowed.
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* canvas.restoreLayers(800, 600, [{ id: "a", name: "Sketch" }], [sketchImage], "a");
|
|
303
|
+
*/
|
|
304
|
+
restoreLayers(width: number, height: number, layers: readonly LayerConfig[], images: readonly CanvasImageSource[], activeLayer: string): void;
|
|
305
|
+
/** Keeps the user's layers in a store, while one is used (see `useLayerStore`) */
|
|
306
|
+
get autosave(): LayerAutosave | undefined;
|
|
307
|
+
/**
|
|
308
|
+
* Keep the user's layers in a store (or stop, without one), so the drawing survives reloading the page: the saved
|
|
309
|
+
* drawing is restored, then changes are saved. Only one window draws on a drawing at a time (see `LayerAutosave`).
|
|
310
|
+
* Returns the autosave.
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* canvas.useLayerStore(new IndexedDbLayerStore("my-drawing"));
|
|
314
|
+
*/
|
|
315
|
+
useLayerStore(store: LayerStoreLike | undefined, options?: AutosaveOptions): LayerAutosave | undefined;
|
|
316
|
+
/**
|
|
317
|
+
* How much the canvas holds: its size, layers, drawings from elsewhere, memory and undo steps.
|
|
318
|
+
*/
|
|
319
|
+
stats(): CanvasStats;
|
|
320
|
+
/**
|
|
321
|
+
* Draw a recorded stroke (e.g. received from elsewhere) onto one of the user's layers, as an action they can undo.
|
|
322
|
+
* It isn't sent as a stroke message. Does nothing during a stroke, or if there's no such layer. Returns whether it was
|
|
323
|
+
* drawn.
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* canvas.drawStroke(canvas.layers.active.id, strokeMessage);
|
|
327
|
+
*/
|
|
328
|
+
drawStroke(layerId: string, stroke: StrokeData): boolean;
|
|
329
|
+
/**
|
|
330
|
+
* Draw a recorded stroke with a stroke engine, point by point.
|
|
331
|
+
*/
|
|
332
|
+
private replay;
|
|
333
|
+
/**
|
|
334
|
+
* Put a patch's pixels onto one of the user's layers (replacing what was there), as an action they can undo. Returns
|
|
335
|
+
* whether it was applied: not for an invalid patch, or if there's no such layer.
|
|
336
|
+
*
|
|
337
|
+
* @example
|
|
338
|
+
* await canvas.applyPatch(canvas.layers.active.id, patch);
|
|
339
|
+
*/
|
|
340
|
+
applyPatch(layerId: string, patch: unknown): Promise<boolean>;
|
|
341
|
+
/**
|
|
342
|
+
* The colour shown at a canvas point (every layer mixed as shown, over the white background), or undefined outside the
|
|
343
|
+
* canvas.
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* app.sampleColour({ x: 10.4, y: 20.9 }); // "#ff0000"
|
|
347
|
+
*/
|
|
348
|
+
sampleColour(point: Point): string | undefined;
|
|
349
|
+
/**
|
|
350
|
+
* The average colour shown in the rectangle between two canvas points (cut to the canvas), counting every pixel, or
|
|
351
|
+
* undefined outside the canvas. With `maxPixels`, it's worked out from the area scaled down to at most that many
|
|
352
|
+
* pixels across, which is quicker (for a preview while dragging).
|
|
353
|
+
*
|
|
354
|
+
* @example
|
|
355
|
+
* app.sampleAreaColour({ x: 0, y: 0 }, { x: 99, y: 99 }); // the average of 100 × 100 pixels
|
|
356
|
+
*/
|
|
357
|
+
sampleAreaColour(a: Point, b: Point, maxPixels?: number): string | undefined;
|
|
358
|
+
/**
|
|
359
|
+
* The `SAMPLE_PIXELS` × `SAMPLE_PIXELS` canvas pixels around a point as shown (the point's pixel is at the middle,
|
|
360
|
+
* rounding down), for the colour sample tool's enlarged view. Pixels outside the canvas are transparent.
|
|
361
|
+
*/
|
|
362
|
+
samplePixels(point: Point): OffscreenCanvas;
|
|
363
|
+
/** Draw an area of the canvas as shown onto a new canvas (see `flattenArea`) */
|
|
364
|
+
private flatten;
|
|
365
|
+
/** The user's view of the canvas (zoom and position) */
|
|
366
|
+
get viewport(): Viewport;
|
|
367
|
+
/** Whether the debug log shows */
|
|
368
|
+
get debugLog(): boolean;
|
|
369
|
+
/**
|
|
370
|
+
* Show or hide the debug log. Strokes and timings are only recorded while it shows.
|
|
371
|
+
*/
|
|
372
|
+
showDebugLog(shown: boolean): void;
|
|
373
|
+
/** Draws brush and eraser strokes */
|
|
374
|
+
get strokes(): StrokeEngine;
|
|
375
|
+
/** The mask limiting where drawing applies */
|
|
376
|
+
get selection(): Selection;
|
|
377
|
+
/** Moves, scales and rotates the active layer's pixels with the Move tool */
|
|
378
|
+
get transform(): Transformer;
|
|
379
|
+
/** The user's undoable actions */
|
|
380
|
+
get history(): History;
|
|
381
|
+
/**
|
|
382
|
+
* Listen for layer and mask changes on the current layer stack and selection, and for strokes starting and ending
|
|
383
|
+
* (background work waits for pauses in drawing).
|
|
384
|
+
*/
|
|
385
|
+
private watchLayersAndMask;
|
|
386
|
+
/**
|
|
387
|
+
* Show the transform box when the Move tool is selected, and apply any transform when switching away or to another layer.
|
|
388
|
+
*/
|
|
389
|
+
private syncTransform;
|
|
390
|
+
/**
|
|
391
|
+
* Write the transformed pixels into the layer (Enter, or switching tool). The mask moves with them.
|
|
392
|
+
*/
|
|
393
|
+
commitTransform(): void;
|
|
394
|
+
/**
|
|
395
|
+
* Undo the user's latest action. A move or rotate that hasn't been applied is cancelled instead, and nothing happens
|
|
396
|
+
* during a stroke.
|
|
397
|
+
*/
|
|
398
|
+
undo(): void;
|
|
399
|
+
/**
|
|
400
|
+
* Redo the user's latest undone action. A move or rotate that hasn't been applied is cancelled instead, and nothing
|
|
401
|
+
* happens during a stroke.
|
|
402
|
+
*/
|
|
403
|
+
redo(): void;
|
|
404
|
+
/**
|
|
405
|
+
* Whether undo or redo can move along the history now: not during a stroke, and not while a transform is pending (which
|
|
406
|
+
* is cancelled instead).
|
|
407
|
+
*/
|
|
408
|
+
private canStepHistory;
|
|
409
|
+
/**
|
|
410
|
+
* Put transformed pixels back where they were (Escape).
|
|
411
|
+
*/
|
|
412
|
+
cancelTransform(): void;
|
|
413
|
+
/**
|
|
414
|
+
* Copy the masked image data of the selected layer to the clipboard. Needs a mask with image data inside it; does
|
|
415
|
+
* nothing during a stroke or while a transform is pending. Returns the area copied, if any.
|
|
416
|
+
*/
|
|
417
|
+
copy(): Rect | undefined;
|
|
418
|
+
/**
|
|
419
|
+
* Copy the masked image data of the selected layer to the clipboard, then erase it from the layer as one undoable
|
|
420
|
+
* action.
|
|
421
|
+
*/
|
|
422
|
+
cut(): void;
|
|
423
|
+
/**
|
|
424
|
+
* Erase the masked image data from the selected layer as one undoable action (Delete or Backspace). Needs a mask with
|
|
425
|
+
* image data inside it; does nothing during a stroke or while a transform is pending.
|
|
426
|
+
*/
|
|
427
|
+
deleteMasked(): void;
|
|
428
|
+
/**
|
|
429
|
+
* The bounds of the selected layer's image data inside the mask, if there is a mask with image data inside it. None
|
|
430
|
+
* during a stroke or while a transform is pending.
|
|
431
|
+
*/
|
|
432
|
+
private maskedArea;
|
|
433
|
+
/**
|
|
434
|
+
* Erase the mask's part of an area from the selected layer, as one undoable action.
|
|
435
|
+
*/
|
|
436
|
+
private eraseMasked;
|
|
437
|
+
/**
|
|
438
|
+
* Show the clipboard's image data over the selected layer where it was copied from, and select the Move tool to place,
|
|
439
|
+
* scale and rotate it. It is written into the layer (and sent) on Enter or when switching to another tool; Escape
|
|
440
|
+
* discards it. A pending transform is applied first.
|
|
441
|
+
*/
|
|
442
|
+
paste(): void;
|
|
443
|
+
/**
|
|
444
|
+
* Apply a finished lasso action to the mask: a shape is added, subtracted or replaces it; a plain click deselects.
|
|
445
|
+
*/
|
|
446
|
+
applyLasso(result: LassoResult): void;
|
|
447
|
+
/**
|
|
448
|
+
* Whether a preset comes with the app (it can't be deleted, replaced or exported).
|
|
449
|
+
*/
|
|
450
|
+
isBuiltInPreset(id: string): boolean;
|
|
451
|
+
/**
|
|
452
|
+
* The handle of the author of presets the user makes (from the `presetAuthor` option), or "" if they have none. Their
|
|
453
|
+
* own presets are the ones with this handle (see `isOwnAuthor`).
|
|
454
|
+
*/
|
|
455
|
+
get authorHandle(): string;
|
|
456
|
+
/**
|
|
457
|
+
* Make a new custom preset from settings: a new ID, the given name, and the author from the `presetAuthor` option.
|
|
458
|
+
*
|
|
459
|
+
* @example
|
|
460
|
+
* app.newPreset(app.brush.preset, "My brush"); // { ...settings, id: "0b5c…", name: "My brush", author: { name, handle } }
|
|
461
|
+
*/
|
|
462
|
+
newPreset(settings: BrushConfig, name: string): BrushConfig;
|
|
463
|
+
/**
|
|
464
|
+
* List the custom presets after the built-in ones, for the brush and the eraser.
|
|
465
|
+
*/
|
|
466
|
+
private listCustomPresets;
|
|
467
|
+
/** The tool currently in effect: the held tool if a key is held, otherwise the selected tool */
|
|
468
|
+
get activeTool(): Tool;
|
|
469
|
+
/** The user's layers */
|
|
470
|
+
get layers(): LayerStack;
|
|
471
|
+
/** Current drawing colour as a hex string, e.g. `#000000` */
|
|
472
|
+
get colour(): string;
|
|
473
|
+
/**
|
|
474
|
+
* Set the drawing colour. Must be a 6-digit hex colour, e.g. `#ff0000`.
|
|
475
|
+
*/
|
|
476
|
+
setColour(colour: string): void;
|
|
477
|
+
/**
|
|
478
|
+
* Change the canvas size, from 1 to the maximum canvas size (`maxCanvasSize` option). Replaces all layers.
|
|
479
|
+
*/
|
|
480
|
+
setCanvasSize(width: number, height: number): void;
|
|
481
|
+
/**
|
|
482
|
+
* Called when the canvas size changes, before `change` is dispatched. Subclasses resize anything of their own here.
|
|
483
|
+
*/
|
|
484
|
+
protected canvasResized(width: number, height: number): void;
|
|
485
|
+
/**
|
|
486
|
+
* Check a canvas dimension is a whole number from 1 to the maximum canvas size.
|
|
487
|
+
*/
|
|
488
|
+
private isValidCanvasDimension;
|
|
489
|
+
/**
|
|
490
|
+
* Set whether scaling the Move tool's box keeps its proportions.
|
|
491
|
+
*/
|
|
492
|
+
setConstrainProportions(constrain: boolean): void;
|
|
493
|
+
/**
|
|
494
|
+
* Set how the colour sample tool samples.
|
|
495
|
+
*/
|
|
496
|
+
setSampleMode(mode: SampleMode): void;
|
|
497
|
+
/**
|
|
498
|
+
* Set where the user's pointer is over the canvas (undefined when it leaves). Dispatches `pointer` when it moves.
|
|
499
|
+
*/
|
|
500
|
+
setPointer(position: Point | undefined): void;
|
|
501
|
+
/**
|
|
502
|
+
* Select a tool.
|
|
503
|
+
*
|
|
504
|
+
* - Clicking a toolbar button (`fromToolbar: true`) only selects the tool: its presets open from the settings bar's
|
|
505
|
+
* preset button.
|
|
506
|
+
* - Pressing a tool's shortcut selects the tool, or toggles its panel if the tool is already selected.
|
|
507
|
+
*
|
|
508
|
+
* Switching tools closes the previous tool's panel (the layers panel and app menu stay open).
|
|
509
|
+
*/
|
|
510
|
+
selectTool(tool: Tool, options?: {
|
|
511
|
+
fromToolbar?: boolean;
|
|
512
|
+
}): void;
|
|
513
|
+
/**
|
|
514
|
+
* Use a tool temporarily while a key is held (e.g. Space for pan). The selected tool is unchanged.
|
|
515
|
+
*/
|
|
516
|
+
holdTool(tool: Tool): void;
|
|
517
|
+
/**
|
|
518
|
+
* Stop using the held tool and return to the selected tool.
|
|
519
|
+
*/
|
|
520
|
+
releaseHeldTool(): void;
|
|
521
|
+
/**
|
|
522
|
+
* Close the open panel, if any.
|
|
523
|
+
*/
|
|
524
|
+
closePanel(): void;
|
|
525
|
+
/**
|
|
526
|
+
* Open a panel, or close it if already open.
|
|
527
|
+
*/
|
|
528
|
+
togglePanel(panel: Panel): void;
|
|
529
|
+
/**
|
|
530
|
+
* Show or hide the interface.
|
|
531
|
+
*/
|
|
532
|
+
toggleInterface(): void;
|
|
533
|
+
/**
|
|
534
|
+
* Dispatch a `change` event.
|
|
535
|
+
*/
|
|
536
|
+
protected notify(): void;
|
|
537
|
+
}
|