tldraw
Version:
A tiny little drawing editor.
64 lines (63 loc) • 2.41 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var ImageAlphaGeometry_exports = {};
__export(ImageAlphaGeometry_exports, {
ImageEllipse2d: () => ImageEllipse2d,
ImageRectangle2d: () => ImageRectangle2d
});
module.exports = __toCommonJS(ImageAlphaGeometry_exports);
var import_editor = require("@tldraw/editor");
var import_ImageAlphaCache = require("./ImageAlphaCache");
function extractAlphaConfig(config) {
return {
alphaDataGetter: config.alphaDataGetter,
crop: config.crop,
flipX: config.flipX,
flipY: config.flipY
};
}
class ImageRectangle2d extends import_editor.Rectangle2d {
alphaConfig;
constructor(config) {
super(config);
this.alphaConfig = extractAlphaConfig(config);
}
hitTestPoint(point, margin = 0, hitInside = false) {
if (!super.hitTestPoint(point, margin, hitInside)) return false;
return !(0, import_ImageAlphaCache.isImagePointTransparent)(this.alphaConfig, point, this.bounds);
}
ignoreHit(point) {
return (0, import_ImageAlphaCache.isImagePointTransparent)(this.alphaConfig, point, this.bounds);
}
}
class ImageEllipse2d extends import_editor.Ellipse2d {
alphaConfig;
constructor(config) {
super(config);
this.alphaConfig = extractAlphaConfig(config);
}
hitTestPoint(point, margin = 0, hitInside = false) {
if (!super.hitTestPoint(point, margin, hitInside)) return false;
return !(0, import_ImageAlphaCache.isImagePointTransparent)(this.alphaConfig, point, this.bounds);
}
ignoreHit(point) {
return (0, import_ImageAlphaCache.isImagePointTransparent)(this.alphaConfig, point, this.bounds);
}
}
//# sourceMappingURL=ImageAlphaGeometry.js.map