@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,136 @@
|
|
|
1
|
+
import style_default from "./style.js";
|
|
2
|
+
import { PcElement, defineElement } from "../../base/index.js";
|
|
3
|
+
import StrokeEngine from "../../../lib/brushes/StrokeEngine/index.js";
|
|
4
|
+
import Layer, { createOffscreenCanvas } from "../../../lib/classes/Layer/index.js";
|
|
5
|
+
import { html, unsafeCSS } from "lit";
|
|
6
|
+
// src/ui/elements/PcBrushTest/index.ts
|
|
7
|
+
/** Width of the testing area in pixels (double its displayed width, for a sharper picture) */
|
|
8
|
+
var TEST_AREA_WIDTH = 800;
|
|
9
|
+
/** Height of the testing area in pixels (double its displayed height) */
|
|
10
|
+
var TEST_AREA_HEIGHT = 320;
|
|
11
|
+
/** The colour test strokes are drawn in, whatever the current colour */
|
|
12
|
+
var TEST_COLOUR = "#000000";
|
|
13
|
+
/**
|
|
14
|
+
* A small area to try brush settings before saving them: strokes are drawn in black, at the settings' own size, on a
|
|
15
|
+
* white background at double resolution (800 × 320 pixels shown in the window's width). "Clear" (a red pill) empties it.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* html`<pc-brush-test .config=${config} .tips=${app.tips}></pc-brush-test>`
|
|
19
|
+
*/
|
|
20
|
+
var PcBrushTest = class extends PcElement {
|
|
21
|
+
static properties = {
|
|
22
|
+
...PcElement.properties,
|
|
23
|
+
config: { attribute: false },
|
|
24
|
+
tips: { attribute: false }
|
|
25
|
+
};
|
|
26
|
+
static styles = [PcElement.styles, unsafeCSS(style_default)];
|
|
27
|
+
/** Creates the layer and stroke canvases (replaceable for tests) */
|
|
28
|
+
createCanvas = createOffscreenCanvas;
|
|
29
|
+
layer;
|
|
30
|
+
engine;
|
|
31
|
+
/** The pointer drawing, if any */
|
|
32
|
+
pointerId;
|
|
33
|
+
onEngineChange = () => this.paint();
|
|
34
|
+
disconnectedCallback() {
|
|
35
|
+
super.disconnectedCallback();
|
|
36
|
+
this.engine?.removeEventListener("change", this.onEngineChange);
|
|
37
|
+
}
|
|
38
|
+
/** The visible canvas */
|
|
39
|
+
get canvas() {
|
|
40
|
+
return this.renderRoot.querySelector("canvas");
|
|
41
|
+
}
|
|
42
|
+
/** The layer strokes are drawn on, and the engine drawing them (created on first use) */
|
|
43
|
+
get drawing() {
|
|
44
|
+
this.layer ??= new Layer({ name: "Test" }, 800, 320, this.createCanvas);
|
|
45
|
+
if (!this.engine) {
|
|
46
|
+
this.engine = new StrokeEngine(800, 320, this.createCanvas);
|
|
47
|
+
this.engine.addEventListener("change", this.onEngineChange);
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
layer: this.layer,
|
|
51
|
+
engine: this.engine
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** A pointer's position in the area's pixels, with pen pressure and tilt */
|
|
55
|
+
point(event) {
|
|
56
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
57
|
+
const scale = rect.width ? 800 / rect.width : 1;
|
|
58
|
+
return {
|
|
59
|
+
x: (event.clientX - rect.left) * scale,
|
|
60
|
+
y: (event.clientY - rect.top) * scale,
|
|
61
|
+
...event.pointerType === "pen" ? {
|
|
62
|
+
pressure: event.pressure,
|
|
63
|
+
tiltX: event.tiltX,
|
|
64
|
+
tiltY: event.tiltY
|
|
65
|
+
} : {}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Start a test stroke.
|
|
70
|
+
*/
|
|
71
|
+
onPointerDown(event) {
|
|
72
|
+
const config = this.config;
|
|
73
|
+
if (!config || !this.tips || event.button !== 0) return;
|
|
74
|
+
const { layer, engine } = this.drawing;
|
|
75
|
+
this.pointerId = event.pointerId;
|
|
76
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
77
|
+
engine.begin({
|
|
78
|
+
layer,
|
|
79
|
+
mode: "paint",
|
|
80
|
+
preset: config,
|
|
81
|
+
size: {
|
|
82
|
+
width: config.width ?? 1,
|
|
83
|
+
height: config.height ?? 1
|
|
84
|
+
},
|
|
85
|
+
colour: TEST_COLOUR,
|
|
86
|
+
tip: this.tips.get(config),
|
|
87
|
+
isPen: event.pointerType === "pen"
|
|
88
|
+
}, this.point(event), event.timeStamp);
|
|
89
|
+
}
|
|
90
|
+
/** Continue the test stroke */
|
|
91
|
+
onPointerMove(event) {
|
|
92
|
+
if (event.pointerId !== this.pointerId) return;
|
|
93
|
+
this.engine?.move(this.point(event), event.timeStamp);
|
|
94
|
+
}
|
|
95
|
+
/** Finish the test stroke */
|
|
96
|
+
onPointerUp(event) {
|
|
97
|
+
if (event.pointerId !== this.pointerId) return;
|
|
98
|
+
this.pointerId = void 0;
|
|
99
|
+
this.engine?.end(this.point(event), event.timeStamp);
|
|
100
|
+
this.paint();
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Empty the testing area.
|
|
104
|
+
*/
|
|
105
|
+
clear() {
|
|
106
|
+
this.engine?.cancel();
|
|
107
|
+
this.layer?.context.clearRect(0, 0, 800, 320);
|
|
108
|
+
this.paint();
|
|
109
|
+
}
|
|
110
|
+
/** Show the layer (with any stroke in progress) on the visible canvas */
|
|
111
|
+
paint() {
|
|
112
|
+
const ctx = this.canvas?.getContext("2d");
|
|
113
|
+
if (!ctx) return;
|
|
114
|
+
ctx.clearRect(0, 0, 800, 320);
|
|
115
|
+
const image = this.engine?.preview?.image ?? this.layer?.canvas;
|
|
116
|
+
if (image) ctx.drawImage(image, 0, 0);
|
|
117
|
+
}
|
|
118
|
+
render() {
|
|
119
|
+
return html`
|
|
120
|
+
<canvas
|
|
121
|
+
width=${800}
|
|
122
|
+
height=${320}
|
|
123
|
+
aria-label=${this.t("paintCanvas.brushConfig.testArea")}
|
|
124
|
+
@pointerdown=${this.onPointerDown}
|
|
125
|
+
@pointermove=${this.onPointerMove}
|
|
126
|
+
@pointerup=${this.onPointerUp}
|
|
127
|
+
@pointercancel=${this.onPointerUp}
|
|
128
|
+
></canvas>
|
|
129
|
+
<button type="button" class="clear" @click=${() => this.clear()}>
|
|
130
|
+
${this.t("paintCanvas.common.clear")}
|
|
131
|
+
</button>
|
|
132
|
+
`;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
defineElement("pc-brush-test", PcBrushTest);
|
|
136
|
+
export { PcBrushTest, TEST_AREA_HEIGHT, TEST_AREA_WIDTH, TEST_COLOUR };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// src/ui/elements/PcBrushTest/style.css?inline
|
|
2
|
+
var style_default = ":host {\n display: block;\n}\ncanvas {\n display: block;\n width: 100%;\n background: #fff;\n border: 1px solid var(--pc-border);\n touch-action: none;\n}\n/* \"Clear\": a red pill */\nbutton.clear {\n margin-top: 6px;\n padding: 4px 16px;\n border: 0;\n border-radius: 999px;\n background: var(--pc-red);\n color: #ffffff;\n font: inherit;\n font-weight: bold;\n cursor: pointer;\n}\nbutton.clear:hover {\n filter: brightness(1.1);\n}\nbutton.clear:focus-visible {\n outline: var(--pc-focus-width) solid var(--pc-focus);\n outline-offset: 2px;\n}\n";
|
|
3
|
+
export { style_default as default };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { PcElement } from "../../base";
|
|
2
|
+
import "../PcIcon";
|
|
3
|
+
/** How a button looks */
|
|
4
|
+
export type ButtonVariant = "accent" | "cancel" | "dismiss" | "pill" | "icon";
|
|
5
|
+
/**
|
|
6
|
+
* A button: affirmative (`accent`, the default), cancelling (`cancel`), a quiet text button (`dismiss`), a small pill
|
|
7
|
+
* (`pill`), or a boxed icon button (`icon`, which needs a `label` for screen readers). Its text goes in its content.
|
|
8
|
+
* Clicks reach listeners on the element; a disabled button sends none.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* html`<pc-button variant="cancel" @click=${close}>Cancel</pc-button>`
|
|
12
|
+
* html`<pc-button variant="icon" icon="undo" label="Undo"></pc-button>`
|
|
13
|
+
*/
|
|
14
|
+
export declare class PcButton extends PcElement {
|
|
15
|
+
static properties: {
|
|
16
|
+
variant: {
|
|
17
|
+
type: StringConstructor;
|
|
18
|
+
reflect: boolean;
|
|
19
|
+
};
|
|
20
|
+
icon: {
|
|
21
|
+
type: StringConstructor;
|
|
22
|
+
};
|
|
23
|
+
label: {
|
|
24
|
+
type: StringConstructor;
|
|
25
|
+
};
|
|
26
|
+
disabled: {
|
|
27
|
+
type: BooleanConstructor;
|
|
28
|
+
reflect: boolean;
|
|
29
|
+
};
|
|
30
|
+
pressed: {
|
|
31
|
+
type: BooleanConstructor;
|
|
32
|
+
};
|
|
33
|
+
translations: {
|
|
34
|
+
attribute: boolean;
|
|
35
|
+
};
|
|
36
|
+
icons: {
|
|
37
|
+
attribute: boolean;
|
|
38
|
+
};
|
|
39
|
+
theme: {
|
|
40
|
+
type: StringConstructor;
|
|
41
|
+
reflect: boolean;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
static styles: import("lit").CSSResultGroup[];
|
|
45
|
+
variant: ButtonVariant;
|
|
46
|
+
/** Name of an icon to show before the text (or alone, for an icon button) */
|
|
47
|
+
icon?: string;
|
|
48
|
+
/** The button's name for screen readers, when its content doesn't say it (e.g. an icon button) */
|
|
49
|
+
label?: string;
|
|
50
|
+
disabled: boolean;
|
|
51
|
+
/** For a button that toggles something: whether it's on (undefined for an ordinary button) */
|
|
52
|
+
pressed?: boolean;
|
|
53
|
+
constructor();
|
|
54
|
+
/** Move keyboard focus to the button */
|
|
55
|
+
focus(options?: FocusOptions): void;
|
|
56
|
+
render(): import("lit").TemplateResult<1>;
|
|
57
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { PcElement, defineElement } from "../../base/index.js";
|
|
2
|
+
import { css, html, nothing } from "lit";
|
|
3
|
+
// src/ui/elements/PcButton/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* A button: affirmative (`accent`, the default), cancelling (`cancel`), a quiet text button (`dismiss`), a small pill
|
|
6
|
+
* (`pill`), or a boxed icon button (`icon`, which needs a `label` for screen readers). Its text goes in its content.
|
|
7
|
+
* Clicks reach listeners on the element; a disabled button sends none.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* html`<pc-button variant="cancel" @click=${close}>Cancel</pc-button>`
|
|
11
|
+
* html`<pc-button variant="icon" icon="undo" label="Undo"></pc-button>`
|
|
12
|
+
*/
|
|
13
|
+
var PcButton = class extends PcElement {
|
|
14
|
+
static properties = {
|
|
15
|
+
...PcElement.properties,
|
|
16
|
+
variant: {
|
|
17
|
+
type: String,
|
|
18
|
+
reflect: true
|
|
19
|
+
},
|
|
20
|
+
icon: { type: String },
|
|
21
|
+
label: { type: String },
|
|
22
|
+
disabled: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
reflect: true
|
|
25
|
+
},
|
|
26
|
+
pressed: { type: Boolean }
|
|
27
|
+
};
|
|
28
|
+
static styles = [PcElement.styles, css`
|
|
29
|
+
:host {
|
|
30
|
+
display: inline-flex;
|
|
31
|
+
}
|
|
32
|
+
:host([disabled]) {
|
|
33
|
+
pointer-events: none;
|
|
34
|
+
}
|
|
35
|
+
button {
|
|
36
|
+
display: inline-flex;
|
|
37
|
+
flex: 1;
|
|
38
|
+
align-items: center;
|
|
39
|
+
justify-content: center;
|
|
40
|
+
gap: var(--pc-space-1);
|
|
41
|
+
min-height: var(--pc-control-size);
|
|
42
|
+
padding: var(--pc-space-1) var(--pc-space-3);
|
|
43
|
+
border: 0;
|
|
44
|
+
/* A joined button group gives each button its corners */
|
|
45
|
+
border-radius: var(--pc-group-radius, var(--pc-radius-pill));
|
|
46
|
+
background: var(--pc-accent);
|
|
47
|
+
color: var(--pc-accent-text);
|
|
48
|
+
font: inherit;
|
|
49
|
+
font-family: var(--pc-font);
|
|
50
|
+
font-size: var(--pc-font-size);
|
|
51
|
+
font-weight: bold;
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
}
|
|
54
|
+
button:hover:not(:disabled) {
|
|
55
|
+
filter: brightness(1.15);
|
|
56
|
+
}
|
|
57
|
+
button:focus-visible {
|
|
58
|
+
outline: var(--pc-focus-width) solid var(--pc-focus);
|
|
59
|
+
outline-offset: 2px;
|
|
60
|
+
}
|
|
61
|
+
button:disabled {
|
|
62
|
+
background: var(--pc-disabled);
|
|
63
|
+
opacity: 0.6;
|
|
64
|
+
cursor: default;
|
|
65
|
+
}
|
|
66
|
+
:host([variant="cancel"]) button {
|
|
67
|
+
background: var(--pc-cancel);
|
|
68
|
+
color: var(--pc-cancel-text);
|
|
69
|
+
}
|
|
70
|
+
:host([variant="dismiss"]) button {
|
|
71
|
+
background: transparent;
|
|
72
|
+
color: var(--pc-dismiss-text);
|
|
73
|
+
}
|
|
74
|
+
:host([variant="dismiss"]) button:hover {
|
|
75
|
+
filter: none;
|
|
76
|
+
text-decoration: underline;
|
|
77
|
+
}
|
|
78
|
+
:host([variant="pill"]) button {
|
|
79
|
+
min-height: 30px;
|
|
80
|
+
}
|
|
81
|
+
:host([variant="icon"]) button {
|
|
82
|
+
min-height: 0;
|
|
83
|
+
padding: 2px;
|
|
84
|
+
border: 1px solid var(--pc-border);
|
|
85
|
+
border-radius: var(--pc-group-radius, var(--pc-radius-small));
|
|
86
|
+
background: var(--pc-surface);
|
|
87
|
+
color: var(--pc-text);
|
|
88
|
+
}
|
|
89
|
+
:host([variant="icon"]) button:hover:not(:disabled) {
|
|
90
|
+
filter: none;
|
|
91
|
+
background: var(--pc-surface-hover);
|
|
92
|
+
}
|
|
93
|
+
:host([variant="icon"]) button[aria-pressed="true"] {
|
|
94
|
+
background: var(--pc-accent);
|
|
95
|
+
}
|
|
96
|
+
:host([variant="icon"]) button:disabled {
|
|
97
|
+
opacity: 0.4;
|
|
98
|
+
}
|
|
99
|
+
`];
|
|
100
|
+
constructor() {
|
|
101
|
+
super();
|
|
102
|
+
this.variant = "accent";
|
|
103
|
+
this.disabled = false;
|
|
104
|
+
}
|
|
105
|
+
/** Move keyboard focus to the button */
|
|
106
|
+
focus(options) {
|
|
107
|
+
this.renderRoot.querySelector("button")?.focus(options);
|
|
108
|
+
}
|
|
109
|
+
render() {
|
|
110
|
+
return html`<button
|
|
111
|
+
part="button"
|
|
112
|
+
type="button"
|
|
113
|
+
?disabled=${this.disabled}
|
|
114
|
+
aria-label=${this.label || nothing}
|
|
115
|
+
aria-pressed=${this.pressed === void 0 ? nothing : String(this.pressed)}
|
|
116
|
+
title=${this.variant === "icon" && this.label || nothing}
|
|
117
|
+
>
|
|
118
|
+
${this.icon ? html`<pc-icon name=${this.icon}></pc-icon>` : nothing}<slot
|
|
119
|
+
></slot>
|
|
120
|
+
</button>`;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
defineElement("pc-button", PcButton);
|
|
124
|
+
export { PcButton };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { PcElement } from "../../base";
|
|
2
|
+
/**
|
|
3
|
+
* Groups buttons in a row (`horizontal`, the default) or a column (`vertical`), with a `label` that names the group for
|
|
4
|
+
* screen readers. When `joined`, the buttons touch and make one pill: the first has the rounded start, the last the
|
|
5
|
+
* rounded end, and those between are square. It tells its children their corners with `--pc-group-radius`, which
|
|
6
|
+
* `<pc-button>` follows (other content can too).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* html`<pc-button-group orientation="vertical" label="Tools">…</pc-button-group>`
|
|
10
|
+
* html`<pc-button-group joined label="View"><pc-button>Day</pc-button><pc-button>Week</pc-button></pc-button-group>`
|
|
11
|
+
*/
|
|
12
|
+
export declare class PcButtonGroup extends PcElement {
|
|
13
|
+
static properties: {
|
|
14
|
+
orientation: {
|
|
15
|
+
type: StringConstructor;
|
|
16
|
+
reflect: boolean;
|
|
17
|
+
};
|
|
18
|
+
label: {
|
|
19
|
+
type: StringConstructor;
|
|
20
|
+
};
|
|
21
|
+
joined: {
|
|
22
|
+
type: BooleanConstructor;
|
|
23
|
+
reflect: boolean;
|
|
24
|
+
};
|
|
25
|
+
translations: {
|
|
26
|
+
attribute: boolean;
|
|
27
|
+
};
|
|
28
|
+
icons: {
|
|
29
|
+
attribute: boolean;
|
|
30
|
+
};
|
|
31
|
+
theme: {
|
|
32
|
+
type: StringConstructor;
|
|
33
|
+
reflect: boolean;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
static styles: import("lit").CSSResultGroup[];
|
|
37
|
+
orientation: "horizontal" | "vertical";
|
|
38
|
+
/** Names the group for screen readers */
|
|
39
|
+
label: string;
|
|
40
|
+
/** Whether the buttons touch, making one pill */
|
|
41
|
+
joined: boolean;
|
|
42
|
+
constructor();
|
|
43
|
+
render(): import("lit").TemplateResult<1>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { PcElement, defineElement } from "../../base/index.js";
|
|
2
|
+
import { css, html } from "lit";
|
|
3
|
+
// src/ui/elements/PcButtonGroup/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* Groups buttons in a row (`horizontal`, the default) or a column (`vertical`), with a `label` that names the group for
|
|
6
|
+
* screen readers. When `joined`, the buttons touch and make one pill: the first has the rounded start, the last the
|
|
7
|
+
* rounded end, and those between are square. It tells its children their corners with `--pc-group-radius`, which
|
|
8
|
+
* `<pc-button>` follows (other content can too).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* html`<pc-button-group orientation="vertical" label="Tools">…</pc-button-group>`
|
|
12
|
+
* html`<pc-button-group joined label="View"><pc-button>Day</pc-button><pc-button>Week</pc-button></pc-button-group>`
|
|
13
|
+
*/
|
|
14
|
+
var PcButtonGroup = class extends PcElement {
|
|
15
|
+
static properties = {
|
|
16
|
+
...PcElement.properties,
|
|
17
|
+
orientation: {
|
|
18
|
+
type: String,
|
|
19
|
+
reflect: true
|
|
20
|
+
},
|
|
21
|
+
label: { type: String },
|
|
22
|
+
joined: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
reflect: true
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
static styles = [PcElement.styles, css`
|
|
28
|
+
:host {
|
|
29
|
+
display: inline-flex;
|
|
30
|
+
}
|
|
31
|
+
[role="group"] {
|
|
32
|
+
display: flex;
|
|
33
|
+
flex-direction: row;
|
|
34
|
+
flex-wrap: wrap;
|
|
35
|
+
gap: var(--pc-space-1);
|
|
36
|
+
align-items: center;
|
|
37
|
+
}
|
|
38
|
+
:host([orientation="vertical"]) [role="group"] {
|
|
39
|
+
flex-direction: column;
|
|
40
|
+
flex-wrap: nowrap;
|
|
41
|
+
align-items: stretch;
|
|
42
|
+
}
|
|
43
|
+
/* Joined: one pill, with the buttons' borders overlapping */
|
|
44
|
+
:host([joined]) [role="group"] {
|
|
45
|
+
flex-wrap: nowrap;
|
|
46
|
+
gap: 0;
|
|
47
|
+
align-items: stretch;
|
|
48
|
+
}
|
|
49
|
+
:host([joined]) ::slotted(*) {
|
|
50
|
+
--pc-group-radius: 0;
|
|
51
|
+
}
|
|
52
|
+
:host([joined]) ::slotted(:not(:first-child)) {
|
|
53
|
+
margin-left: -1px;
|
|
54
|
+
}
|
|
55
|
+
:host([joined]) ::slotted(:first-child) {
|
|
56
|
+
--pc-group-radius: var(--pc-radius-pill) 0 0 var(--pc-radius-pill);
|
|
57
|
+
}
|
|
58
|
+
:host([joined]) ::slotted(:last-child) {
|
|
59
|
+
--pc-group-radius: 0 var(--pc-radius-pill) var(--pc-radius-pill) 0;
|
|
60
|
+
}
|
|
61
|
+
:host([joined][orientation="vertical"]) ::slotted(:not(:first-child)) {
|
|
62
|
+
margin-top: -1px;
|
|
63
|
+
margin-left: 0;
|
|
64
|
+
}
|
|
65
|
+
:host([joined][orientation="vertical"]) ::slotted(:first-child) {
|
|
66
|
+
--pc-group-radius: var(--pc-radius-pill) var(--pc-radius-pill) 0 0;
|
|
67
|
+
}
|
|
68
|
+
:host([joined][orientation="vertical"]) ::slotted(:last-child) {
|
|
69
|
+
--pc-group-radius: 0 0 var(--pc-radius-pill) var(--pc-radius-pill);
|
|
70
|
+
}
|
|
71
|
+
:host([joined]) ::slotted(:only-child) {
|
|
72
|
+
--pc-group-radius: var(--pc-radius-pill);
|
|
73
|
+
}
|
|
74
|
+
`];
|
|
75
|
+
constructor() {
|
|
76
|
+
super();
|
|
77
|
+
this.orientation = "horizontal";
|
|
78
|
+
this.label = "";
|
|
79
|
+
this.joined = false;
|
|
80
|
+
}
|
|
81
|
+
render() {
|
|
82
|
+
return html`<div
|
|
83
|
+
part="group"
|
|
84
|
+
role="group"
|
|
85
|
+
aria-label=${this.label}
|
|
86
|
+
aria-orientation=${this.orientation}
|
|
87
|
+
>
|
|
88
|
+
<slot></slot>
|
|
89
|
+
</div>`;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
defineElement("pc-button-group", PcButtonGroup);
|
|
93
|
+
export { PcButtonGroup };
|