Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::view::View::BackgroundGradient Struct Reference

One background-image layer. More...

#include <view.hpp>

Public Types

enum class  LinearFrom { endpoints , angle , corner }
 Where a linear gradient's endpoints come from. More...
enum class  RepeatUnit { px , line_fraction }
 What linear_repeat is measured in. More...
enum class  RadialSize {
  max_side , farthest_corner , farthest_side , closest_corner ,
  closest_side , explicit_radii
}
 How a radial gradient's radii are sized, per css-images-3. More...

Public Attributes

int type = 0
std::size_t css_image_layer_index = 0
float x0 = 0
float y0 = 0
float x1 = 0
float y1 = 1
float radius = 0.7071f
float angle = 0.0f
float sweep_turns = 1.0f
std::vector< Color > colors
std::vector< float > positions
LinearFrom linear_from = LinearFrom::endpoints
float linear_angle = 0.0f
 CSS angle in radians, clockwise from "to top".
float corner_x = 1.0f
 Signs of the named corner for LinearFrom::corner: x is +1 for right, -1 for left; y is +1 for bottom, -1 for top.
float corner_y = 1.0f
float linear_repeat = 0.0f
 The band a repeating-linear-gradient tiles; 0 when the gradient does not repeat.
RepeatUnit linear_repeat_unit = RepeatUnit::px
bool positions_in_px = false
 True when positions still hold raw px LENGTHS rather than 0..1 parameters, because every stop named one.
RadialSize radial_size = RadialSize::max_side
bool radial_circle = false
 A circle has one radius resolved against the box's diagonal-ish metric; an ellipse gets a separate radius per axis.
float radial_rx = 0.0f
 RadialSize::explicit_radii: radii as fractions of width and height, plus an absolute term.
float radial_ry = 0.0f
float radial_rx_px = 0.0f
float radial_ry_px = 0.0f
canvas::GradientInterpolation interpolation
 CSS in <space> [<hue> hue].

Detailed Description

One background-image layer.

CSS background-image takes a comma-separated LIST and paints the FIRST entry on top, so a view holds a stack of these rather than a single gradient. The single-gradient setters below replace the whole stack with one layer, which is what every caller that predates layering wants.

Member Enumeration Documentation

◆ LinearFrom

Where a linear gradient's endpoints come from.

endpoints means x0..y1 are already box fractions and need no box (the four to <side> keywords, and every caller of the explicit setter).

Enumerator
endpoints 
angle 
corner 

◆ RadialSize

How a radial gradient's radii are sized, per css-images-3.

max_side is not a CSS keyword — it is the pre-existing radius x max(w,h) circle the explicit setter has always meant, kept so those callers are unaffected.

Enumerator
max_side 
farthest_corner 
farthest_side 
closest_corner 
closest_side 
explicit_radii 

◆ RepeatUnit

What linear_repeat is measured in.

CSS lets the band be a length (... 1px, 7px — 7 CSS px per tile whatever the box) or a fraction of the gradient line (... 0%, 10%), and the line's length is a function of the laid-out box, so the choice cannot be collapsed before paint.

Enumerator
px 
line_fraction 

Member Data Documentation

◆ angle

float pulp::view::View::BackgroundGradient::angle = 0.0f

◆ colors

std::vector<Color> pulp::view::View::BackgroundGradient::colors

◆ corner_x

float pulp::view::View::BackgroundGradient::corner_x = 1.0f

Signs of the named corner for LinearFrom::corner: x is +1 for right, -1 for left; y is +1 for bottom, -1 for top.

◆ corner_y

float pulp::view::View::BackgroundGradient::corner_y = 1.0f

◆ css_image_layer_index

std::size_t pulp::view::View::BackgroundGradient::css_image_layer_index = 0

◆ interpolation

canvas::GradientInterpolation pulp::view::View::BackgroundGradient::interpolation

CSS in <space> [<hue> hue].

◆ linear_angle

float pulp::view::View::BackgroundGradient::linear_angle = 0.0f

CSS angle in radians, clockwise from "to top".

Valid for LinearFrom::angle.

◆ linear_from

LinearFrom pulp::view::View::BackgroundGradient::linear_from = LinearFrom::endpoints

◆ linear_repeat

float pulp::view::View::BackgroundGradient::linear_repeat = 0.0f

The band a repeating-linear-gradient tiles; 0 when the gradient does not repeat.

positions are rescaled ONTO this band — 0..1 across one tile — exactly as a repeating conic's are onto its sweep, so the painter only has to place the band and let the shader tile it.

◆ linear_repeat_unit

RepeatUnit pulp::view::View::BackgroundGradient::linear_repeat_unit = RepeatUnit::px

◆ positions

std::vector<float> pulp::view::View::BackgroundGradient::positions

◆ positions_in_px

bool pulp::view::View::BackgroundGradient::positions_in_px = false

True when positions still hold raw px LENGTHS rather than 0..1 parameters, because every stop named one.

The divisor is the gradient line (linear) or horizontal radius (radial), each a function of the laid-out box — and of the background-size TILE when the layer is tiled — so the division belongs at paint.

linear-gradient(<colour> 1px, transparent 1px) under background-size: 100% 32px is a scanline every 32px. Read as parameters instead, both stops land at 1.0 — the far end of the ramp — and the layer paints its first colour over the WHOLE box. That is a monotone wash, and it reads as a missing tile rather than as a misread stop, which is why the two halves have to land together.

◆ radial_circle

bool pulp::view::View::BackgroundGradient::radial_circle = false

A circle has one radius resolved against the box's diagonal-ish metric; an ellipse gets a separate radius per axis.

CSS defaults to ellipse unless circle is named or a single length is given.

◆ radial_rx

float pulp::view::View::BackgroundGradient::radial_rx = 0.0f

RadialSize::explicit_radii: radii as fractions of width and height, plus an absolute term.

A % radius fills the fraction slot and a px radius the absolute one, so both spellings — and a calc() that mixes them — resolve through one expression.

◆ radial_rx_px

float pulp::view::View::BackgroundGradient::radial_rx_px = 0.0f

◆ radial_ry

float pulp::view::View::BackgroundGradient::radial_ry = 0.0f

◆ radial_ry_px

float pulp::view::View::BackgroundGradient::radial_ry_px = 0.0f

◆ radial_size

RadialSize pulp::view::View::BackgroundGradient::radial_size = RadialSize::max_side

◆ radius

float pulp::view::View::BackgroundGradient::radius = 0.7071f

◆ sweep_turns

float pulp::view::View::BackgroundGradient::sweep_turns = 1.0f

◆ type

int pulp::view::View::BackgroundGradient::type = 0

◆ x0

float pulp::view::View::BackgroundGradient::x0 = 0

◆ x1

float pulp::view::View::BackgroundGradient::x1 = 0

◆ y0

float pulp::view::View::BackgroundGradient::y0 = 0

◆ y1

float pulp::view::View::BackgroundGradient::y1 = 1

The documentation for this struct was generated from the following file:
  • /home/runner/work/pulp/pulp/core/view/include/pulp/view/view.hpp