@gradio/imageeditor 0.12.13 → 0.13.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.
Files changed (130) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/Example.svelte +1 -1
  3. package/IMAGE_EDITOR_OVERVIEW.md +224 -0
  4. package/ImageEditor.stories.svelte +4 -4
  5. package/Index.svelte +35 -46
  6. package/{shared/InteractiveImageEditor.svelte → InteractiveImageEditor.svelte} +56 -103
  7. package/dist/Example.svelte.d.ts +1 -1
  8. package/dist/Index.svelte +29 -33
  9. package/dist/Index.svelte.d.ts +17 -16
  10. package/dist/{shared/InteractiveImageEditor.svelte → InteractiveImageEditor.svelte} +47 -88
  11. package/dist/{shared/InteractiveImageEditor.svelte.d.ts → InteractiveImageEditor.svelte.d.ts} +13 -15
  12. package/dist/shared/Anchor.svelte +311 -0
  13. package/dist/shared/Anchor.svelte.d.ts +18 -0
  14. package/dist/shared/Controls.svelte +162 -23
  15. package/dist/shared/Controls.svelte.d.ts +7 -2
  16. package/dist/shared/{tools/IconButton.svelte → IconButton.svelte} +19 -3
  17. package/dist/shared/{tools/IconButton.svelte.d.ts → IconButton.svelte.d.ts} +4 -1
  18. package/dist/shared/ImageEditor.svelte +546 -289
  19. package/dist/shared/ImageEditor.svelte.d.ts +51 -56
  20. package/dist/shared/Layers.svelte +233 -0
  21. package/dist/shared/Layers.svelte.d.ts +35 -0
  22. package/dist/shared/Resize.svelte +218 -0
  23. package/dist/shared/Resize.svelte.d.ts +29 -0
  24. package/dist/shared/SecondaryToolbar.svelte +54 -0
  25. package/dist/shared/SecondaryToolbar.svelte.d.ts +35 -0
  26. package/dist/shared/Toolbar.svelte +337 -0
  27. package/dist/shared/Toolbar.svelte.d.ts +42 -0
  28. package/dist/shared/{tools → brush}/BrushOptions.svelte +68 -64
  29. package/dist/shared/{tools → brush}/BrushOptions.svelte.d.ts +9 -9
  30. package/dist/shared/{tools → brush}/BrushSize.svelte +2 -27
  31. package/dist/shared/{tools → brush}/ColorField.svelte +2 -1
  32. package/dist/shared/{tools → brush}/ColorField.svelte.d.ts +1 -0
  33. package/dist/shared/{tools → brush}/ColorPicker.svelte +81 -9
  34. package/dist/shared/{tools → brush}/ColorPicker.svelte.d.ts +1 -0
  35. package/dist/shared/{tools → brush}/ColorSwatch.svelte +78 -38
  36. package/dist/shared/{tools → brush}/ColorSwatch.svelte.d.ts +6 -2
  37. package/dist/shared/brush/brush-cursor.d.ts +101 -0
  38. package/dist/shared/brush/brush-cursor.js +327 -0
  39. package/dist/shared/brush/brush-textures.d.ts +71 -0
  40. package/dist/shared/brush/brush-textures.js +404 -0
  41. package/dist/shared/brush/brush-utils.d.ts +32 -0
  42. package/dist/shared/brush/brush-utils.js +59 -0
  43. package/dist/shared/brush/brush.d.ts +152 -0
  44. package/dist/shared/brush/brush.js +396 -0
  45. package/dist/shared/brush/types.d.ts +37 -0
  46. package/dist/shared/brush/types.js +1 -0
  47. package/dist/shared/core/editor.d.ts +252 -0
  48. package/dist/shared/core/editor.js +1221 -0
  49. package/dist/shared/crop/crop.d.ts +201 -0
  50. package/dist/shared/crop/crop.js +727 -0
  51. package/dist/shared/image/image.d.ts +89 -0
  52. package/dist/shared/image/image.js +185 -0
  53. package/dist/shared/resize/resize.d.ts +270 -0
  54. package/dist/shared/resize/resize.js +1413 -0
  55. package/dist/shared/types.d.ts +12 -0
  56. package/dist/shared/utils/pixi.d.ts +16 -57
  57. package/dist/shared/utils/pixi.js +15 -113
  58. package/dist/shared/zoom/zoom.d.ts +136 -0
  59. package/dist/shared/zoom/zoom.js +548 -0
  60. package/package.json +11 -10
  61. package/shared/Anchor.svelte +384 -0
  62. package/shared/Controls.svelte +194 -27
  63. package/shared/{tools/IconButton.svelte → IconButton.svelte} +21 -4
  64. package/shared/ImageEditor.svelte +682 -349
  65. package/shared/Layers.svelte +249 -0
  66. package/shared/Resize.svelte +239 -0
  67. package/shared/SecondaryToolbar.svelte +61 -0
  68. package/shared/Toolbar.svelte +386 -0
  69. package/shared/brush/BRUSH_TOOL.md +134 -0
  70. package/shared/brush/BrushOptions.svelte +200 -0
  71. package/shared/{tools → brush}/BrushSize.svelte +2 -30
  72. package/shared/{tools → brush}/ColorField.svelte +3 -1
  73. package/shared/{tools → brush}/ColorPicker.svelte +86 -9
  74. package/shared/{tools → brush}/ColorSwatch.svelte +95 -42
  75. package/shared/brush/brush-cursor.ts +408 -0
  76. package/shared/brush/brush-textures.ts +508 -0
  77. package/shared/brush/brush-utils.ts +76 -0
  78. package/shared/brush/brush.ts +506 -0
  79. package/shared/brush/types.ts +41 -0
  80. package/shared/core/EDITOR.md +182 -0
  81. package/shared/core/editor.ts +1730 -0
  82. package/shared/crop/CROP.md +139 -0
  83. package/shared/crop/crop.ts +1027 -0
  84. package/shared/image/IMAGE.md +135 -0
  85. package/shared/image/image.ts +300 -0
  86. package/shared/resize/resize.ts +1894 -0
  87. package/shared/types.ts +14 -0
  88. package/shared/utils/pixi.ts +19 -246
  89. package/shared/zoom/zoom.ts +729 -0
  90. package/dist/shared/layers/Layers.svelte +0 -231
  91. package/dist/shared/layers/Layers.svelte.d.ts +0 -18
  92. package/dist/shared/layers/utils.d.ts +0 -73
  93. package/dist/shared/layers/utils.js +0 -156
  94. package/dist/shared/tools/Brush.svelte +0 -215
  95. package/dist/shared/tools/Brush.svelte.d.ts +0 -29
  96. package/dist/shared/tools/Crop.svelte +0 -155
  97. package/dist/shared/tools/Crop.svelte.d.ts +0 -16
  98. package/dist/shared/tools/Cropper.svelte +0 -271
  99. package/dist/shared/tools/Cropper.svelte.d.ts +0 -41
  100. package/dist/shared/tools/Handle.svelte +0 -260
  101. package/dist/shared/tools/Handle.svelte.d.ts +0 -29
  102. package/dist/shared/tools/Sources.svelte +0 -257
  103. package/dist/shared/tools/Sources.svelte.d.ts +0 -34
  104. package/dist/shared/tools/Tools.svelte +0 -102
  105. package/dist/shared/tools/Tools.svelte.d.ts +0 -48
  106. package/dist/shared/tools/brush.d.ts +0 -62
  107. package/dist/shared/tools/brush.js +0 -133
  108. package/dist/shared/tools/crop.d.ts +0 -15
  109. package/dist/shared/tools/crop.js +0 -154
  110. package/dist/shared/tools/index.d.ts +0 -5
  111. package/dist/shared/tools/index.js +0 -5
  112. package/dist/shared/tools/sources.d.ts +0 -46
  113. package/dist/shared/tools/sources.js +0 -121
  114. package/dist/shared/tools/types.d.ts +0 -1
  115. package/shared/layers/Layers.svelte +0 -250
  116. package/shared/layers/utils.ts +0 -294
  117. package/shared/tools/Brush.svelte +0 -280
  118. package/shared/tools/BrushOptions.svelte +0 -180
  119. package/shared/tools/Crop.svelte +0 -189
  120. package/shared/tools/Cropper.svelte +0 -346
  121. package/shared/tools/Handle.svelte +0 -289
  122. package/shared/tools/Sources.svelte +0 -283
  123. package/shared/tools/Tools.svelte +0 -162
  124. package/shared/tools/brush.ts +0 -247
  125. package/shared/tools/crop.ts +0 -213
  126. package/shared/tools/index.ts +0 -5
  127. package/shared/tools/sources.ts +0 -195
  128. package/shared/tools/types.ts +0 -1
  129. /package/dist/shared/{tools → brush}/BrushSize.svelte.d.ts +0 -0
  130. /package/dist/shared/{tools/types.js → types.js} +0 -0
@@ -0,0 +1,89 @@
1
+ import { Container, type ColorSource, Sprite, type Renderer, Texture } from "pixi.js";
2
+ import { type ImageEditorContext, type Tool } from "../core/editor";
3
+ import { type Tool as ToolbarTool, type Subtool } from "../Toolbar.svelte";
4
+ import { type Command } from "../utils/commands";
5
+ /**
6
+ * Handles adding images to the editor
7
+ * Only a single image can be added at a time
8
+ * Adding an image removes the current image is one exists
9
+ */
10
+ export declare class ImageTool implements Tool {
11
+ name: string;
12
+ context: ImageEditorContext;
13
+ current_tool: ToolbarTool;
14
+ current_subtool: Subtool;
15
+ setup(context: ImageEditorContext, tool: ToolbarTool, subtool: Subtool): Promise<void>;
16
+ cleanup(): void;
17
+ add_image({ image, fixed_canvas, border_region }: {
18
+ image: Blob | File | Texture;
19
+ fixed_canvas: boolean;
20
+ border_region?: number;
21
+ }): Promise<void>;
22
+ set_tool(tool: ToolbarTool, subtool: Subtool): void;
23
+ }
24
+ interface BgImageCommand extends Command {
25
+ /**
26
+ * Initial setup for the bg command
27
+ * @returns
28
+ */
29
+ start: () => Promise<[number, number]>;
30
+ }
31
+ export declare class AddImageCommand implements BgImageCommand {
32
+ sprite: Sprite;
33
+ fixed_canvas: boolean;
34
+ context: ImageEditorContext;
35
+ background: Blob | File | Texture;
36
+ current_canvas_size: {
37
+ width: number;
38
+ height: number;
39
+ };
40
+ current_scale: number;
41
+ current_position: {
42
+ x: number;
43
+ y: number;
44
+ };
45
+ border_region: number;
46
+ scaled_width: number;
47
+ scaled_height: number;
48
+ constructor(context: ImageEditorContext, background: Blob | File | Texture, fixed_canvas: boolean, border_region?: number);
49
+ start(): Promise<[number, number]>;
50
+ private handle_image;
51
+ execute(): Promise<void>;
52
+ undo(): Promise<void>;
53
+ }
54
+ /**
55
+ * Command that sets a background
56
+ */
57
+ interface BgColorCommand extends Command {
58
+ /**
59
+ * Initial setup for the bg command
60
+ * @returns
61
+ */
62
+ start: () => [number, number];
63
+ }
64
+ /**
65
+ * Adds a background color to the canvas.
66
+ * @param container The container to add the image to.
67
+ * @param renderer The renderer to use for the image.
68
+ * @param color The background color to add.
69
+ * @param width The width of the background.
70
+ * @param height The height of the background.
71
+ * @param resize The function to resize the canvas.
72
+ * @returns A command that can be used to undo the action.
73
+ */
74
+ export declare function add_bg_color(container: Container, renderer: Renderer, color: ColorSource, width: number, height: number, resize: (width: number, height: number) => void): BgColorCommand;
75
+ /**
76
+ * Calculates new dimensions and position for an image to fit within a canvas while maintaining aspect ratio
77
+ * @param image_width Original width of the image
78
+ * @param image_height Original height of the image
79
+ * @param canvas_width Width of the canvas
80
+ * @param canvas_height Height of the canvas
81
+ * @returns Object containing new dimensions and position
82
+ */
83
+ export declare function fit_image_to_canvas(image_width: number, image_height: number, canvas_width: number, canvas_height: number): {
84
+ width: number;
85
+ height: number;
86
+ x: number;
87
+ y: number;
88
+ };
89
+ export {};
@@ -0,0 +1,185 @@
1
+ import { Container, Graphics, Color, RenderTexture, Sprite, Texture } from "pixi.js";
2
+ import {} from "../core/editor";
3
+ import {} from "../Toolbar.svelte";
4
+ import {} from "../utils/commands";
5
+ import { make_graphics } from "../utils/pixi";
6
+ import { get } from "svelte/store";
7
+ /**
8
+ * Handles adding images to the editor
9
+ * Only a single image can be added at a time
10
+ * Adding an image removes the current image is one exists
11
+ */
12
+ export class ImageTool {
13
+ name = "image";
14
+ context;
15
+ current_tool;
16
+ current_subtool;
17
+ async setup(context, tool, subtool) {
18
+ this.context = context;
19
+ this.current_tool = tool;
20
+ this.current_subtool = subtool;
21
+ }
22
+ cleanup() { }
23
+ async add_image({ image, fixed_canvas, border_region = 0 }) {
24
+ const image_command = new AddImageCommand(this.context, image, fixed_canvas, border_region);
25
+ await image_command.start();
26
+ this.context.execute_command(image_command);
27
+ }
28
+ set_tool(tool, subtool) {
29
+ this.current_tool = tool;
30
+ this.current_subtool = subtool;
31
+ }
32
+ }
33
+ export class AddImageCommand {
34
+ sprite;
35
+ fixed_canvas;
36
+ context;
37
+ background;
38
+ current_canvas_size;
39
+ current_scale;
40
+ current_position;
41
+ border_region;
42
+ scaled_width;
43
+ scaled_height;
44
+ constructor(context, background, fixed_canvas, border_region = 0) {
45
+ this.context = context;
46
+ this.background = background;
47
+ this.fixed_canvas = fixed_canvas;
48
+ this.border_region = border_region;
49
+ this.current_canvas_size = get(this.context.dimensions);
50
+ this.current_scale = get(this.context.scale);
51
+ this.current_position = get(this.context.position);
52
+ this.sprite = new Sprite();
53
+ }
54
+ async start() {
55
+ // Create the sprite from the blob
56
+ let image_texture;
57
+ if (this.background instanceof Texture) {
58
+ image_texture = this.background;
59
+ }
60
+ else {
61
+ const img = await createImageBitmap(this.background);
62
+ image_texture = Texture.from(img);
63
+ }
64
+ this.sprite = new Sprite(image_texture);
65
+ return this.handle_image();
66
+ }
67
+ handle_image() {
68
+ // Handle fixed canvas differently when border region is present
69
+ if (this.fixed_canvas) {
70
+ // Calculate the effective canvas size accounting for border region
71
+ const effectiveCanvasWidth = Math.max(this.current_canvas_size.width - this.border_region * 2, 10);
72
+ const effectiveCanvasHeight = Math.max(this.current_canvas_size.height - this.border_region * 2, 10);
73
+ // Fit the image to the canvas while maintaining aspect ratio
74
+ const { width, height, x, y } = fit_image_to_canvas(this.sprite.width, this.sprite.height, effectiveCanvasWidth, effectiveCanvasHeight);
75
+ this.sprite.width = width;
76
+ this.sprite.height = height;
77
+ // Center the image in the canvas
78
+ this.sprite.x = x + this.border_region;
79
+ this.sprite.y = y + this.border_region;
80
+ }
81
+ else {
82
+ // For non-fixed canvas, use natural dimensions plus border
83
+ const width = this.sprite.width;
84
+ const height = this.sprite.height;
85
+ // Position at the border's offset from origin
86
+ this.sprite.x = this.border_region;
87
+ this.sprite.y = this.border_region;
88
+ return [width + this.border_region * 2, height + this.border_region * 2];
89
+ }
90
+ return [this.current_canvas_size.width, this.current_canvas_size.height];
91
+ }
92
+ async execute() {
93
+ // First ensure we have run start() to create the sprite and get dimensions
94
+ const [width, height] = await this.start();
95
+ // Update image properties with the original dimensions and center in viewport
96
+ this.context.set_image_properties({
97
+ scale: 1, // Start at 1:1 scale
98
+ position: {
99
+ x: this.context.app.screen.width / 2,
100
+ y: this.context.app.screen.height / 2
101
+ },
102
+ width: this.fixed_canvas ? this.current_canvas_size.width : width,
103
+ height: this.fixed_canvas ? this.current_canvas_size.height : height
104
+ });
105
+ // Create new background layer and add the sprite
106
+ const background_layer = this.context.layer_manager.create_background_layer(this.fixed_canvas ? this.current_canvas_size.width : width, this.fixed_canvas ? this.current_canvas_size.height : height);
107
+ this.sprite.zIndex = 0;
108
+ background_layer.addChild(this.sprite);
109
+ // Resize and preserve content of existing layers
110
+ this.context.layer_manager.reset_layers(this.fixed_canvas ? this.current_canvas_size.width : width, this.fixed_canvas ? this.current_canvas_size.height : height, true);
111
+ this.context.set_background_image(this.sprite);
112
+ this.context.reset();
113
+ }
114
+ async undo() {
115
+ if (this.sprite) {
116
+ this.sprite.destroy();
117
+ }
118
+ // The background layer will be automatically cleaned up when a new image is added
119
+ }
120
+ }
121
+ /**
122
+ * Adds a background color to the canvas.
123
+ * @param container The container to add the image to.
124
+ * @param renderer The renderer to use for the image.
125
+ * @param color The background color to add.
126
+ * @param width The width of the background.
127
+ * @param height The height of the background.
128
+ * @param resize The function to resize the canvas.
129
+ * @returns A command that can be used to undo the action.
130
+ */
131
+ export function add_bg_color(container, renderer, color, width, height, resize) {
132
+ let sprite;
133
+ return {
134
+ start() {
135
+ container.removeChildren();
136
+ const graphics = make_graphics(1);
137
+ const texture = RenderTexture.create({
138
+ width,
139
+ height
140
+ });
141
+ renderer.render(graphics, { renderTexture: texture });
142
+ sprite = new Sprite(texture);
143
+ return [sprite.width, sprite.height];
144
+ },
145
+ async execute() {
146
+ resize(sprite.width, sprite.height);
147
+ sprite.zIndex = 1;
148
+ container.addChild(sprite);
149
+ },
150
+ undo() {
151
+ container.removeChildren();
152
+ }
153
+ };
154
+ }
155
+ /**
156
+ * Calculates new dimensions and position for an image to fit within a canvas while maintaining aspect ratio
157
+ * @param image_width Original width of the image
158
+ * @param image_height Original height of the image
159
+ * @param canvas_width Width of the canvas
160
+ * @param canvas_height Height of the canvas
161
+ * @returns Object containing new dimensions and position
162
+ */
163
+ export function fit_image_to_canvas(image_width, image_height, canvas_width, canvas_height) {
164
+ const image_aspect_ratio = image_width / image_height;
165
+ const canvas_aspect_ratio = canvas_width / canvas_height;
166
+ let new_width;
167
+ let new_height;
168
+ if (image_aspect_ratio > canvas_aspect_ratio) {
169
+ new_width = canvas_width;
170
+ new_height = canvas_width / image_aspect_ratio;
171
+ }
172
+ else {
173
+ new_height = canvas_height;
174
+ new_width = canvas_height * image_aspect_ratio;
175
+ }
176
+ // center image
177
+ const x = Math.round((canvas_width - new_width) / 2);
178
+ const y = Math.round((canvas_height - new_height) / 2);
179
+ return {
180
+ width: Math.round(new_width),
181
+ height: Math.round(new_height),
182
+ x,
183
+ y
184
+ };
185
+ }
@@ -0,0 +1,270 @@
1
+ import { type ImageEditorContext, type Tool } from "../core/editor";
2
+ import { type Tool as ToolbarTool, type Subtool } from "../Toolbar.svelte";
3
+ /**
4
+ * @class ResizeTool
5
+ * @implements {Tool}
6
+ * @description Implements the resize tool functionality for the image editor
7
+ */
8
+ export declare class ResizeTool implements Tool {
9
+ name: "resize";
10
+ private image_editor_context;
11
+ current_tool: ToolbarTool;
12
+ current_subtool: Subtool;
13
+ private current_cursor;
14
+ private readonly CORNER_SIZE;
15
+ private readonly LINE_THICKNESS;
16
+ private readonly HANDLE_COLOR;
17
+ private readonly HIT_AREA_SIZE;
18
+ private borderRegion;
19
+ private is_dragging;
20
+ private selected_handle;
21
+ private active_corner_index;
22
+ private active_edge_index;
23
+ private last_pointer_position;
24
+ private resize_ui_container;
25
+ private dimensions;
26
+ private position;
27
+ private scale;
28
+ private is_moving;
29
+ private dom_mousedown_handler;
30
+ private dom_mousemove_handler;
31
+ private dom_mouseup_handler;
32
+ private event_callbacks;
33
+ private last_scale;
34
+ /**
35
+ * @method setup
36
+ * @async
37
+ * @description Sets up the resize tool with the given context and tool/subtool
38
+ * @param {ImageEditorContext} context - The image editor context
39
+ * @param {ToolbarTool} tool - The current tool
40
+ * @param {Subtool} subtool - The current subtool
41
+ * @returns {Promise<void>}
42
+ */
43
+ setup(context: ImageEditorContext, tool: ToolbarTool, subtool: Subtool): Promise<void>;
44
+ /**
45
+ * @method cleanup
46
+ * @description Cleans up the resize tool resources and removes event listeners
47
+ * @returns {void}
48
+ */
49
+ cleanup(): void;
50
+ /**
51
+ * @method set_tool
52
+ * @description Sets the current tool and subtool, updating UI visibility
53
+ * @param {ToolbarTool} tool - The tool to set
54
+ * @param {Subtool} subtool - The subtool to set
55
+ * @returns {void}
56
+ */
57
+ set_tool(tool: ToolbarTool, subtool: Subtool): void;
58
+ /**
59
+ * @method init_resize_ui
60
+ * @private
61
+ * @async
62
+ * @description Initializes the resize UI elements and sets up the update loop
63
+ * @returns {Promise<void>}
64
+ */
65
+ private init_resize_ui;
66
+ /**
67
+ * @method make_resize_ui
68
+ * @private
69
+ * @description Creates the resize UI with the specified dimensions
70
+ * @param {number} width - Width of the resize area
71
+ * @param {number} height - Height of the resize area
72
+ * @returns {Container} The created resize UI container
73
+ */
74
+ private make_resize_ui;
75
+ /**
76
+ * @method create_handle
77
+ * @private
78
+ * @description Creates a handle for the resize UI
79
+ * @param {boolean} [is_edge=false] - Whether the handle is an edge handle
80
+ * @returns {Container} The created handle container
81
+ */
82
+ private create_handle;
83
+ /**
84
+ * @method create_edge_handles
85
+ * @private
86
+ * @description Creates edge handles for the resize UI
87
+ * @param {Container} container - The container to add handles to
88
+ * @param {number} width - Width of the resize area
89
+ * @param {number} height - Height of the resize area
90
+ * @returns {void}
91
+ */
92
+ private create_edge_handles;
93
+ /**
94
+ * @method create_corner_handles
95
+ * @private
96
+ * @description Creates corner handles for the resize UI
97
+ * @param {Container} container - The container to add handles to
98
+ * @param {number} width - Width of the resize area
99
+ * @param {number} height - Height of the resize area
100
+ * @returns {void}
101
+ */
102
+ private create_corner_handles;
103
+ /**
104
+ * @method handle_pointer_down
105
+ * @private
106
+ * @description Handles pointer down events on handles
107
+ * @param {FederatedPointerEvent} event - The pointer event
108
+ * @param {Container} handle - The handle that was clicked
109
+ * @param {number} corner_index - Index of the corner (-1 if not a corner)
110
+ * @param {number} edge_index - Index of the edge (-1 if not an edge)
111
+ * @returns {void}
112
+ */
113
+ private handle_pointer_down;
114
+ /**
115
+ * Maintains aspect ratio during resizing
116
+ * @param new_width - The new width
117
+ * @param new_height - The new height
118
+ * @param original_aspect_ratio - The original aspect ratio
119
+ * @param delta - The delta to apply
120
+ * @returns The adjusted dimensions
121
+ */
122
+ private maintain_aspect_ratio;
123
+ /**
124
+ * Limits dimensions based on constraints
125
+ * @param width - The width to limit
126
+ * @param height - The height to limit
127
+ * @param maintain_aspect_ratio - Whether to maintain aspect ratio
128
+ * @returns The limited dimensions
129
+ */
130
+ private limit_dimensions;
131
+ /**
132
+ * Calculates position deltas based on dimension changes
133
+ * @param old_width - The original width
134
+ * @param old_height - The original height
135
+ * @param new_width - The new width
136
+ * @param new_height - The new height
137
+ * @returns Object containing x and y position deltas
138
+ */
139
+ private calculate_position_deltas;
140
+ /**
141
+ * Applies boundary constraints to keep the image within the container
142
+ * @private
143
+ */
144
+ private apply_boundary_constraints;
145
+ /**
146
+ * Updates the resize bounds based on the delta
147
+ * @param delta - The delta to apply
148
+ * @param maintain_aspect_ratio - Whether to maintain the aspect ratio
149
+ */
150
+ private update_resize_bounds;
151
+ /**
152
+ * updates the resize ui position and dimensions
153
+ */
154
+ private update_resize_ui;
155
+ /**
156
+ * updates the positions of all handles
157
+ * @param width - width of the resize area
158
+ * @param height - height of the resize area
159
+ */
160
+ private update_handle_positions;
161
+ /**
162
+ * sets up event listeners for the resize tool
163
+ */
164
+ private setup_event_listeners;
165
+ /**
166
+ * Sets up direct DOM event listeners for dragging the background image
167
+ */
168
+ private setup_dom_event_listeners;
169
+ /**
170
+ * Cleans up DOM event listeners
171
+ */
172
+ private cleanup_dom_event_listeners;
173
+ /**
174
+ * removes event listeners for the resize tool
175
+ */
176
+ private cleanup_event_listeners;
177
+ /**
178
+ * Handles pointer move events
179
+ */
180
+ private handle_pointer_move;
181
+ /**
182
+ * handles pointer up events
183
+ */
184
+ private handle_pointer_up;
185
+ /**
186
+ * Handles dragging of the background image
187
+ * @param current_position - The current pointer position
188
+ * @private
189
+ */
190
+ private handle_image_dragging;
191
+ /**
192
+ * Handles corner resizing
193
+ * @param current_position - The current mouse position
194
+ * @param original_width - The original width
195
+ * @param original_height - The original height
196
+ * @param original_x - The original x position
197
+ * @param original_y - The original y position
198
+ * @param original_aspect_ratio - The original aspect ratio
199
+ * @param maintain_aspect_ratio - Whether to maintain aspect ratio
200
+ * @returns The new dimensions and position
201
+ * @private
202
+ */
203
+ private handle_direct_corner_resize;
204
+ /**
205
+ * Handles edge resizing
206
+ * @param current_position - The current mouse position
207
+ * @param original_width - The original width
208
+ * @param original_height - The original height
209
+ * @param original_x - The original x position
210
+ * @param original_y - The original y position
211
+ * @returns The new dimensions and position
212
+ * @private
213
+ */
214
+ private handle_direct_edge_resize;
215
+ /**
216
+ * Limits dimensions to container size
217
+ * @param dimensions - The dimensions to limit
218
+ * @param original_x - The original x position
219
+ * @param original_y - The original y position
220
+ * @param original_width - The original width
221
+ * @param original_height - The original height
222
+ * @param maintain_aspect_ratio - Whether to maintain aspect ratio
223
+ * @returns The limited dimensions and position
224
+ * @private
225
+ */
226
+ private limit_dimensions_to_container;
227
+ /**
228
+ * Apply size limits to ensure dimensions don't exceed container
229
+ * @private
230
+ */
231
+ private apply_size_limits;
232
+ /**
233
+ * Adjust position based on which handles are being dragged
234
+ * @private
235
+ */
236
+ private adjust_position_for_resizing;
237
+ /**
238
+ * Apply border region constraints to prevent image from intruding on border
239
+ * @private
240
+ */
241
+ private apply_border_constraints;
242
+ /**
243
+ * Apply top and left border constraints
244
+ * @private
245
+ */
246
+ private apply_top_left_constraints;
247
+ /**
248
+ * Apply bottom and right border constraints
249
+ * @private
250
+ */
251
+ private apply_bottom_right_constraints;
252
+ /**
253
+ * Shows the resize UI
254
+ * @private
255
+ */
256
+ private show_resize_ui;
257
+ /**
258
+ * Hides the resize UI
259
+ * @private
260
+ */
261
+ private hide_resize_ui;
262
+ on<T extends string>(event: T, callback: () => void): void;
263
+ off<T extends string>(event: T, callback: () => void): void;
264
+ private notify;
265
+ /**
266
+ * Sets the border region explicitly
267
+ * @param borderRegion The border region size in pixels
268
+ */
269
+ set_border_region(borderRegion: number): void;
270
+ }