Merge pull request #6961 from dotCooCoo/fix/gradient-repeat-runs

Gradients: a repeated gradient with many stops keeps every run
This commit is contained in:
BFlat
2026-11-13 05:22:59 +07:00
committed by GitHub
12 changed files with 560 additions and 52 deletions
+13 -5
View File
@@ -1270,11 +1270,19 @@ is written with its stops repeated as many times as the shape needs: at most 256
legacy `.ai`), and for a radial or diamond gradient no farther from its center than 65,536 runs, or than a million
times the smallest gap between its stops (measured in runs) when that is less. Past those it pads, with a warning.
The `.ai` editing data has no spread either: it holds the stops repeated across the shape, at most 256 of them, with
a warning. PDF import finds a sharp step between two colors in an axial or radial shading, in any PDF, by halving
the spans between its samples, so the step reads back where it is in the file (to 1/64 × 2^-14 of the axis, with at
most 16,384 samples a shading) instead of blurred across the samples around it. Object › Expand expands the
repeated stops, into the same whole number of `steps` objects for each run (at least one, so about `steps` in all),
each run starting on an object's edge:
a warning. When the runs need more stops than these limits allow, every run is still written, without the stops that
change its colors least. Each run keeps its ends; sharp steps and swatch-linked stops are the last to be left out,
but a run with more of them than its share of the limit loses some. The same applies to a gradient along or across a
stroke, and to CSS's conic gradient, past 16,384 stops, and to Outline Stroke's mesh past 1,024. For CSS the 16,384
counts the gradient's stops before they are written: CSS then adds a stop for each midpoint, and for a Perceptual
gradient stops along each span's curve, so the written gradient can hold more. PDF
import finds a sharp step between two colors in an axial or radial shading by halving the spans between its samples,
so the step reads back where it is in the file (to 1/64 × 2^-14 of the axis) instead of blurred across the samples
around it. A shading takes at most 16,384 samples, so the steps past the point where that budget runs out stay
blurred, and a color band narrower than 1/64 of the axis can be missed when no sample lands in it. Object › Expand
expands the repeated stops, into the same whole number of `steps` objects for each run (at least one, so about
`steps` in all), each run starting on an object's edge; a gradient that needs more than 256 runs across the box stays
a gradient:
```json
{"name":"run_command","arguments":{"command":"paint.editGradient","params":{"spread":"reflect","repeats":3}}}