@aurigma/design-atoms
Version:
Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.
32 lines • 1.79 kB
JavaScript
import { ShapeItemHandler } from "./ShapeItemHandler";
import { PointF, Path } from "@aurigma/design-atoms-model/Math";
export class EllipseItemHandler extends ShapeItemHandler {
constructor(item, textWhizz = null, colorPreviewService) {
if (item != null) {
super(Path.ellipse(item.sourceRectangle.left, item.sourceRectangle.top, item.sourceRectangle.width, item.sourceRectangle.height), item, textWhizz, null, colorPreviewService);
this._controlPoints = [
new PointF(item.sourceRectangle.left, item.sourceRectangle.top),
new PointF(item.sourceRectangle.right, item.sourceRectangle.bottom)
];
}
else
super(null, item, textWhizz, null, colorPreviewService);
this._allowNegativeResize = false;
}
hitTest(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.hitTest(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;
}
}
//# sourceMappingURL=EllipseItemHandler.js.map