* feat(scene-graph)!: make a stroke a paint Stroke extends Fill, so a stroke carries the same paint vocabulary a fill does instead of a lone color. Every construction site now states a solid paint type, which keeps today's behaviour exactly; rendering, .fig conversion, and the stroke panel still read solid strokes only. copyFill is generic over the paint shape so copyStroke reuses it rather than repeating the deep copy of gradient stops, transforms and pattern fields. Groundwork for the gradient and image strokes in #797. * test(scene-graph): cover a stroke's nested paint data in copyStroke A stroke is a paint now, so its gradient stops and transform must copy as deeply as a fill's; the fixture was solid and proved only the color and dash pattern.
67 lines
1.9 KiB
TypeScript
67 lines
1.9 KiB
TypeScript
import { expect, test, useEditorSetupWithClear } from '#tests/e2e/fixtures'
|
|
|
|
const editor = useEditorSetupWithClear('/?test&no-chrome&no-rulers')
|
|
|
|
async function expectCanvas(name: string) {
|
|
editor.canvas.assertNoErrors()
|
|
const buffer = await editor.canvas.screenshotCanvasRegion()
|
|
expect(buffer).toMatchSnapshot(`${name}.png`)
|
|
}
|
|
|
|
test('boolean operations', async () => {
|
|
await editor.page.evaluate(() => {
|
|
const store = window.openPencil?.getStore?.()
|
|
if (!store) throw new Error('OpenPencil store not initialized')
|
|
const pageId = store.state.currentPageId
|
|
const operations = ['UNION', 'SUBTRACT', 'INTERSECT', 'EXCLUDE'] as const
|
|
const colors = [
|
|
{ r: 0.23, g: 0.51, b: 0.96, a: 1 },
|
|
{ r: 0.96, g: 0.35, b: 0.35, a: 1 },
|
|
{ r: 0.08, g: 0.73, b: 0.73, a: 1 },
|
|
{ r: 0.58, g: 0.27, b: 0.95, a: 1 }
|
|
]
|
|
|
|
for (const [index, operation] of operations.entries()) {
|
|
const group = store.graph.createNode('BOOLEAN_OPERATION', pageId, {
|
|
name: `${operation} visual`,
|
|
x: 72 + index * 152,
|
|
y: 92,
|
|
width: 124,
|
|
height: 104,
|
|
booleanOperation: operation,
|
|
fills: [{ type: 'SOLID', color: colors[index], visible: true, opacity: 1 }],
|
|
strokes: [
|
|
{
|
|
type: 'SOLID',
|
|
color: { r: 0.08, g: 0.1, b: 0.18, a: 0.32 },
|
|
weight: 2,
|
|
visible: true,
|
|
opacity: 1,
|
|
align: 'CENTER'
|
|
}
|
|
]
|
|
})
|
|
store.graph.createNode('RECTANGLE', group.id, {
|
|
name: `${operation} rectangle`,
|
|
x: 0,
|
|
y: 18,
|
|
width: 82,
|
|
height: 70,
|
|
cornerRadius: 14
|
|
})
|
|
store.graph.createNode('ELLIPSE', group.id, {
|
|
name: `${operation} ellipse`,
|
|
x: 42,
|
|
y: 0,
|
|
width: 82,
|
|
height: 104
|
|
})
|
|
}
|
|
|
|
store.clearSelection()
|
|
store.requestRender()
|
|
})
|
|
await editor.canvas.waitForRender()
|
|
await expectCanvas('boolean-operations')
|
|
})
|