@pixerate/editor 0.228.1 → 0.229.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.
@@ -150,8 +150,12 @@ function effectReach(e) {
150
150
  return e.size;
151
151
  case "satin":
152
152
  return Math.max(1, e.distance) + e.size;
153
- case "bevel-emboss":
154
- return e.size + e.soften + 1;
153
+ case "bevel-emboss": {
154
+ if (e.technique === "smooth") return e.size + e.soften + 1;
155
+ const size = Math.max(e.size, 1);
156
+ const chiselSoft = e.technique === "chisel-soft" ? Math.max(size / 4, 1) + 1 : 0;
157
+ return size + 3 + chiselSoft + e.soften + 1 + 1;
158
+ }
155
159
  default:
156
160
  return 0;
157
161
  }
@@ -46,7 +46,7 @@ import {
46
46
  validateEffectGradient,
47
47
  validateLayerEffects,
48
48
  warpSurface
49
- } from "./chunk-QXY4YTRI.js";
49
+ } from "./chunk-UOOK7HTX.js";
50
50
  import {
51
51
  affineFromHomography,
52
52
  applyHomography,
@@ -464,6 +464,11 @@ function clampCropToImage(crop, width, height) {
464
464
  height: Math.max(1, Math.min(height - y, crop.height))
465
465
  };
466
466
  }
467
+ var MARGIN_FIT_MIN_GUTTER = 36;
468
+ function marginFitSpan(size) {
469
+ const gutter = Math.max(size * 0.075, MARGIN_FIT_MIN_GUTTER);
470
+ return size - 2 * gutter > size * 0.5 ? size - 2 * gutter : size * 0.85;
471
+ }
467
472
  function resolveViewport(state, vpWidth, vpHeight, isActivelyCropping, cropOverride) {
468
473
  const { imageDimensions, crop: stateCrop, transform, zoom, pan, fit = "margin" } = state;
469
474
  const naturalWidth = imageDimensions.width || 800;
@@ -472,7 +477,7 @@ function resolveViewport(state, vpWidth, vpHeight, isActivelyCropping, cropOverr
472
477
  const activeCrop = cropOverride !== void 0 && cropOverride !== null ? cropOverride : stateCrop ?? (isActivelyCropping ? full : null);
473
478
  const region = !isActivelyCropping && activeCrop ? clampCropToImage(activeCrop, naturalWidth, naturalHeight) : full;
474
479
  const { width: baseW, height: baseH } = getRotatedSize(region.width, region.height, transform);
475
- const fitScale = fit === "contain" ? Math.min(vpWidth / baseW, vpHeight / baseH) : Math.min(vpWidth * 0.85 / baseW, vpHeight * 0.85 / baseH, 1);
480
+ const fitScale = fit === "contain" ? Math.min(vpWidth / baseW, vpHeight / baseH) : Math.min(marginFitSpan(vpWidth) / baseW, marginFitSpan(vpHeight) / baseH, 1);
476
481
  const centerX = vpWidth / 2 + pan.x;
477
482
  const centerY = vpHeight / 2 + pan.y;
478
483
  const projection = {
@@ -11758,6 +11763,7 @@ export {
11758
11763
  applyImageProjectionToContext,
11759
11764
  projectImageRect,
11760
11765
  clampCropToImage,
11766
+ MARGIN_FIT_MIN_GUTTER,
11761
11767
  getViewportProjection,
11762
11768
  getViewportMetrics,
11763
11769
  canvasToImagePoint,
@@ -150,8 +150,12 @@ function effectReach(e) {
150
150
  return e.size;
151
151
  case "satin":
152
152
  return Math.max(1, e.distance) + e.size;
153
- case "bevel-emboss":
154
- return e.size + e.soften + 1;
153
+ case "bevel-emboss": {
154
+ if (e.technique === "smooth") return e.size + e.soften + 1;
155
+ const size = Math.max(e.size, 1);
156
+ const chiselSoft = e.technique === "chisel-soft" ? Math.max(size / 4, 1) + 1 : 0;
157
+ return size + 3 + chiselSoft + e.soften + 1 + 1;
158
+ }
155
159
  default:
156
160
  return 0;
157
161
  }
@@ -1031,6 +1031,18 @@ export declare class ImageEditorController {
1031
1031
  compositePixels(rect?: CropBox, options?: {
1032
1032
  layerIds?: string[];
1033
1033
  }): PixelBuffer;
1034
+ /**
1035
+ * The Eyedropper: the colour (#rrggbb) of the composite at a document point, or the average of
1036
+ * the `size` × `size` square round it (1, 3 or 5…), or null outside the canvas or where every
1037
+ * layer is transparent. With `setForeground` it also becomes the paint foreground.
1038
+ */
1039
+ sampleColor(point: {
1040
+ x: number;
1041
+ y: number;
1042
+ }, options?: {
1043
+ size?: number;
1044
+ setForeground?: boolean;
1045
+ }): string | null;
1034
1046
  private compositorSources;
1035
1047
  private sourceIds;
1036
1048
  private nextSourceId;
@@ -1031,6 +1031,18 @@ export declare class ImageEditorController {
1031
1031
  compositePixels(rect?: CropBox, options?: {
1032
1032
  layerIds?: string[];
1033
1033
  }): PixelBuffer;
1034
+ /**
1035
+ * The Eyedropper: the colour (#rrggbb) of the composite at a document point, or the average of
1036
+ * the `size` × `size` square round it (1, 3 or 5…), or null outside the canvas or where every
1037
+ * layer is transparent. With `setForeground` it also becomes the paint foreground.
1038
+ */
1039
+ sampleColor(point: {
1040
+ x: number;
1041
+ y: number;
1042
+ }, options?: {
1043
+ size?: number;
1044
+ setForeground?: boolean;
1045
+ }): string | null;
1034
1046
  private compositorSources;
1035
1047
  private sourceIds;
1036
1048
  private nextSourceId;
@@ -67,6 +67,12 @@ export declare function projectImageRect(rect: CropBox, p: ImageProjection): {
67
67
  };
68
68
  /** Clamps a crop box to the image bounds. */
69
69
  export declare function clampCropToImage(crop: CropBox, width: number, height: number): CropBox;
70
+ /**
71
+ * The `margin` fit's gutter on each side: 7.5 % of the view (85 % fit), and never less than the
72
+ * room the transform frame's rotate handle needs above the image (`TRANSFORM_ROTATE_HANDLE_OFFSET`
73
+ * out, plus the handle), so a full-size layer's handles stay inside a small view.
74
+ */
75
+ export declare const MARGIN_FIT_MIN_GUTTER = 36;
70
76
  /**
71
77
  * Returns the natural-image -> canvas projection used by the interactive viewport.
72
78
  */
@@ -67,6 +67,12 @@ export declare function projectImageRect(rect: CropBox, p: ImageProjection): {
67
67
  };
68
68
  /** Clamps a crop box to the image bounds. */
69
69
  export declare function clampCropToImage(crop: CropBox, width: number, height: number): CropBox;
70
+ /**
71
+ * The `margin` fit's gutter on each side: 7.5 % of the view (85 % fit), and never less than the
72
+ * room the transform frame's rotate handle needs above the image (`TRANSFORM_ROTATE_HANDLE_OFFSET`
73
+ * out, plus the handle), so a full-size layer's handles stay inside a small view.
74
+ */
75
+ export declare const MARGIN_FIT_MIN_GUTTER = 36;
70
76
  /**
71
77
  * Returns the natural-image -> canvas projection used by the interactive viewport.
72
78
  */