AI editing data: write Perceptual gradients with the stops on their curve

A gradient definition in the .ai editing data holds each stop's color, opacity, midpoint and ramp point, and VectorCraft's reader opens it as a Classic gradient. A Perceptual gradient was written with its own stops, so the file opened with different colors between them.

The writer now treats a Perceptual gradient as it treats a gradient mixed around the hue wheel, in the art and in the Swatches panel: the colors on its curve become stops of their own in process colors, at most 256, with a warning that names Perceptual gradients. A stop linked to a global process color reports its lost link for both methods. Dither is reported as its own loss. A freeform gradient, or one with more than 256 stops, is still written as its average color whatever its method.
This commit is contained in:
dotCooCoo
2026-11-15 23:59:10 -08:00
parent ed6f22a84c
commit 4e5a6953ba
6 changed files with 206 additions and 43 deletions
+3 -2
View File
@@ -145,8 +145,9 @@ private editing data. VectorCraft:
type with inline graphics, ruby, gradient or pattern paint or an appearance or opacity mask of its own, other patterns, other clipping objects and live
objects (placed documents included) are written as plain filled and stroked paths, and freeform gradients, gradients along
or across a stroke and gradients without stops, with more than 256 stops or without extent as their average
color, each with a warning. Gradients that dither or mix their colors perceptually are written as classic
gradients, and gradient stops linked to global process colors as their colors, each with a warning. The opacity
color, each with a warning. Gradients that dither are written without dither's noise, Perceptual gradients and
gradients mixed around the hue wheel as classic gradients of the stops on their curve in process colors (at most
256), and gradient stops linked to global process colors as their colors, each with a warning. The opacity
and blending mode of single fills and strokes, opacity masks on layers, the placement of pattern swatches that
move, turn or scale their pattern, and the effects of objects written without an art style, other than geometry
effects, are left out.
+8
View File
@@ -2300,6 +2300,14 @@ applies to fills). Tests: `color::gradient::tests` (perceptual midpoint, expansi
`pdf::tests::dithered_perceptual_gradients_export_as_images_with_noise_on_the_fill` and the Gradient panel's
`the_method_menu_makes_the_gradient_perceptual`. Scores and hours unchanged.
A saved `.ai`'s editing data writes a Perceptual gradient, in the art and in the Swatches panel, as a classic gradient of
the stops on its curve in process colors (at most 256, the stops VectorCraft's reader reads), as it writes a gradient
mixed around the hue wheel, so the file opens with the colors between the stops it had; a gradient definition's stops
there hold no interpolation method (`crates/eps/src/import/ai/paint.rs:193-245` reads each `Bs` stop's color, opacity,
midpoint and ramp point). The warning names Perceptual gradients, and a stop linked to a global process color reports
its lost link; Dither's noise is reported as its own loss (VectorCraft's own rules). Test:
`ai_editing::tests::perceptual_gradients_are_written_with_the_stops_on_their_curve`.
PDF export writes a Perceptual linear or radial gradient whose stops are tints of one spot color (and paper white) as a Separation shading in that ink instead of an image, so the ink keeps its plate ([swatches](https://helpx.adobe.com/illustrator/using/using-creating-swatches.html); [separations](https://helpx.adobe.com/illustrator/using/printing-color-separations.html)). Its tints follow the curve's stops, each the tint with the OKLab lightness of the color there (VectorCraft's own rule). A Perceptual gradient that mixes spot colors with each other or with CMYK or gray stops is written as a DeviceN shading of its inks: at each stop on the curve, the inks of the two stops on either side are mixed at the weight where the two colors mixed in display RGB have the OKLab lightness of the color there, or at the stop's mix position between the two colors when that mix's lightness turns back on the way from one color to the other, as from red to blue (VectorCraft's own rule). Dithered fills, freeform gradients, Perceptual gradients that mix a spot color with RGB or Lab stops, and Perceptual gradients whose curve has more than 4,096 stops once expanded (VectorCraft's own limit) are still images, and the export warns that their spot colors are written in process colors. In a CMYK document, or an export that converts colors to a CMYK destination profile, RGB and Lab stops are written in CMYK, so a Perceptual gradient that mixes a spot color with them is a DeviceN shading; an export that converts colors to an RGB destination profile keeps them in RGB. Tests: `color::gradient::tests::ink_tints_follow_the_perceptual_curve`, `ink_mixes_follow_the_perceptual_curve` and `ink_mixes_use_the_mix_position_when_the_lightness_turns_back`, `engine::tests::linked_stops::perceptual_spot_gradients_export_as_separation_shadings`, `perceptual_spot_gradients_mixed_with_other_inks_export_as_device_n_shadings`, `perceptual_spot_gradients_with_rgb_stops_in_a_cmyk_document_export_as_device_n_shadings` and `spot_gradients_drawn_as_images_warn`.
In these Separation and DeviceN shadings, a white stop linked to a swatch that is not a spot color (a global White swatch, for example) is paper white, 0% of the ink, as an unlinked white stop is, so a gradient of one spot ink and such a stop stays a Separation shading; a stop linked to a white spot color stays a stop of that ink (VectorCraft's own rule). Test: `engine::tests::linked_stops::white_stops_linked_to_process_swatches_are_paper_in_spot_gradients`.