an.paint#
Paint: what fills a shape when one flat colour is not enough – a gradient.
A gradient blends colour stops (CSS’s color stops: a colour at an
offset from 0 to 1 along the gradient) either along a line (linear) or
outward from a centre (radial). The vocabulary is CSS’s
(linear-gradient / radial-gradient), so an author who knows one knows
the other:
angle(linear) is the CSS gradient angle in degrees:0runs to the top,90to the right,180(the default) to the bottom. As in CSS the gradient line is as long as it must be for the box’s corners to sit on the first and last stop.centerandradius(radial) are fractions of the box. In a box that is not square the gradient is an ellipse with the box’s proportions (CSS’sellipse);radius: 0.5touches the sides of a centred box.Colours between stops are interpolated in sRGB, as CSS and SVG do by default; beyond the first and last stop the end colours hold.
Colours are hex strings (#rgb, #rgba, #rrggbb, #rrggbbaa), the
representation the StylePack uses everywhere. Stops may be written as plain
colours, which are spread evenly:
>>> g = Gradient(stops=["#101030", "#f0d090"])
>>> [(s.offset, s.color) for s in g.stops]
[(0.0, '#101030'), (1.0, '#f0d090')]
>>> Gradient(type="radial", stops=["#fff", "#0000"], radius=0.75).radius
0.75
A field that would do nothing is refused rather than ignored:
>>> Gradient(type="radial", stops=["#fff", "#000"], angle=90)
Traceback (most recent call last):
...
pydantic_core._pydantic_core.ValidationError: ...
This is genre-neutral core vocabulary: a plane of the 2D stage draws one
(an.stage.environments.PlaneArt), and a StylePack names them as
gradient roles (an.styles.StylePack.gradients).
Module Attributes
top to bottom. |
Functions
|
A hex colour as |
Classes
|
A linear or radial gradient between colour stops (see the module docstring). |
|
A colour at an offset along the gradient ( |
- class an.paint.Gradient(**data)[source]#
Bases:
BaseModelA linear or radial gradient between colour stops (see the module docstring).