@overtone-art/canvas-editor-core 0.5.0 → 0.5.1
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/index.d.mts +42 -2
- package/dist/index.d.ts +42 -2
- package/dist/index.global.js +28 -28
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +77 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +77 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -323,8 +323,32 @@ declare class TiledPatternObject extends FabricObject {
|
|
|
323
323
|
* tiling. The copy shares the source (it only ever reads from it).
|
|
324
324
|
*/
|
|
325
325
|
clone(): Promise<this>;
|
|
326
|
+
/**
|
|
327
|
+
* The source's tile footprint: its bounding box, minus a stroke it reserves
|
|
328
|
+
* room for but never paints.
|
|
329
|
+
*
|
|
330
|
+
* fabric keeps `strokeWidth` inside an object's box whether or not a `stroke`
|
|
331
|
+
* colour paints it, and the built-in shapes arrive with `strokeWidth: 1` and no
|
|
332
|
+
* stroke. Stepping the grid by that box puts a transparent seam between every
|
|
333
|
+
* pair of neighbours at zero spacing: the artwork is a pixel narrower than the
|
|
334
|
+
* box it is stepped by.
|
|
335
|
+
*/
|
|
336
|
+
private sourceBox;
|
|
326
337
|
/** The source's on-canvas width, before the tile scale. */
|
|
327
338
|
private baseW;
|
|
339
|
+
/** The source's on-canvas height, before the tile scale. */
|
|
340
|
+
private baseH;
|
|
341
|
+
/**
|
|
342
|
+
* Size to paint the snapshot at, for a tile of `tileW × tileH`.
|
|
343
|
+
*
|
|
344
|
+
* The snapshot is NOT exactly the source's box: `toCanvasElement` rounds the
|
|
345
|
+
* raster up to whole pixels and pads it further for a shadow. Painting it into
|
|
346
|
+
* the tile step would squeeze the artwork inside that padding — every tile
|
|
347
|
+
* shrinks by up to a pixel and the grid shows transparent seams at zero
|
|
348
|
+
* spacing. So the bitmap is painted at its own footprint, scaled by the same
|
|
349
|
+
* factor the tile is, and the step stays the source's box.
|
|
350
|
+
*/
|
|
351
|
+
private drawSize;
|
|
328
352
|
/** Tile size from the config alone, ignoring any in-flight gesture. */
|
|
329
353
|
private baseTile;
|
|
330
354
|
/** Tile size as drawn right now, including a live scale gesture. */
|
|
@@ -356,6 +380,18 @@ interface PatternOrigin {
|
|
|
356
380
|
x: number;
|
|
357
381
|
y: number;
|
|
358
382
|
}
|
|
383
|
+
/**
|
|
384
|
+
* Size the tile bitmap is painted at, when that differs from the grid step.
|
|
385
|
+
*
|
|
386
|
+
* A snapshot of the source is not always exactly the source's box: the raster is
|
|
387
|
+
* allocated in whole pixels, and a shadow pads it further. Painting such a bitmap
|
|
388
|
+
* into the step would shrink the artwork inside its own transparent margin and
|
|
389
|
+
* open a hairline gap between neighbours at zero spacing.
|
|
390
|
+
*/
|
|
391
|
+
interface TileDrawSize {
|
|
392
|
+
width: number;
|
|
393
|
+
height: number;
|
|
394
|
+
}
|
|
359
395
|
/**
|
|
360
396
|
* Pure tile geometry: where each tile centre lands and how much it is rotated,
|
|
361
397
|
* for a config + target/base size. Covers every corner of the target from the
|
|
@@ -369,8 +405,12 @@ declare function computeTilePositions(config: PatternConfig, targetW: number, ta
|
|
|
369
405
|
* Draw the tiled pattern onto a 2D context, in target coordinates (0,0 = the
|
|
370
406
|
* target's top-left corner). The geometry lives in {@link computeTilePositions};
|
|
371
407
|
* this just plays it out as canvas calls.
|
|
408
|
+
*
|
|
409
|
+
* `baseW`/`baseH` are the grid STEP. `draw` is the size the bitmap is painted at
|
|
410
|
+
* and defaults to the step — pass it when the bitmap carries padding the step
|
|
411
|
+
* does not (see {@link TileDrawSize}), so the artwork still lands step-sized.
|
|
372
412
|
*/
|
|
373
|
-
declare function drawTiles(ctx: CanvasRenderingProtocol, img: CanvasImageSource, config: PatternConfig, targetW: number, targetH: number, baseW: number, baseH: number, origin?: PatternOrigin): void;
|
|
413
|
+
declare function drawTiles(ctx: CanvasRenderingProtocol, img: CanvasImageSource, config: PatternConfig, targetW: number, targetH: number, baseW: number, baseH: number, origin?: PatternOrigin, draw?: TileDrawSize): void;
|
|
374
414
|
/** Minimal 2D-context surface used by {@link drawTiles}; lets tests inject a spy. */
|
|
375
415
|
interface CanvasRenderingProtocol {
|
|
376
416
|
save(): void;
|
|
@@ -1175,4 +1215,4 @@ declare class AnnotationOverlay {
|
|
|
1175
1215
|
*/
|
|
1176
1216
|
declare function displaceRgba(source: Uint8ClampedArray, map: Uint8ClampedArray, width: number, height: number, options: Omit<MockupDisplacement, 'image'>): Uint8ClampedArray;
|
|
1177
1217
|
|
|
1178
|
-
export { type AddMaskOptions, AnnotationOverlay, type AnnotationPrimitive, BackgroundImageOptions, CANVAS_MASK_TARGET, CANVAS_SIZE_PRESETS, CanvasEditor, type CanvasRenderingProtocol, CanvasSizePreset, type CoverPlacement, CropController, DEFAULT_LAYER_SHADOW, DEFAULT_SELECTION_STYLE, DEFAULT_TEXT_CURVE, DpiIssue, EditorConfig, EditorEvents, EditorState, EventEmitter, FileAdapter, FontDefinition, FontRegistry, HistoryManager, ImageAdjustments, ImageProvider, ImageProviderResult, ImageSearchOptions, ImageSearchResult, Layer, LayerData, LayerManager, LayerMaskEntry, LayerMaskManager, LayerMaskMode, LayerMeta, LayerShadowConfig, LayerType, LicenseConfig, LicenseManager, LicenseStatus, MaskBrushOptions, MaskController, type MaskPerformanceSample, MaskPoint, MaskPresetId, MaskPresetManager, MaskRefinementError, type MaskRefinementErrorCode, MaskRefinementPrompt, MaskRefinementProvider, MaskRefinementResult, MockupConfig, MockupDisplacement, MockupPrintArea, NormalizedLayerPosition, PatternConfig, PatternLocks, PatternManager, type PatternOrigin, type PngExportOptions, PositioningAdapter, PrintifyPositioning, ProjectManager, ProjectState, ResizeOptions, SHAPE_MASK_BOX, SHAPE_MASK_IDS, type SelectionStyle, SemanticExportOptions, SerializedBackgroundImageOptions, SerializedLayer, ShapeMaskPresetId, ShapePlugin, SnapManager, SvgExportOptions, TEXTURE_MASK_IDS, TEXTURE_MASK_SIZE, TemplateDefinition, TextCurveConfig, TextCurveManager, TextureMaskPresetId, type TilePlacement, TiledPatternObject, Unit, UnitConverter, type ViewportTransform, applyAspectLock, applyLayerShadow, applyObjectSelectionStyle, applySelectionStyle, buildCurvePathData, clamp, clearTextureMaskCache, composeMaskGroup, computeCoverPlacement, computePrintAreaClip, computeTilePositions, deserializeEditor, displaceRgba, drawTiles, escapeXml, exportDataURL, exportMockup, exportPNG, exportPrintArea, exportSVG, fitToBox, generateId, isCssColor, isMaskPresetId, isShapeMaskId, isTextureMaskId, needsAbsoluteSpace, readLayerShadow, renderTextureMask, resetTransform, restoreLocks, round2, sanitizeSvg, serializeEditor, shapeMaskPathData, toCanvasSpace, toHostSpace, unwrapGroup };
|
|
1218
|
+
export { type AddMaskOptions, AnnotationOverlay, type AnnotationPrimitive, BackgroundImageOptions, CANVAS_MASK_TARGET, CANVAS_SIZE_PRESETS, CanvasEditor, type CanvasRenderingProtocol, CanvasSizePreset, type CoverPlacement, CropController, DEFAULT_LAYER_SHADOW, DEFAULT_SELECTION_STYLE, DEFAULT_TEXT_CURVE, DpiIssue, EditorConfig, EditorEvents, EditorState, EventEmitter, FileAdapter, FontDefinition, FontRegistry, HistoryManager, ImageAdjustments, ImageProvider, ImageProviderResult, ImageSearchOptions, ImageSearchResult, Layer, LayerData, LayerManager, LayerMaskEntry, LayerMaskManager, LayerMaskMode, LayerMeta, LayerShadowConfig, LayerType, LicenseConfig, LicenseManager, LicenseStatus, MaskBrushOptions, MaskController, type MaskPerformanceSample, MaskPoint, MaskPresetId, MaskPresetManager, MaskRefinementError, type MaskRefinementErrorCode, MaskRefinementPrompt, MaskRefinementProvider, MaskRefinementResult, MockupConfig, MockupDisplacement, MockupPrintArea, NormalizedLayerPosition, PatternConfig, PatternLocks, PatternManager, type PatternOrigin, type PngExportOptions, PositioningAdapter, PrintifyPositioning, ProjectManager, ProjectState, ResizeOptions, SHAPE_MASK_BOX, SHAPE_MASK_IDS, type SelectionStyle, SemanticExportOptions, SerializedBackgroundImageOptions, SerializedLayer, ShapeMaskPresetId, ShapePlugin, SnapManager, SvgExportOptions, TEXTURE_MASK_IDS, TEXTURE_MASK_SIZE, TemplateDefinition, TextCurveConfig, TextCurveManager, TextureMaskPresetId, type TileDrawSize, type TilePlacement, TiledPatternObject, Unit, UnitConverter, type ViewportTransform, applyAspectLock, applyLayerShadow, applyObjectSelectionStyle, applySelectionStyle, buildCurvePathData, clamp, clearTextureMaskCache, composeMaskGroup, computeCoverPlacement, computePrintAreaClip, computeTilePositions, deserializeEditor, displaceRgba, drawTiles, escapeXml, exportDataURL, exportMockup, exportPNG, exportPrintArea, exportSVG, fitToBox, generateId, isCssColor, isMaskPresetId, isShapeMaskId, isTextureMaskId, needsAbsoluteSpace, readLayerShadow, renderTextureMask, resetTransform, restoreLocks, round2, sanitizeSvg, serializeEditor, shapeMaskPathData, toCanvasSpace, toHostSpace, unwrapGroup };
|
package/dist/index.d.ts
CHANGED
|
@@ -323,8 +323,32 @@ declare class TiledPatternObject extends FabricObject {
|
|
|
323
323
|
* tiling. The copy shares the source (it only ever reads from it).
|
|
324
324
|
*/
|
|
325
325
|
clone(): Promise<this>;
|
|
326
|
+
/**
|
|
327
|
+
* The source's tile footprint: its bounding box, minus a stroke it reserves
|
|
328
|
+
* room for but never paints.
|
|
329
|
+
*
|
|
330
|
+
* fabric keeps `strokeWidth` inside an object's box whether or not a `stroke`
|
|
331
|
+
* colour paints it, and the built-in shapes arrive with `strokeWidth: 1` and no
|
|
332
|
+
* stroke. Stepping the grid by that box puts a transparent seam between every
|
|
333
|
+
* pair of neighbours at zero spacing: the artwork is a pixel narrower than the
|
|
334
|
+
* box it is stepped by.
|
|
335
|
+
*/
|
|
336
|
+
private sourceBox;
|
|
326
337
|
/** The source's on-canvas width, before the tile scale. */
|
|
327
338
|
private baseW;
|
|
339
|
+
/** The source's on-canvas height, before the tile scale. */
|
|
340
|
+
private baseH;
|
|
341
|
+
/**
|
|
342
|
+
* Size to paint the snapshot at, for a tile of `tileW × tileH`.
|
|
343
|
+
*
|
|
344
|
+
* The snapshot is NOT exactly the source's box: `toCanvasElement` rounds the
|
|
345
|
+
* raster up to whole pixels and pads it further for a shadow. Painting it into
|
|
346
|
+
* the tile step would squeeze the artwork inside that padding — every tile
|
|
347
|
+
* shrinks by up to a pixel and the grid shows transparent seams at zero
|
|
348
|
+
* spacing. So the bitmap is painted at its own footprint, scaled by the same
|
|
349
|
+
* factor the tile is, and the step stays the source's box.
|
|
350
|
+
*/
|
|
351
|
+
private drawSize;
|
|
328
352
|
/** Tile size from the config alone, ignoring any in-flight gesture. */
|
|
329
353
|
private baseTile;
|
|
330
354
|
/** Tile size as drawn right now, including a live scale gesture. */
|
|
@@ -356,6 +380,18 @@ interface PatternOrigin {
|
|
|
356
380
|
x: number;
|
|
357
381
|
y: number;
|
|
358
382
|
}
|
|
383
|
+
/**
|
|
384
|
+
* Size the tile bitmap is painted at, when that differs from the grid step.
|
|
385
|
+
*
|
|
386
|
+
* A snapshot of the source is not always exactly the source's box: the raster is
|
|
387
|
+
* allocated in whole pixels, and a shadow pads it further. Painting such a bitmap
|
|
388
|
+
* into the step would shrink the artwork inside its own transparent margin and
|
|
389
|
+
* open a hairline gap between neighbours at zero spacing.
|
|
390
|
+
*/
|
|
391
|
+
interface TileDrawSize {
|
|
392
|
+
width: number;
|
|
393
|
+
height: number;
|
|
394
|
+
}
|
|
359
395
|
/**
|
|
360
396
|
* Pure tile geometry: where each tile centre lands and how much it is rotated,
|
|
361
397
|
* for a config + target/base size. Covers every corner of the target from the
|
|
@@ -369,8 +405,12 @@ declare function computeTilePositions(config: PatternConfig, targetW: number, ta
|
|
|
369
405
|
* Draw the tiled pattern onto a 2D context, in target coordinates (0,0 = the
|
|
370
406
|
* target's top-left corner). The geometry lives in {@link computeTilePositions};
|
|
371
407
|
* this just plays it out as canvas calls.
|
|
408
|
+
*
|
|
409
|
+
* `baseW`/`baseH` are the grid STEP. `draw` is the size the bitmap is painted at
|
|
410
|
+
* and defaults to the step — pass it when the bitmap carries padding the step
|
|
411
|
+
* does not (see {@link TileDrawSize}), so the artwork still lands step-sized.
|
|
372
412
|
*/
|
|
373
|
-
declare function drawTiles(ctx: CanvasRenderingProtocol, img: CanvasImageSource, config: PatternConfig, targetW: number, targetH: number, baseW: number, baseH: number, origin?: PatternOrigin): void;
|
|
413
|
+
declare function drawTiles(ctx: CanvasRenderingProtocol, img: CanvasImageSource, config: PatternConfig, targetW: number, targetH: number, baseW: number, baseH: number, origin?: PatternOrigin, draw?: TileDrawSize): void;
|
|
374
414
|
/** Minimal 2D-context surface used by {@link drawTiles}; lets tests inject a spy. */
|
|
375
415
|
interface CanvasRenderingProtocol {
|
|
376
416
|
save(): void;
|
|
@@ -1175,4 +1215,4 @@ declare class AnnotationOverlay {
|
|
|
1175
1215
|
*/
|
|
1176
1216
|
declare function displaceRgba(source: Uint8ClampedArray, map: Uint8ClampedArray, width: number, height: number, options: Omit<MockupDisplacement, 'image'>): Uint8ClampedArray;
|
|
1177
1217
|
|
|
1178
|
-
export { type AddMaskOptions, AnnotationOverlay, type AnnotationPrimitive, BackgroundImageOptions, CANVAS_MASK_TARGET, CANVAS_SIZE_PRESETS, CanvasEditor, type CanvasRenderingProtocol, CanvasSizePreset, type CoverPlacement, CropController, DEFAULT_LAYER_SHADOW, DEFAULT_SELECTION_STYLE, DEFAULT_TEXT_CURVE, DpiIssue, EditorConfig, EditorEvents, EditorState, EventEmitter, FileAdapter, FontDefinition, FontRegistry, HistoryManager, ImageAdjustments, ImageProvider, ImageProviderResult, ImageSearchOptions, ImageSearchResult, Layer, LayerData, LayerManager, LayerMaskEntry, LayerMaskManager, LayerMaskMode, LayerMeta, LayerShadowConfig, LayerType, LicenseConfig, LicenseManager, LicenseStatus, MaskBrushOptions, MaskController, type MaskPerformanceSample, MaskPoint, MaskPresetId, MaskPresetManager, MaskRefinementError, type MaskRefinementErrorCode, MaskRefinementPrompt, MaskRefinementProvider, MaskRefinementResult, MockupConfig, MockupDisplacement, MockupPrintArea, NormalizedLayerPosition, PatternConfig, PatternLocks, PatternManager, type PatternOrigin, type PngExportOptions, PositioningAdapter, PrintifyPositioning, ProjectManager, ProjectState, ResizeOptions, SHAPE_MASK_BOX, SHAPE_MASK_IDS, type SelectionStyle, SemanticExportOptions, SerializedBackgroundImageOptions, SerializedLayer, ShapeMaskPresetId, ShapePlugin, SnapManager, SvgExportOptions, TEXTURE_MASK_IDS, TEXTURE_MASK_SIZE, TemplateDefinition, TextCurveConfig, TextCurveManager, TextureMaskPresetId, type TilePlacement, TiledPatternObject, Unit, UnitConverter, type ViewportTransform, applyAspectLock, applyLayerShadow, applyObjectSelectionStyle, applySelectionStyle, buildCurvePathData, clamp, clearTextureMaskCache, composeMaskGroup, computeCoverPlacement, computePrintAreaClip, computeTilePositions, deserializeEditor, displaceRgba, drawTiles, escapeXml, exportDataURL, exportMockup, exportPNG, exportPrintArea, exportSVG, fitToBox, generateId, isCssColor, isMaskPresetId, isShapeMaskId, isTextureMaskId, needsAbsoluteSpace, readLayerShadow, renderTextureMask, resetTransform, restoreLocks, round2, sanitizeSvg, serializeEditor, shapeMaskPathData, toCanvasSpace, toHostSpace, unwrapGroup };
|
|
1218
|
+
export { type AddMaskOptions, AnnotationOverlay, type AnnotationPrimitive, BackgroundImageOptions, CANVAS_MASK_TARGET, CANVAS_SIZE_PRESETS, CanvasEditor, type CanvasRenderingProtocol, CanvasSizePreset, type CoverPlacement, CropController, DEFAULT_LAYER_SHADOW, DEFAULT_SELECTION_STYLE, DEFAULT_TEXT_CURVE, DpiIssue, EditorConfig, EditorEvents, EditorState, EventEmitter, FileAdapter, FontDefinition, FontRegistry, HistoryManager, ImageAdjustments, ImageProvider, ImageProviderResult, ImageSearchOptions, ImageSearchResult, Layer, LayerData, LayerManager, LayerMaskEntry, LayerMaskManager, LayerMaskMode, LayerMeta, LayerShadowConfig, LayerType, LicenseConfig, LicenseManager, LicenseStatus, MaskBrushOptions, MaskController, type MaskPerformanceSample, MaskPoint, MaskPresetId, MaskPresetManager, MaskRefinementError, type MaskRefinementErrorCode, MaskRefinementPrompt, MaskRefinementProvider, MaskRefinementResult, MockupConfig, MockupDisplacement, MockupPrintArea, NormalizedLayerPosition, PatternConfig, PatternLocks, PatternManager, type PatternOrigin, type PngExportOptions, PositioningAdapter, PrintifyPositioning, ProjectManager, ProjectState, ResizeOptions, SHAPE_MASK_BOX, SHAPE_MASK_IDS, type SelectionStyle, SemanticExportOptions, SerializedBackgroundImageOptions, SerializedLayer, ShapeMaskPresetId, ShapePlugin, SnapManager, SvgExportOptions, TEXTURE_MASK_IDS, TEXTURE_MASK_SIZE, TemplateDefinition, TextCurveConfig, TextCurveManager, TextureMaskPresetId, type TileDrawSize, type TilePlacement, TiledPatternObject, Unit, UnitConverter, type ViewportTransform, applyAspectLock, applyLayerShadow, applyObjectSelectionStyle, applySelectionStyle, buildCurvePathData, clamp, clearTextureMaskCache, composeMaskGroup, computeCoverPlacement, computePrintAreaClip, computeTilePositions, deserializeEditor, displaceRgba, drawTiles, escapeXml, exportDataURL, exportMockup, exportPNG, exportPrintArea, exportSVG, fitToBox, generateId, isCssColor, isMaskPresetId, isShapeMaskId, isTextureMaskId, needsAbsoluteSpace, readLayerShadow, renderTextureMask, resetTransform, restoreLocks, round2, sanitizeSvg, serializeEditor, shapeMaskPathData, toCanvasSpace, toHostSpace, unwrapGroup };
|