Donner SVG main
0.8.0 ยท 766e862a0.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::geode::LinearGradientParams Struct Reference

Parameters for a linear gradient fill at the Geode drawing layer. More...

#include "donner/svg/renderer/geode/GeoEncoder.h"

Classes

struct  Stop
 A single gradient stop: normalized offset and STRAIGHT-alpha RGBA. Not premultiplied: the resolver writes r/g/b/a each divided by 255, and both gradient shaders interpolate stops in straight alpha and premultiply only at output (stop-opacity conformance depends on it). More...

Public Attributes

Vector2d startGrad = Vector2d::Zero()
 Start point in gradient space.
Vector2d endGrad = Vector2d::Zero()
 End point in gradient space.
Transform2d gradientFromPath
 Affine transform that maps a path-space sample position to gradient space. The fragment shader uses this to recover the gradient parameter t per pixel. This is the inverse of pathFromGradient and already bakes in both gradientUnits and the gradientTransform attribute.
uint32_t spreadMode = 0
 Spread mode at the edges of the gradient range. 0 = pad, 1 = reflect, 2 = repeat.
std::span< const Stop > stops
 Gradient stops, in order of non-decreasing offset. Colors are in straight alpha, 0..1 per channel - the shader interpolates in straight alpha and premultiplies at output. Offsets are in [0, 1]. Up to 16 stops travel inline in the draw's parameters; a gradient with more reads them from a stop ramp texture, which the draws of one encoder share by stop content and a resident draw keeps until its stops change. A draw with more than GeoEncoder::kMaxGradientRampStops stops is refused.

Detailed Description

Parameters for a linear gradient fill at the Geode drawing layer.

All geometry fields are in the gradient's own coordinate system (after the caller has already folded gradientUnits + the gradientTransform attribute into gradientFromPath). The encoder uploads these verbatim into a per-draw uniform buffer consumed by donner/gpu/shader/programs/SlugGradientSource.h.


Class Documentation

◆ donner::geode::LinearGradientParams::Stop

struct donner::geode::LinearGradientParams::Stop

A single gradient stop: normalized offset and STRAIGHT-alpha RGBA. Not premultiplied: the resolver writes r/g/b/a each divided by 255, and both gradient shaders interpolate stops in straight alpha and premultiply only at output (stop-opacity conformance depends on it).

Class Members
float offset = 0.0f Stop offset in [0, 1].
float rgba[4] = {0.0f, 0.0f, 0.0f, 1.0f} Straight-alpha RGBA color.

Member Data Documentation

◆ endGrad

Vector2d donner::geode::LinearGradientParams::endGrad = Vector2d::Zero()

End point in gradient space.

◆ gradientFromPath

Transform2d donner::geode::LinearGradientParams::gradientFromPath

Affine transform that maps a path-space sample position to gradient space. The fragment shader uses this to recover the gradient parameter t per pixel. This is the inverse of pathFromGradient and already bakes in both gradientUnits and the gradientTransform attribute.

◆ spreadMode

uint32_t donner::geode::LinearGradientParams::spreadMode = 0

Spread mode at the edges of the gradient range. 0 = pad, 1 = reflect, 2 = repeat.

◆ startGrad

Vector2d donner::geode::LinearGradientParams::startGrad = Vector2d::Zero()

Start point in gradient space.

◆ stops

std::span<const Stop> donner::geode::LinearGradientParams::stops

Gradient stops, in order of non-decreasing offset. Colors are in straight alpha, 0..1 per channel - the shader interpolates in straight alpha and premultiplies at output. Offsets are in [0, 1]. Up to 16 stops travel inline in the draw's parameters; a gradient with more reads them from a stop ramp texture, which the draws of one encoder share by stop content and a resident draw keeps until its stops change. A draw with more than GeoEncoder::kMaxGradientRampStops stops is refused.


The documentation for this struct was generated from the following file: