Repository navigation
Commit 373822f
SVG: filters
renderSVG applies filters: url(#...) and the filter functions (blur,
drop-shadow, brightness, contrast, grayscale, hue-rotate, invert,
opacity, saturate, sepia). New src/render/filter.ts, ported from resvg:
8 bit premultiplied pixels like resvg's (its rounding, the linearRGB
tables as the rounded curves), feGaussianBlur (box blur from sigma 2,
IIR below), feOffset, feFlood, feComposite (arithmetic too), feMerge,
feDropShadow, feColorMatrix, feComponentTransfer, feTile, feBlend
(tiny-skia's 16 modes), feMorphology (separable, monotonic queue: linear
time, 80 s -> 0.1 s for resvg's huge-radius test), feConvolveMatrix.
svg.ts parses filters like usvg: regions and subregions in both units,
attributes through href, inputs/results, color-interpolation-filters,
invalid filters hide the element (invalid convolutions are transparent);
filters with feImage, feTurbulence, feDisplacementMap or lighting are
left out. An element with filters renders into a layer covering the
filter regions in its scale (2 canvases of margin, like resvg), rotation
and skew applied when drawn (bilinear). Scales are tiny-skia's get_scale
(the rows' lengths), now for pattern tiles too. Filter attributes are
plain numbers (10% isn't 0.1 there).
resvg's filter tests: 300/408 (was 81; blur, offset, flood, composite,
merge, color matrix, component transfer, blend, morphology, convolve all
pass; the rest is mostly the unsupported primitives), copied to
tests/svgs/resvg (1 MB); tests/svg.js takes 21 s instead of 5 s.
Patterns 32/33, markers 61/64, images 17/56 unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lfv41PqHEGbU7SLg5onpG11 parent c3ccdf2 commit 373822f
606 files changed
Lines changed: 5369 additions & 13 deletions
File tree
- src
- render
- tests/svgs/resvg/filters
- enable-background
- feBlend
- feColorMatrix
- feComponentTransfer
- feComposite
- feConvolveMatrix
- feDiffuseLighting
- feDisplacementMap
- feDropShadow
- feFlood
- feGaussianBlur
- feImage
- feMerge
- feMorphology
- feOffset
- feTile
- filter-functions
- filter
- flood-color
- flood-opacity
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
29 | 38 | | |
30 | 39 | | |
31 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
| |||
520 | 522 | | |
521 | 523 | | |
522 | 524 | | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2260 | 2260 | | |
2261 | 2261 | | |
2262 | 2262 | | |
2263 | | - | |
| 2263 | + | |
| 2264 | + | |
2264 | 2265 | | |
2265 | 2266 | | |
2266 | 2267 | | |
| |||
0 commit comments