Class Paint

A structure type that describes a color, linear gradient, box gradient or radial gradient painting options.

Solid color paint is the most basic type of paint. They are just a single color that fills the entire region to be painted.

The linear gradient paint is a type of paint that creates a linear gradient, that is, a gradient that goes from one color to another in a unique direction.

The linear gradient is composed of: - The starting and ending colors; - Two vectors that represent where the gradient should start and where it should end. Values above or below those limits get clamped to their maximum or minimum.

The box gradient paint is a type of paint that creates a rectangular gradient. This gradient type is very common in user interfaces to create shadow and highlight effects.

The box gradient is composed of: - The starting and ending colors; - A rectangle that defines the boundaries of the gradient;

  • A radius that defines how the gradient box should round it's corners; - A feather value. This defines how blurry the border of the rectangle is.

The radial gradient paint is a type of paint that creates a circular gradient whose colors are interpolated based on it's distance from the center.

The radial gradient is composed of: - The starting and ending colors; - A center vector that defines the place where the gradient starts; - A inner and outer radius that represent where the gradient should start and where it should end. Values above or below those limits get clamped to their maximum or minimum.

Hierarchy

  • FrameworkObject
    • Paint

Constructors

  • Parameters

    • OptionalisInternalConstructor: boolean

    Returns Paint

Accessors

  • get type(): EnumValue<PaintType, number>
  • The current paint type. Use this method to check the paint type before accessing members of this class.

    Returns EnumValue<PaintType, number>

Methods

  • Creates a box gradient. Box gradient is a feathered rounded rectangle, it is useful for rendering drop shadows or highlights for boxes.

    Parameters

    • rect: Immutable<Rect2>

      The size and position of the box gradient rectangle.

    • startingColor: Immutable<Color>

      The gradient starting color.

    • endingColor: Immutable<Color>

      The gradient ending color.

    • Optionalradius: number

      Defines the rectangle corner radius.

    • Optionalfeather: number

      Defines the rectangle feather. Feather defines how blurry the border of the rectangle is.

    Returns Paint

    A newly created paint object.

  • Creates a linear gradient.

    Parameters

    Returns Paint

    A newly created paint object.

  • Creates a radial gradient.

    Parameters

    • center: Immutable<Vector2>

      The center point of the radial gradient.

    • innerRadius: number

      The inner radius of the gradient.

    • outerRadius: number

      The outer radius of the gradient.

    • startingColor: Immutable<Color>

      The gradient starting color.

    • endingColor: Immutable<Color>

      The gradient ending color.

    Returns Paint

    A newly created paint object.