{"version":3,"file":"index-9656e7b9.js","sources":["../../../../js/icons/src/Brush.svelte","../../../../js/icons/src/Color.svelte","../../../../js/icons/src/Erase.svelte","../../../../js/icons/src/Sketch.svelte","../../../../js/image/src/utils.ts","../../../../js/image/src/Cropper.svelte","../../../../node_modules/.pnpm/lazy-brush@1.0.1/node_modules/lazy-brush/src/Point.js","../../../../node_modules/.pnpm/lazy-brush@1.0.1/node_modules/lazy-brush/src/LazyPoint.js","../../../../node_modules/.pnpm/lazy-brush@1.0.1/node_modules/lazy-brush/src/LazyBrush.js","../../../../js/image/src/Sketch.svelte","../../../../js/image/src/ModifySketch.svelte","../../../../js/image/src/SketchSettings.svelte","../../../../js/image/src/Image.svelte","../../../../js/image/src/StaticImage.svelte","../../../../js/app/src/components/Image/Image.svelte","../../../../js/app/src/components/Image/index.ts"],"sourcesContent":["\n","\n","\n","\n","export const get_coordinates_of_clicked_image = (\n\tevt: MouseEvent\n): [number, number] | null => {\n\tlet image = evt.currentTarget as HTMLImageElement;\n\n\tconst imageRect = image.getBoundingClientRect();\n\tconst xScale = image.naturalWidth / imageRect.width;\n\tconst yScale = image.naturalHeight / imageRect.height;\n\tif (xScale > yScale) {\n\t\tconst displayed_width = imageRect.width;\n\t\tconst displayed_height = image.naturalHeight / xScale;\n\t\tconst y_offset = (imageRect.height - displayed_height) / 2;\n\t\tvar x = Math.round((evt.clientX - imageRect.left) * xScale);\n\t\tvar y = Math.round((evt.clientY - imageRect.top - y_offset) * xScale);\n\t} else {\n\t\tconst displayed_width = image.naturalWidth / yScale;\n\t\tconst displayed_height = imageRect.height;\n\t\tconst x_offset = (imageRect.width - displayed_width) / 2;\n\t\tvar x = Math.round((evt.clientX - imageRect.left - x_offset) * yScale);\n\t\tvar y = Math.round((evt.clientY - imageRect.top) * yScale);\n\t}\n\tif (x < 0 || x >= image.naturalWidth || y < 0 || y >= image.naturalHeight) {\n\t\treturn null;\n\t}\n\treturn [x, y];\n};\n","\n","class Point {\n /**\n *\n * @param {number} x\n * @param {number} y\n */\n constructor(x, y) {\n this.x = x\n this.y = y\n }\n}\n\nexport default Point\n","import Point from './Point'\n\nclass LazyPoint extends Point {\n /**\n * Update the x and y values\n *\n * @param {Point} point\n */\n update (point) {\n this.x = point.x\n this.y = point.y\n }\n\n /**\n * Move the point to another position using an angle and distance\n *\n * @param {number} angle The angle in radians\n * @param {number} distance How much the point should be moved\n */\n moveByAngle (angle, distance) {\n // Rotate the angle based on the browser coordinate system ([0,0] in the top left)\n const angleRotated = angle + (Math.PI / 2)\n\n this.x = this.x + (Math.sin(angleRotated) * distance),\n this.y = this.y - (Math.cos(angleRotated) * distance)\n }\n\n /**\n * Check if this point is the same as another point\n *\n * @param {Point} point\n * @returns {boolean}\n */\n equalsTo (point) {\n return this.x === point.x && this.y === point.y\n }\n\n /**\n * Get the difference for x and y axis to another point\n *\n * @param {Point} point\n * @returns {Point}\n */\n getDifferenceTo (point) {\n return new Point(this.x - point.x, this.y - point.y)\n }\n\n /**\n * Calculate distance to another point\n *\n * @param {Point} point\n * @returns {Point}\n */\n getDistanceTo (point) {\n const diff = this.getDifferenceTo(point)\n\n return Math.sqrt(Math.pow(diff.x, 2) + Math.pow(diff.y, 2))\n }\n\n /**\n * Calculate the angle to another point\n *\n * @param {Point} point\n * @returns {Point}\n */\n getAngleTo (point) {\n const diff = this.getDifferenceTo(point)\n\n return Math.atan2(diff.y, diff.x)\n }\n\n /**\n * Return a simple object with x and y properties\n *\n * @returns {object}\n */\n toObject () {\n return {\n x: this.x,\n y: this.y\n }\n }\n}\n\nexport default LazyPoint\n","import LazyPoint from './LazyPoint'\nconst RADIUS_DEFAULT = 30\n\nclass LazyBrush {\n /**\n * constructor\n *\n * @param {object} settings\n * @param {number} settings.radius The radius for the lazy area\n * @param {boolean} settings.enabled\n */\n constructor ({ radius = RADIUS_DEFAULT, enabled = true, initialPoint = { x: 0, y: 0 }} = {}) {\n this.radius = radius\n this._isEnabled = enabled\n\n this.pointer = new LazyPoint(initialPoint.x, initialPoint.y)\n this.brush = new LazyPoint(initialPoint.x, initialPoint.y)\n\n this.angle = 0\n this.distance = 0\n this._hasMoved = false\n }\n\n /**\n * Enable lazy brush calculations.\n *\n */\n enable () {\n this._isEnabled = true\n }\n\n /**\n * Disable lazy brush calculations.\n *\n */\n disable () {\n this._isEnabled = false\n }\n\n /**\n * @returns {boolean}\n */\n isEnabled () {\n return this._isEnabled\n }\n\n /**\n * Update the radius\n *\n * @param {number} radius\n */\n setRadius (radius) {\n this.radius = radius\n }\n\n /**\n * Return the current radius\n *\n * @returns {number}\n */\n getRadius () {\n return this.radius\n }\n\n /**\n * Return the brush coordinates as a simple object\n *\n * @returns {object}\n */\n getBrushCoordinates () {\n return this.brush.toObject()\n }\n\n /**\n * Return the pointer coordinates as a simple object\n *\n * @returns {object}\n */\n getPointerCoordinates () {\n return this.pointer.toObject()\n }\n\n /**\n * Return the brush as a LazyPoint\n *\n * @returns {LazyPoint}\n */\n getBrush () {\n return this.brush\n }\n\n /**\n * Return the pointer as a LazyPoint\n *\n * @returns {LazyPoint}\n */\n getPointer () {\n return this.pointer\n }\n\n /**\n * Return the angle between pointer and brush\n *\n * @returns {number} Angle in radians\n */\n getAngle () {\n return this.angle\n }\n\n /**\n * Return the distance between pointer and brush\n *\n * @returns {number} Distance in pixels\n */\n getDistance () {\n return this.distance\n }\n\n /**\n * Return if the previous update has moved the brush.\n *\n * @returns {boolean} Whether the brush moved previously.\n */\n brushHasMoved () {\n return this._hasMoved\n }\n\n /**\n * Updates the pointer point and calculates the new brush point.\n *\n * @param {Point} newPointerPoint\n * @param {Object} options\n * @param {Boolean} options.both Force update pointer and brush\n * @returns {Boolean} Whether any of the two points changed\n */\n update (newPointerPoint, { both = false } = {}) {\n this._hasMoved = false\n if (this.pointer.equalsTo(newPointerPoint) && !both) {\n return false\n }\n\n this.pointer.update(newPointerPoint)\n\n if (both) {\n this._hasMoved = true\n this.brush.update(newPointerPoint)\n return true\n }\n\n if (this._isEnabled) {\n this.distance = this.pointer.getDistanceTo(this.brush)\n this.angle = this.pointer.getAngleTo(this.brush)\n\n if (this.distance > this.radius) {\n this.brush.moveByAngle(this.angle, this.distance - this.radius)\n this._hasMoved = true\n }\n } else {\n this.distance = 0\n this.angle = 0\n this.brush.update(newPointerPoint)\n this._hasMoved = true\n }\n\n return true\n }\n}\n\nexport default LazyBrush\n\n","\n\n