Skip to content

Commit

Permalink
fix: 再次恢复patch397 (#463)
Browse files Browse the repository at this point in the history
  • Loading branch information
wuchenguang1998 authored Jul 5, 2024
1 parent 6461a9a commit 4270c23
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/core/plugin/PolygonModifyPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,24 @@ function renderIconEdge(
left: number,
top: number,
styleOverride: any,
fabricObject: fabric.Object
fabricObject: fabric.Object,
img: HTMLImageElement
) {
const img = document.createElement('img');
img.src = edgeImg;
drawImg(ctx, left, top, img, 25, 25, fabric.util.degreesToRadians(fabricObject.angle || 0));
}

class PolygonModifyPlugin implements IPluginTempl {
public isEdit: boolean;
private img: HTMLImageElement;
static pluginName = 'PolygonModifyPlugin';
static events = [];
static apis = ['toggleEdit', 'activeEdit', 'inActiveEdit'];

constructor(public canvas: fabric.Canvas, public editor: IEditor) {
this.isEdit = false;
const img = document.createElement('img');
img.src = edgeImg;
this.img = img;
this.init();
}
init() {
Expand All @@ -124,6 +127,7 @@ class PolygonModifyPlugin implements IPluginTempl {
this._ensureEvent(poly);
if (poly.points == null) return;
const lastControl = poly.points.length - 1;
const This = this;
poly.controls = poly.points.reduce<Record<string, PointIndexControl>>(function (
acc,
point,
Expand All @@ -133,7 +137,7 @@ class PolygonModifyPlugin implements IPluginTempl {
positionHandler: polygonPositionHandler,
actionHandler: anchorWrapper(index > 0 ? index - 1 : lastControl, actionHandler),
actionName: 'modifyPolygon',
render: (...args) => renderIconEdge(...args),
render: (...args) => renderIconEdge(...args, This.img),
});
Object.defineProperty(acc['p' + index], 'pointIndex', { value: index });
return acc;
Expand Down

0 comments on commit 4270c23

Please sign in to comment.