This module defines high-level canvas-related types and procedures for working with shapes and gradients in the Impeller rendering engine.
Types
CircleShape = object center*: ImpellerPoint radius*: cfloat
- Represents a circle shape defined by its center point and radius.
GradientColor = object color*: ColorRGBA ## The color of this stop, including alpha for transparency. impellerColor*: ImpellerColor position*: float32 ## The position of this color stop along the gradient, typically in the range [0.0, 1.0].
- Represents a single color stop in a gradient
LinearGradient = object width*, height*: float32 startPoint*, endPoint*: ImpellerPoint colors*: seq[GradientColor] ## The colors for the gradient. The length of this ## sequence should match the length of `stops`. stops*: seq[float32] ## The positions for each color in the gradient, typically in the range [0.0
- Defines a gradient for use in painting operations
RectShape = ImpellerRect
- Represents a rectangle shape with position and dimensions.
Procs
proc addGradientPoint(gradient: var LinearGradient; color: ColorRGBA; position: cfloat) {....raises: [], tags: [], forbids: [].}
- Adds a color stop to the gradient at the specified position.
proc addGradientPoint(gradient: var LinearGradient; color: string; position: float32) {. ...raises: [InvalidColor, ValueError, KeyError], tags: [], forbids: [].}
- Adds a color stop to the gradient using a hex color string.
proc drawCircle(builder: ImpellerDisplayListBuilder; circle: CircleShape; paint: ImpellerPaint) {....raises: [], tags: [], forbids: [].}
proc drawGradient(builder: ImpellerDisplayListBuilder; gradient: var LinearGradient) {....raises: [], tags: [], forbids: [].}
- Draws the specified gradient using the provided display list builder.
proc drawRect(builder: ImpellerDisplayListBuilder; rect: RectShape; color: ColorRGBA) {....raises: [], tags: [], forbids: [].}
- Draws a rectangle with the given color.
proc drawRect(builder: ImpellerDisplayListBuilder; rect: RectShape; color: string) {....raises: [InvalidColor, ValueError, KeyError], tags: [], forbids: [].}
- Draws a rectangle with the given hex color string.
proc initGradientPoint(color: string; position: float32): GradientColor {. ...raises: [InvalidColor, ValueError, KeyError], tags: [], forbids: [].}
- Initializes a gradient color stop from a hex color string and position.
proc initGradientPointAlpha(color: string; alpha: uint8; position: float32): GradientColor {. ...raises: [InvalidColor, ValueError, KeyError], tags: [], forbids: [].}
- Initializes a gradient color stop from a hex color string, alpha value, and position.
proc initGradientPointHexAlpha(color: Color; position: float32): GradientColor {. ...raises: [], tags: [], forbids: [].}
- Initializes a gradient color stop from a Color object with alpha and position.
proc initGradientPointHexAlpha(color: string; position: float32): GradientColor {. ...raises: [InvalidColor], tags: [], forbids: [].}
- Initializes a gradient color stop from a hex color string with alpha and position.
proc initLinearGradient(colors: seq[GradientColor]; startPoint: ImpellerPoint = ImpellerPoint( x: 0.0, y: 0.0); endPoint: ImpellerPoint = ImpellerPoint(); width: float32 = 100.0'f32; height: float32 = 100.0'f32): LinearGradient {. ...raises: [], tags: [], forbids: [].}
- Creates a new linear gradient with the specified colors and points.
proc newCircle(radius: float32; x: float32 = 0.0; y: float32 = 0.0): CircleShape {. ...raises: [], tags: [], forbids: [].}
- Creates a new circle shape with the specified center and radius.
proc newRectangle(width, height: float32; x, y: float32 = 0.0): RectShape {. ...raises: [], tags: [], forbids: [].}
- Creates a new rectangle shape with the specified position and dimensions.
proc setColor(paint: ImpellerPaint; color: ColorRGBA) {....raises: [], tags: [], forbids: [].}
- Sets the color of the given paint object using a ColorRGBA value.
proc setColor(paint: ImpellerPaint; color: ImpellerColor) {....raises: [], tags: [], forbids: [].}
- Sets the color of the given paint object using an ImpellerColor.
proc setColor(paint: ImpellerPaint; color: string) {. ...raises: [InvalidColor, ValueError, KeyError], tags: [], forbids: [].}
- Sets the color of the given paint object using a hex color string.