@ggraphic/editor 0.1.0-alpha.6 → 0.1.0-alpha.7
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/dist/components/GenericCanvasElement.js +15 -1
- package/dist/components/TopBar/ContextControls.js +1 -1
- package/dist/components/TopBar/modules/FloatingFontSizeControl.d.ts +3 -1
- package/dist/components/TopBar/modules/FloatingFontSizeControl.js +46 -4
- package/dist/components/kindRenderers.js +10 -1
- package/dist/hooks/useLiveFontSize.d.ts +6 -0
- package/dist/hooks/useLiveFontSize.js +26 -0
- package/dist/i18n/de.d.ts +1 -0
- package/dist/i18n/de.js +1 -0
- package/dist/i18n/en.js +1 -0
- package/dist/page/actions.js +8 -2
- package/dist/primitives/CanvasImage.js +86 -12
- package/dist/primitives/CanvasRichText.js +10 -5
- package/dist/primitives/CanvasText.d.ts +8 -1
- package/dist/primitives/CanvasText.js +25 -5
- package/dist/styles/compiled.css +1 -1
- package/dist/utils/cropGhost.d.ts +3 -2
- package/dist/utils/cropGhost.js +4 -3
- package/dist/utils/filteredPan.d.ts +22 -0
- package/dist/utils/filteredPan.js +36 -0
- package/package.json +1 -1
|
@@ -58,6 +58,7 @@ export declare function paintCropGhosts(stage: Konva.Stage, canvas: HTMLCanvasEl
|
|
|
58
58
|
* Einfärbung), einmal auf eine verkleinerte Kopie gerechnet statt per Cache
|
|
59
59
|
* auf dem ganzen, oft vielfach gezoomten Restbild. Spiegeln bleibt außen vor:
|
|
60
60
|
* das Restbild spiegelt über seine Skalierung. `displayedWidth` ist die Breite
|
|
61
|
-
* des ganzen Fotos auf der Bühne; der Weichzeichner-Radius gilt dort.
|
|
61
|
+
* des ganzen Fotos auf der Bühne; der Weichzeichner-Radius gilt dort. `maxSide`
|
|
62
|
+
* begrenzt die längste Kante der Kopie (der Pan braucht Bildschirmauflösung).
|
|
62
63
|
*/
|
|
63
|
-
export declare function cropGhostSource(image: HTMLImageElement, adjustments: ImageAdjustments | null, displayedWidth: number, color?: string | null): CanvasImageSource;
|
|
64
|
+
export declare function cropGhostSource(image: HTMLImageElement, adjustments: ImageAdjustments | null, displayedWidth: number, color?: string | null, maxSide?: number): CanvasImageSource;
|
package/dist/utils/cropGhost.js
CHANGED
|
@@ -172,9 +172,10 @@ const GHOST_SOURCE_SIDE = 1024;
|
|
|
172
172
|
* Einfärbung), einmal auf eine verkleinerte Kopie gerechnet statt per Cache
|
|
173
173
|
* auf dem ganzen, oft vielfach gezoomten Restbild. Spiegeln bleibt außen vor:
|
|
174
174
|
* das Restbild spiegelt über seine Skalierung. `displayedWidth` ist die Breite
|
|
175
|
-
* des ganzen Fotos auf der Bühne; der Weichzeichner-Radius gilt dort.
|
|
175
|
+
* des ganzen Fotos auf der Bühne; der Weichzeichner-Radius gilt dort. `maxSide`
|
|
176
|
+
* begrenzt die längste Kante der Kopie (der Pan braucht Bildschirmauflösung).
|
|
176
177
|
*/
|
|
177
|
-
export function cropGhostSource(image, adjustments, displayedWidth, color = null) {
|
|
178
|
+
export function cropGhostSource(image, adjustments, displayedWidth, color = null, maxSide = GHOST_SOURCE_SIDE) {
|
|
178
179
|
const look = adjustments ? { ...adjustments, flipX: false, flipY: false } : null;
|
|
179
180
|
const filters = [
|
|
180
181
|
...(color ? [Konva.Filters.RGB] : []),
|
|
@@ -183,7 +184,7 @@ export function cropGhostSource(image, adjustments, displayedWidth, color = null
|
|
|
183
184
|
const natural = { width: image.naturalWidth, height: image.naturalHeight };
|
|
184
185
|
if (filters.length === 0 || !natural.width || !natural.height)
|
|
185
186
|
return image;
|
|
186
|
-
const scale = Math.min(1,
|
|
187
|
+
const scale = Math.min(1, maxSide / Math.max(natural.width, natural.height));
|
|
187
188
|
const width = Math.max(1, Math.round(natural.width * scale));
|
|
188
189
|
const height = Math.max(1, Math.round(natural.height * scale));
|
|
189
190
|
const canvas = document.createElement('canvas');
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type Konva from 'konva';
|
|
2
|
+
interface Rect {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}
|
|
8
|
+
/** A pan of a filtered photo over its pre-filtered copy; `end` puts the photo and its filters back. */
|
|
9
|
+
export interface FilteredPan {
|
|
10
|
+
/** Sets a crop given in the photo's own pixels on the copy. */
|
|
11
|
+
crop: (crop: Rect) => void;
|
|
12
|
+
end: () => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Pans a filtered photo without filtering it again on every move. A filtered node draws from its
|
|
16
|
+
* cache, and a new crop needs a new cache: one pass of every filter over the bitmap per pointer
|
|
17
|
+
* move (#197). Instead the node shows `source` — the whole photo, filtered once at the resolution
|
|
18
|
+
* it is shown at — with its crop scaled to that copy, and no filters or cache. Null when `source`
|
|
19
|
+
* is the photo itself (nothing to filter).
|
|
20
|
+
*/
|
|
21
|
+
export declare function beginFilteredPan(node: Konva.Image, source: CanvasImageSource, naturalWidth: number): FilteredPan | null;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const scaleRect = (r, s) => ({
|
|
2
|
+
x: r.x * s,
|
|
3
|
+
y: r.y * s,
|
|
4
|
+
width: r.width * s,
|
|
5
|
+
height: r.height * s,
|
|
6
|
+
});
|
|
7
|
+
/**
|
|
8
|
+
* Pans a filtered photo without filtering it again on every move. A filtered node draws from its
|
|
9
|
+
* cache, and a new crop needs a new cache: one pass of every filter over the bitmap per pointer
|
|
10
|
+
* move (#197). Instead the node shows `source` — the whole photo, filtered once at the resolution
|
|
11
|
+
* it is shown at — with its crop scaled to that copy, and no filters or cache. Null when `source`
|
|
12
|
+
* is the photo itself (nothing to filter).
|
|
13
|
+
*/
|
|
14
|
+
export function beginFilteredPan(node, source, naturalWidth) {
|
|
15
|
+
const photo = node.image();
|
|
16
|
+
if (!photo || source === photo || !('width' in source))
|
|
17
|
+
return null;
|
|
18
|
+
const sourceWidth = Number(source.width);
|
|
19
|
+
if (!sourceWidth || !naturalWidth)
|
|
20
|
+
return null;
|
|
21
|
+
const s = sourceWidth / naturalWidth;
|
|
22
|
+
const filters = node.filters();
|
|
23
|
+
node.clearCache();
|
|
24
|
+
node.filters([]);
|
|
25
|
+
node.image(source);
|
|
26
|
+
node.crop(scaleRect(node.crop(), s));
|
|
27
|
+
return {
|
|
28
|
+
crop: (crop) => node.crop(scaleRect(crop, s)),
|
|
29
|
+
end: () => {
|
|
30
|
+
const crop = node.crop();
|
|
31
|
+
node.image(photo);
|
|
32
|
+
node.filters(filters);
|
|
33
|
+
node.crop(scaleRect(crop, 1 / s));
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|