cione-comp-lib
Version:
`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`
29 lines (28 loc) • 1.11 kB
JavaScript
import BoundingRect from "../../../../zrender/lib/core/BoundingRect.mjs";
import { onIrrelevantElement } from "./cursorHelper.mjs";
import { clipPointsByRect } from "../../util/graphic.mjs";
function makeRectPanelClipPath(rect) {
rect = normalizeRect(rect);
return function(localPoints) {
return clipPointsByRect(localPoints, rect);
};
}
function makeLinearBrushOtherExtent(rect, specifiedXYIndex) {
rect = normalizeRect(rect);
return function(xyIndex) {
var idx = specifiedXYIndex != null ? specifiedXYIndex : xyIndex;
var brushWidth = idx ? rect.width : rect.height;
var base = idx ? rect.x : rect.y;
return [base, base + (brushWidth || 0)];
};
}
function makeRectIsTargetByCursor(rect, api, targetModel) {
var boundingRect = normalizeRect(rect);
return function(e, localCursorPoint) {
return boundingRect.contain(localCursorPoint[0], localCursorPoint[1]) && !onIrrelevantElement(e, api, targetModel);
};
}
function normalizeRect(rect) {
return BoundingRect.create(rect);
}
export { makeLinearBrushOtherExtent, makeRectIsTargetByCursor, makeRectPanelClipPath };