feat: layer effects, bucket fill, simple brush

This commit is contained in:
2026-05-21 00:02:12 +07:00
parent bcf4650c70
commit e7dd9420e7
47 changed files with 1675 additions and 1038 deletions
+10 -10
View File
@@ -10,7 +10,7 @@ function makeProject(): Project {
updatedAt: "2024-01-01T00:00:00.000Z",
aspectRatio: "1:1",
canvas: { width: 100, height: 100, unit: "px" },
layers: [{ id: "l1", type: "text", x: 0, y: 0, scale: 1, rotation: 0, opacity: 1 }],
layers: [{ id: "l1", type: "text", x: 0, y: 0, scale: 1, rotation: 0, opacity: 1, effects: [], visible: true }],
};
}
@@ -31,18 +31,18 @@ describe("hasProjectChanged", () => {
it("detects face blur region changes", () => {
const a = makeProject();
const b = makeProject();
a.layers[0].type = "image";
b.layers[0].type = "image";
a.layers[0].faceBlur = { method: "gaussian", amount: 14, regions: [{ x: 1, y: 1, width: 10, height: 10 }] };
b.layers[0].faceBlur = { method: "gaussian", amount: 14, regions: [{ x: 1, y: 1, width: 11, height: 10 }] };
a.layers[0].type = "raster";
b.layers[0].type = "raster";
a.layers[0].effects = [{ kind: "face-blur", enabled: true, method: "gaussian", amount: 14, regions: [{ x: 1, y: 1, width: 10, height: 10 }] }];
b.layers[0].effects = [{ kind: "face-blur", enabled: true, method: "gaussian", amount: 14, regions: [{ x: 1, y: 1, width: 11, height: 10 }] }];
expect(hasProjectChanged(a, b)).toBe(true);
});
it("detects layer order changes", () => {
const a = makeProject();
const b = makeProject();
a.layers.push({ id: "l2", type: "text", x: 3, y: 4, scale: 1, rotation: 0, opacity: 1 });
b.layers.push({ id: "l2", type: "text", x: 3, y: 4, scale: 1, rotation: 0, opacity: 1 });
a.layers.push({ id: "l2", type: "text", x: 3, y: 4, scale: 1, rotation: 0, opacity: 1, effects: [], visible: true });
b.layers.push({ id: "l2", type: "text", x: 3, y: 4, scale: 1, rotation: 0, opacity: 1, effects: [], visible: true });
b.layers = [b.layers[1], b.layers[0]];
expect(hasProjectChanged(a, b)).toBe(true);
});
@@ -58,9 +58,9 @@ describe("hasProjectChanged", () => {
it("detects face blur removal", () => {
const a = makeProject();
const b = makeProject();
a.layers[0].type = "image";
b.layers[0].type = "image";
a.layers[0].faceBlur = { method: "gaussian", amount: 14, regions: [{ x: 1, y: 1, width: 10, height: 10 }] };
a.layers[0].type = "raster";
b.layers[0].type = "raster";
a.layers[0].effects = [{ kind: "face-blur", enabled: true, method: "gaussian", amount: 14, regions: [{ x: 1, y: 1, width: 10, height: 10 }] }];
expect(hasProjectChanged(a, b)).toBe(true);
});
});