Class GradientRamp
The colour ramp Word blends the two stops of a DrawingML gradient with (WQ-0037).
public static class GradientRamp
- Inheritance
-
GradientRamp
- Inherited Members
Remarks
A two-stop gradient whose stops sit at 0 and 100000 does not blend as a component-wise interpolation of sRGB bytes. Word blends in a linear-light space - a plain power law with exponent 2.2 - under an S-shaped parameter, and exports the result as a sampled FunctionType 0 table rather than the FunctionType 2 exponentials it uses for every other stop list.
The parameter has no established closed form and none is invented here: it is the measured curve, read out of Word's own export of a black-to-white gradient, where the composite IS the parameter with no space or easing ambiguity. Cosine and smoothstep are both measurably wrong - the measured end slopes are 0.247 and 0.274 where both of those are 0, and the peak slope is 1.695 against a cosine's pi/2.
Validated against four colour pairs, three of which took no part in deriving it - black to red, red to cyan, white to 2F5496 and 1F3864 to FFE699: worst-case error 1 level out of 255, against 59 for the component-wise sRGB blend it replaces.
Everything here is integer. The imaging renderer is integer-only on purpose so its output is byte-identical across runtimes, and both byte-identical-across-runs gates sit inside the parity filter; evaluating a power at render time would put that at risk.
Fields
- SampleCount
The number of entries Word samples a ramp at, and the number this emits.
- Scale
The fixed-point scale of the two tables.
Properties
- SegmentKnots
Gets the sample indices a PDF stitching function needs knots at. See DocWright.Core.Rendering.GradientRamp.SegmentKnotData for why they are not evenly spaced.
Methods
- AppliesTo(IReadOnlyList<GradientStop>)
Gets a value indicating whether Word blends this stop list with the measured ramp.
- Blend(ColorRgb, ColorRgb, long, long)
Blends two colours at an arbitrary position along the ramp.
- SampleAt(ColorRgb, ColorRgb, int)
Blends two colours at one of SampleCount evenly spaced positions along the ramp.