* 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.
68 lines
1.8 KiB
TypeScript
68 lines
1.8 KiB
TypeScript
import { describe, expect, test } from 'bun:test'
|
|
|
|
import { createAPI } from '../helpers'
|
|
|
|
describe('stroke details', () => {
|
|
test('strokeWeight and strokeAlign', () => {
|
|
const api = createAPI()
|
|
const rect = api.createRectangle()
|
|
rect.strokes = [
|
|
{
|
|
type: 'SOLID',
|
|
color: { r: 0, g: 0, b: 0, a: 1 },
|
|
weight: 2,
|
|
opacity: 1,
|
|
visible: true,
|
|
align: 'CENTER'
|
|
}
|
|
]
|
|
expect(rect.strokeWeight).toBe(2)
|
|
expect(rect.strokeAlign).toBe('CENTER')
|
|
rect.strokeWeight = 4
|
|
expect(rect.strokeWeight).toBe(4)
|
|
})
|
|
|
|
test('strokeCap and strokeJoin', () => {
|
|
const api = createAPI()
|
|
const line = api.createLine()
|
|
line.strokes = [
|
|
{
|
|
type: 'SOLID',
|
|
color: { r: 0, g: 0, b: 0, a: 1 },
|
|
weight: 2,
|
|
opacity: 1,
|
|
visible: true,
|
|
align: 'CENTER'
|
|
}
|
|
]
|
|
expect(line.strokeCap).toBe('NONE')
|
|
expect(line.strokeJoin).toBe('MITER')
|
|
line.strokeCap = 'ROUND'
|
|
line.strokeJoin = 'BEVEL'
|
|
expect(line.strokeCap).toBe('ROUND')
|
|
expect(line.strokeJoin).toBe('BEVEL')
|
|
expect(line.strokes[0]).toMatchObject({ cap: 'ROUND', join: 'BEVEL' })
|
|
})
|
|
|
|
test('strokeMiterLimit', () => {
|
|
const api = createAPI()
|
|
const rect = api.createRectangle()
|
|
expect(rect.strokeMiterLimit).toBe(4)
|
|
rect.strokeMiterLimit = 8
|
|
expect(rect.strokeMiterLimit).toBe(8)
|
|
})
|
|
|
|
test('individual stroke weights', () => {
|
|
const api = createAPI()
|
|
const frame = api.createFrame()
|
|
frame.strokeTopWeight = 1
|
|
frame.strokeRightWeight = 2
|
|
frame.strokeBottomWeight = 3
|
|
frame.strokeLeftWeight = 4
|
|
expect(frame.strokeTopWeight).toBe(1)
|
|
expect(frame.strokeRightWeight).toBe(2)
|
|
expect(frame.strokeBottomWeight).toBe(3)
|
|
expect(frame.strokeLeftWeight).toBe(4)
|
|
})
|
|
})
|