* fix(core): keep SVG icon stroke caps and joins after saving Icons inserted from Iconify and vectors from import_svg set stroke-linecap and stroke-linejoin only on the Stroke paint. .fig stores cap and join on the node, and the reader rebuilds the paint's cap and join from it, so a saved and reopened Lucide icon came back with NONE caps and MITER joins and showed gaps where its strokes meet. Set strokeCap and strokeJoin on the node as well. * fix(core): fill open subpaths of filled SVG paths SVG fills every subpath as if it were closed, but parseSVGPath put only closed subpaths in the fill region. The renderer filled the open ones as a separate path, so a hole formed by an open subpath and a closed one under the path's fill rule was filled in, as in some Font Awesome icons. Add an includeOpenRegions option to parseSVGPath, off by default, and set it for filled paths without a stroke from Iconify icons and import_svg, and for SVG clip paths. Stroked paths keep open subpaths out of the region so their closing edges are not stroked. A filled polyline now flattens with adjacent filled shapes like a polygon does. * docs(changelog): state where open SVG subpaths are now filled The app has no icon picker. The fix reaches Design JSX <Icon> and inline <svg> through scalePathInfos, dropped and pasted SVG files and clip paths through svgToVectorPaths, and makes filled polylines render filled. Name the unstroked-path limit instead of an unqualified claim. * test(core): import SceneGraph from its owning package Scene Graph owns the graph type; the Core barrel only re-exports it for compatibility. importVectors also returns the graph, matching the same helper in #832 so the shared test files reconcile cleanly. * docs(changelog): name every path that keeps SVG stroke caps The app has no icon picker; the fix reaches Design JSX <Icon> and inline <svg> through createIconFromPaths, and dropped or pasted SVG files through the same vector placement as import_svg. * test(core): import SceneGraph from its owning package Scene Graph owns the graph type; the Core barrel only re-exports it for compatibility. * refactor(core): read the first SVG path stroke with at(0) Array destructuring types the first stroke as always present, so the type-aware no-unnecessary-condition lint rejected the guard that skips vectors without strokes and failed bun run check. --------- Co-authored-by: Jason Woltje <1139190+jetrich@users.noreply.github.com>
30 lines
844 B
TypeScript
30 lines
844 B
TypeScript
import { describe, expect, test } from 'bun:test'
|
|
|
|
import { parseSVGPath } from '@open-pencil/scene-graph/parse-path'
|
|
|
|
// An open outer square around a closed inner square, as filled icon sets often draw a ring.
|
|
const RING = 'M0 0h24v24H0M6 6v12h12V6z'
|
|
|
|
describe('parseSVGPath', () => {
|
|
test('leaves open subpaths out of the fill region by default', () => {
|
|
const network = parseSVGPath(RING)
|
|
|
|
expect(network.regions).toHaveLength(1)
|
|
expect(network.regions[0].loops).toEqual([[3, 4, 5, 6]])
|
|
})
|
|
|
|
test('puts open subpaths in the fill region with includeOpenRegions', () => {
|
|
const network = parseSVGPath(RING, 'EVENODD', { includeOpenRegions: true })
|
|
|
|
expect(network.regions).toEqual([
|
|
{
|
|
windingRule: 'EVENODD',
|
|
loops: [
|
|
[0, 1, 2],
|
|
[3, 4, 5, 6]
|
|
]
|
|
}
|
|
])
|
|
})
|
|
})
|