move exporting of fill attr to subclasses

This commit is contained in:
llama 2025-06-14 17:47:22 +08:00
parent 615bbf95a1
commit 22e70b2b23
No known key found for this signature in database
GPG key ID: 0B7543854B9413C3
4 changed files with 6 additions and 1 deletions

View file

@ -49,7 +49,6 @@ export class Shape {
left: floatToDisplay(this.left),
top: floatToDisplay(this.top),
...(!angle ? {} : { angle: angle.toString() }),
...(this.fill === SHAPE_MASK_COLOR ? {} : { fill: this.fill }),
};
}

View file

@ -3,6 +3,7 @@
import { fabric } from "fabric";
import { SHAPE_MASK_COLOR } from "../tools/lib";
import type { ConstructorParams, Size } from "../types";
import type { ShapeDataForCloze } from "./base";
import { Shape } from "./base";
@ -25,6 +26,7 @@ export class Ellipse extends Shape {
...super.toDataForCloze(),
rx: floatToDisplay(this.rx),
ry: floatToDisplay(this.ry),
...(this.fill === SHAPE_MASK_COLOR ? {} : { fill: this.fill }),
};
}

View file

@ -3,6 +3,7 @@
import { fabric } from "fabric";
import { SHAPE_MASK_COLOR } from "../tools/lib";
import type { ConstructorParams, Size } from "../types";
import type { ShapeDataForCloze } from "./base";
import { Shape } from "./base";
@ -22,6 +23,7 @@ export class Polygon extends Shape {
return {
...super.toDataForCloze(),
points: this.points.map(({ x, y }) => `${floatToDisplay(x)},${floatToDisplay(y)}`).join(" "),
...(this.fill === SHAPE_MASK_COLOR ? {} : { fill: this.fill }),
};
}

View file

@ -3,6 +3,7 @@
import { fabric } from "fabric";
import { SHAPE_MASK_COLOR } from "../tools/lib";
import type { ConstructorParams, Size } from "../types";
import type { ShapeDataForCloze } from "./base";
import { Shape } from "./base";
@ -25,6 +26,7 @@ export class Rectangle extends Shape {
...super.toDataForCloze(),
width: floatToDisplay(this.width),
height: floatToDisplay(this.height),
...(this.fill === SHAPE_MASK_COLOR ? {} : { fill: this.fill }),
};
}