Class WGradient


public class WGradient extends Object
A linear or radial gradient.

See Also:
  • Constructor Details

    • WGradient

      public WGradient()
      Default constructor.

      Creates an empty linear gradient from (0,0) to (1,1) (without color stops).

      See Also:
  • Method Details

    • getStyle

      public GradientStyle getStyle()
      Returns the gradient style.

      See Also:
    • isEmpty

      public boolean isEmpty()
      Returns whether the gradient is empty.

      A gradient is empty if no color stops are defined.

    • setLinearGradient

      public void setLinearGradient(double x0, double y0, double x1, double y1)
      Configures a linear gradient.

      The coordinates describe a line which provides an origin and orientation of the gradient in user-space coordinates.

    • setRadialGradient

      public void setRadialGradient(double cx, double cy, double r, double fx, double fy)
      Configures a radial gradient.

      A radial gradient is described by a center, a radial and a focus point. All coordinates are user-space coordinates.

    • addColorStop

      public void addColorStop(double position, WColor color)
      Adds a color stop.

      For a linear gradient, the position is relative to the position on the line (from 0 to 1 corresponding to p0 to p1).

      For a radial gradient, the position indicates the distance from the center (from 0 to 1 corresponding to center to radius).

    • addColorStop

      public void addColorStop(WGradient.ColorStop colorstop)
      Adds a color stop.

      Adds a color stop.

    • clearColorStops

      public void clearColorStops()
      Removes all color stops.

      See Also:
    • getColorstops

      public List<WGradient.ColorStop> getColorstops()
      Returns the color stops.

      See Also:
    • getLinearGradientVector

      public WLineF getLinearGradientVector()
      Returns the line positioning the linear gradient.

      This returns the line set in setLinearGradient().

    • getRadialCenterPoint

      public WPointF getRadialCenterPoint()
      Returns the center of a radial gradient.

      This returns the center point set in setRadialGradient().

    • getRadialFocalPoint

      public WPointF getRadialFocalPoint()
      Returns the focal point of a radial gradient.

      This returns the focal point set in setRadialGradient().

    • getRadialRadius

      public double getRadialRadius()
      Returns the radius of a radial gradient.

      This returns the radius set in setRadialGradient().

    • equals

      public boolean equals(WGradient other)
      Indicates whether some other object is "equal to" this one.