TTkColorGradient

TTkColorGradient🌶️

class TTkColorGradient(increment: int | None = None, fgincrement: int = 0, bgincrement: int = 0, orientation: Direction = Direction.VERTICAL)[source]🌶️

Bases: TTkColorModifier

Create a linear incremental gradient modifier.

Parameters:
  • increment (int | None) – shared increment for foreground and background; when provided it overrides fgincrement and bgincrement

  • fgincrement (int) – foreground incremental step when increment is not provided

  • bgincrement (int) – background incremental step when increment is not provided

  • orientation (TTkK.Direction) – gradient direction, either TTkK.Direction.VERTICAL or TTkK.Direction.HORIZONTAL

Methods🌶️

copy()[source]🌶️

Return a gradient modifier copy sharing the computed cache.

The returned instance keeps the same increments and orientation, and shares the internal cache to avoid recomputing gradient steps.

Returns:

copied gradient modifier

Return type:

TTkColorGradient

exec(x, y, color) TTkColor[source]🌶️

Apply the gradient to a color at the given canvas position.

Parameters:
  • x (int) – horizontal coordinate

  • y (int) – vertical coordinate

  • color (TTkColor) – source color

Returns:

transformed color

Return type:

TTkColor

setParam(*args, **kwargs) None[source]🌶️

Set runtime parameters used during gradient evaluation.

Accepted kwargs are val (base offset) and step (scaling factor).