UNPKG

@aurigma/design-atoms

Version:

Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.

51 lines 2.75 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import { ShapeItemHandler } from "./ShapeItemHandler"; import { PointF, Path } from "@aurigma/design-atoms-model/Math"; var EllipseItemHandler = /** @class */ (function (_super) { __extends(EllipseItemHandler, _super); function EllipseItemHandler(item, textWhizz, colorPreviewService) { if (textWhizz === void 0) { textWhizz = null; } var _this = this; if (item != null) { _this = _super.call(this, Path.ellipse(item.sourceRectangle.left, item.sourceRectangle.top, item.sourceRectangle.width, item.sourceRectangle.height), item, textWhizz, null, colorPreviewService) || this; _this._controlPoints = [ new PointF(item.sourceRectangle.left, item.sourceRectangle.top), new PointF(item.sourceRectangle.right, item.sourceRectangle.bottom) ]; } else _this = _super.call(this, null, item, textWhizz, null, colorPreviewService) || this; _this._allowNegativeResize = false; return _this; } EllipseItemHandler.prototype.hitTest = function (point, isSelected) { /// <summary>Determines whether the specified point is located inside this vector ellipse.</summary> /// <param name="p" type="Aurigma.GraphicsMill.AjaxControls.VectorObjects.Math.PointF">The point to test.</param> /// <returns type="Boolean"><strong>true</strong> if the specified point is located inside this vector object; otherwise <strong>false</strong>.</returns> var result = _super.prototype.hitTest.call(this, point.clone()); var r = this._getRectangle(); var p = point.clone(); p.translate(-r.centerX, -r.centerY); p.rotate(-r.angle); p.scale(2 / r.width, 2 / r.height); var isBelongToEllipse = (p.x * p.x + p.y * p.y < 1); var isBelongRect = isSelected ? r.toRectangleF().contains(point) : false; result.body = isBelongToEllipse || isBelongRect; return result; }; return EllipseItemHandler; }(ShapeItemHandler)); export { EllipseItemHandler }; //# sourceMappingURL=EllipseItemHandler.js.map