- Fix router import path in main.js - Handle Django REST Framework pagination format in API calls - Add getTemplates function to project API - Restart frontend development server
179 lines
4.8 KiB
JavaScript
179 lines
4.8 KiB
JavaScript
import { changeCropHeight, changeCropWidth, changeCropX, changeCropY, changeHeightAndScaleToCover, changeWidthAndScaleToCover, ghostScalePositionHandler, scaleEquallyCropGenerator, withCornerFlip, withFlip } from "./croppingHandlers.mjs";
|
|
import { renderCornerControl, renderRoundedSegmentControl, shouldActivateCorner } from "./controlRendering.mjs";
|
|
import { Control, controlsUtils } from "fabric";
|
|
//#region extensions/cropping_controls/croppingControls.ts
|
|
const { scaleCursorStyleHandler } = controlsUtils;
|
|
const cropActionName = () => "crop";
|
|
const createImageCroppingControls = () => ({
|
|
tls: new Control({
|
|
x: -.5,
|
|
y: -.5,
|
|
cursorStyleHandler: scaleCursorStyleHandler,
|
|
positionHandler: ghostScalePositionHandler,
|
|
actionHandler: scaleEquallyCropGenerator(-.5, -.5)
|
|
}),
|
|
brs: new Control({
|
|
x: .5,
|
|
y: .5,
|
|
cursorStyleHandler: scaleCursorStyleHandler,
|
|
positionHandler: ghostScalePositionHandler,
|
|
actionHandler: scaleEquallyCropGenerator(.5, .5)
|
|
}),
|
|
trs: new Control({
|
|
x: .5,
|
|
y: -.5,
|
|
cursorStyleHandler: scaleCursorStyleHandler,
|
|
positionHandler: ghostScalePositionHandler,
|
|
actionHandler: scaleEquallyCropGenerator(.5, -.5)
|
|
}),
|
|
bls: new Control({
|
|
x: -.5,
|
|
y: .5,
|
|
cursorStyleHandler: scaleCursorStyleHandler,
|
|
positionHandler: ghostScalePositionHandler,
|
|
actionHandler: scaleEquallyCropGenerator(-.5, .5)
|
|
}),
|
|
mlc: new Control({
|
|
x: -.5,
|
|
y: 0,
|
|
angle: 90,
|
|
sizeX: 8,
|
|
sizeY: 16,
|
|
render: renderRoundedSegmentControl,
|
|
cursorStyleHandler: scaleCursorStyleHandler,
|
|
actionHandler: withFlip(changeCropX, changeCropWidth, "flipX"),
|
|
getActionName: cropActionName
|
|
}),
|
|
mrc: new Control({
|
|
x: .5,
|
|
y: 0,
|
|
angle: 90,
|
|
sizeX: 8,
|
|
sizeY: 16,
|
|
render: renderRoundedSegmentControl,
|
|
cursorStyleHandler: scaleCursorStyleHandler,
|
|
actionHandler: withFlip(changeCropWidth, changeCropX, "flipX"),
|
|
getActionName: cropActionName
|
|
}),
|
|
mbc: new Control({
|
|
x: 0,
|
|
y: .5,
|
|
angle: 0,
|
|
sizeX: 16,
|
|
sizeY: 8,
|
|
render: renderRoundedSegmentControl,
|
|
cursorStyleHandler: scaleCursorStyleHandler,
|
|
actionHandler: withFlip(changeCropHeight, changeCropY, "flipY"),
|
|
getActionName: cropActionName
|
|
}),
|
|
mtc: new Control({
|
|
x: 0,
|
|
y: -.5,
|
|
angle: 0,
|
|
sizeX: 16,
|
|
sizeY: 8,
|
|
render: renderRoundedSegmentControl,
|
|
cursorStyleHandler: scaleCursorStyleHandler,
|
|
actionHandler: withFlip(changeCropY, changeCropHeight, "flipY"),
|
|
getActionName: cropActionName
|
|
}),
|
|
tlc: new Control({
|
|
angle: 0,
|
|
x: -.5,
|
|
y: -.5,
|
|
sizeX: 12,
|
|
sizeY: 8,
|
|
render: renderCornerControl,
|
|
shouldActivate: shouldActivateCorner,
|
|
cursorStyleHandler: scaleCursorStyleHandler,
|
|
actionHandler: withCornerFlip(changeCropX, changeCropWidth, changeCropY, changeCropHeight),
|
|
getActionName: cropActionName
|
|
}),
|
|
trc: new Control({
|
|
angle: 90,
|
|
x: .5,
|
|
y: -.5,
|
|
sizeX: 12,
|
|
sizeY: 8,
|
|
render: renderCornerControl,
|
|
shouldActivate: shouldActivateCorner,
|
|
cursorStyleHandler: scaleCursorStyleHandler,
|
|
actionHandler: withCornerFlip(changeCropWidth, changeCropX, changeCropY, changeCropHeight),
|
|
getActionName: cropActionName
|
|
}),
|
|
blc: new Control({
|
|
angle: 270,
|
|
x: -.5,
|
|
y: .5,
|
|
sizeX: 12,
|
|
sizeY: 8,
|
|
render: renderCornerControl,
|
|
shouldActivate: shouldActivateCorner,
|
|
cursorStyleHandler: scaleCursorStyleHandler,
|
|
actionHandler: withCornerFlip(changeCropX, changeCropWidth, changeCropHeight, changeCropY),
|
|
getActionName: cropActionName
|
|
}),
|
|
brc: new Control({
|
|
angle: 180,
|
|
x: .5,
|
|
y: .5,
|
|
sizeX: 12,
|
|
sizeY: 8,
|
|
render: renderCornerControl,
|
|
shouldActivate: shouldActivateCorner,
|
|
cursorStyleHandler: scaleCursorStyleHandler,
|
|
actionHandler: withCornerFlip(changeCropWidth, changeCropX, changeCropHeight, changeCropY),
|
|
getActionName: cropActionName
|
|
})
|
|
});
|
|
const edgeActionName = () => "resizing";
|
|
const createImageResizeControlsWithScaleToCover = () => ({
|
|
mle: new Control({
|
|
x: -.5,
|
|
y: 0,
|
|
angle: 90,
|
|
sizeX: 8,
|
|
sizeY: 16,
|
|
render: renderRoundedSegmentControl,
|
|
cursorStyleHandler: scaleCursorStyleHandler,
|
|
actionHandler: changeWidthAndScaleToCover,
|
|
getActionName: edgeActionName
|
|
}),
|
|
mre: new Control({
|
|
x: .5,
|
|
y: 0,
|
|
angle: 90,
|
|
sizeX: 8,
|
|
sizeY: 16,
|
|
render: renderRoundedSegmentControl,
|
|
cursorStyleHandler: scaleCursorStyleHandler,
|
|
actionHandler: changeWidthAndScaleToCover,
|
|
getActionName: edgeActionName
|
|
}),
|
|
mte: new Control({
|
|
x: 0,
|
|
y: -.5,
|
|
angle: 0,
|
|
sizeX: 16,
|
|
sizeY: 8,
|
|
render: renderRoundedSegmentControl,
|
|
cursorStyleHandler: scaleCursorStyleHandler,
|
|
actionHandler: changeHeightAndScaleToCover,
|
|
getActionName: edgeActionName
|
|
}),
|
|
mbe: new Control({
|
|
x: 0,
|
|
y: .5,
|
|
angle: 0,
|
|
sizeX: 16,
|
|
sizeY: 8,
|
|
render: renderRoundedSegmentControl,
|
|
cursorStyleHandler: scaleCursorStyleHandler,
|
|
actionHandler: changeHeightAndScaleToCover,
|
|
getActionName: edgeActionName
|
|
})
|
|
});
|
|
//#endregion
|
|
export { createImageCroppingControls, createImageResizeControlsWithScaleToCover };
|
|
|
|
//# sourceMappingURL=croppingControls.mjs.map
|