Skip to main content

LinearGradient

LinearGradient class has the following properties:

  • begin - An instance of Alignment class. The offset at which stop 0.0 of the gradient is placed.
  • end - An instance of Alignment class. The offset at which stop 1.0 of the gradient is placed.
  • colors - The colors the gradient should obtain at each of the stops. If stops is non-null, this list must have the same length as stops. This list must have at least two colors in it (otherwise, it's not a gradient!).
  • stops - A list of values from 0.0 to 1.0 that denote fractions along the gradient. If non-null, this list must have the same length as colors. If the first value is not 0.0, then a stop with position 0.0 and a color equal to the first color in colors is implied. If the last value is not 1.0, then a stop with position 1.0 and a color equal to the last color in colors is implied.
  • tile_mode - How this gradient should tile the plane beyond in the region before begin and after end. The value is GradientTileMode enum with supported values: CLAMP (default), DECAL, MIRROR, REPEATED. More info here.
  • rotation - rotation for the gradient, in radians, around the center-point of its bounding box.

More information:

Example of usage

Container(
gradient=ft.LinearGradient(
begin=ft.alignment.top_center,
end=ft.alignment.bottom_center,
colors=[ft.colors.BLUE, ft.colors.YELLOW],
),
width=150,
height=150,
border_radius=5,
)