Gradients¶
bouquet.gradients module provides various types of gradients.
Note
bouquet.gradients API is stable and won’t change dramatically.
How to use gradients with Vertex Instructions?¶
This is possible to use gradient textures with Vertex Instructions via the
***Gradient.render_texture() function. You can take a look at code examples
in the Examples section.
- class bouquet.gradients.ColorStop¶
Bases:
EventDispatcherThe ColorStop class is used together with
LinearGradientandRadialGradient. It defines a specific color at a certain position within the gradient.- color¶
The color to display at the stop
position.coloris anColorPropertyand defaults to white.
- position¶
The position of the color stop. The value should be in the range from 0.0 (start; one edge of gradient) to 1.0 (end; another edge of gradient). If the value exceeds the bounds, it will be set to:
1.0 if the value is greater than 1.0;
0.0 if the value is less than 0.0.
positionis anBoundedNumericPropertyand defaults to 0.0.
- class bouquet.gradients.base.GradientBase(**kwargs)¶
Bases:
AnchorLayoutBase class for linear and radial gradients. Do not use it directly; use a
LinearGradientor aRadialGradient.Hint
GradientBaseis anAnchorLayoutsubclass, so you can put any widget inside it.- color_stops¶
List of
ColorStopobjects, describes how the gradient will look. If the list is empty, the gradient will be completely white.Warning
bouquet gradients supports up to 1024 color stops.
- Raises:
ValueError – If the list length is greater than 1024.
TypeError – If the list contains anything other than
ColorStopobjects.
color_stopsis aListPropertyand is empty by default.
- class bouquet.gradients.LinearGradient(**kwargs)¶
Bases:
GradientBaseThe LinearGradient class provides a way to create linear gradients in Kivy.
A linear gradient is a visual effect where color is linearly interpolated between multiple color stops (
ColorStop) across a straight line, known as the gradient line.See also
Note, a linear gradient is rendered as described in the CSS specification.
- angle¶
Defines the rotation of the gradient line in degrees. The angle determines the direction in which the gradient will be rendered, where 0 degrees represents a vertical gradient (from bottom to top), and 90 degrees represents a horizontal gradient (from left to right).
angleis anNumericPropertyand defaults to 0.
- static render_texture(**kwargs) Texture¶
Renders gradient at FBO and returns the texture.
- Parameters:
kwargs – Any
LinearGradientproperties.
- class bouquet.gradients.RadialGradient(**kwargs)¶
Bases:
GradientBaseThe RadialGradient class provides a way to create radial gradients in Kivy.
A radial gradient is a visual effect where color is linearly interpolated between multiple color stops (
ColorStop) from the center to the border.Hint
The value 0.0 of
ColorStop.positionrepresents the center, while 1.0 represents the border.- gradient_center_pos¶
Position of the gradient center.
gradient_center_posis aReferenceListPropertyof (gradient_center_x,gradient_center_y) properties.
- gradient_center_x¶
X-coordinate of the gradient’s center, where 0.0 corresponds to the left edge of the widget and 1.0 to the right edge.
gradient_center_xis anNumericPropertyand defaults to 0.5.
- gradient_center_y¶
Y-coordinate of the gradient’s center, where 0.0 corresponds to the top edge of the widget and 1.0 to the bottom edge.
gradient_center_yis anNumericPropertyand defaults to 0.5.
- radius¶
Radius of the gradient. A larger value extends the gradient effect, while a smaller value contracts it.
radiusis anNumericPropertyand defaults to 1.0.
- static render_texture(**kwargs) Texture¶
Renders gradient at FBO and returns the texture.
- Parameters:
kwargs – Any
RadialGradientproperties.
- class bouquet.gradients.BilinearGradient(**kwargs)¶
Bases:
AnchorLayoutWidget for creating a bilinear gradient background with customizable colors for each corner.
Hint
BilinearGradientis anAnchorLayoutsubclass, so you can put any widget inside it.- bottom_left_color¶
Color of the top bottom corner of gradient.
bottom_left_coloris anColorPropertyand defaults to black.
- bottom_right_color¶
Color of the bottom right corner of gradient.
bottom_right_coloris anColorPropertyand defaults to red.
- static render_texture(**kwargs) Texture¶
Renders gradient at FBO and returns the texture.
- Parameters:
kwargs – Any
BilinearGradientproperties.
- top_left_color¶
Color of the top left corner of gradient.
top_left_coloris anColorPropertyand defaults to green.
- top_right_color¶
Color of the top right corner of gradient.
top_right_coloris anColorPropertyand defaults to yellow.
- class bouquet.gradients.ConicalGradient(**kwargs)¶
Bases:
GradientBaseThe ConicalGradient class provides a way to create conical gradients in Kivy.
A conical gradient is a type of gradient in which colors smoothly blend around a central point, creating a cone-like appearance.
- gradient_center_pos¶
Position of the gradient center.
gradient_center_posis aReferenceListPropertyof (gradient_center_x,gradient_center_y) properties.
- gradient_center_x¶
X-coordinate of the gradient’s center, where 0.0 corresponds to the left edge of the widget and 1.0 to the right edge.
gradient_center_xis anNumericPropertyand defaults to 0.5.
- gradient_center_y¶
Y-coordinate of the gradient’s center, where 0.0 corresponds to the top edge of the widget and 1.0 to the bottom edge.
gradient_center_yis anNumericPropertyand defaults to 0.5.
- static render_texture(**kwargs) Texture¶
Renders gradient at FBO and returns the texture.
- Parameters:
kwargs – Any
ConicalGradientproperties.