Class LinearGradient

java.lang.Object
com.codename1.ui.Gradient
com.codename1.ui.LinearGradient
All Implemented Interfaces:
Paint

public final class LinearGradient extends Gradient

Multi-stop linear gradient at an arbitrary angle. Mirrors CSS linear-gradient(<angle>, <stops>). Angle is in CSS degrees: 0 points up (toward the top edge), 90 right, 180 down, 270 left.

Since

8.1

  • Constructor Details

    • LinearGradient

      public LinearGradient(float angleDegrees, int[] colors, float[] positions)
      Creates a linear gradient at the given angle with the given stops.
  • Method Details

    • getKind

      public byte getKind()
      Description copied from class: Gradient
      Returns one of KIND_LINEAR, KIND_RADIAL, KIND_CONIC.
      Specified by:
      getKind in class Gradient
    • getAngleDegrees

      public float getAngleDegrees()
    • setAngleDegrees

      public LinearGradient setAngleDegrees(float angleDegrees)
    • computeEndpoints

      public void computeEndpoints(int width, int height, float[] out)
      Computes the endpoints of the gradient line for a rectangle of the given width / height (rect origin at (0,0)). Output is x0,y0,x1,y1.
    • sampleArgb

      public int sampleArgb(int px, int py, int width, int height)
      Description copied from class: Gradient
      Software-rasterizer hook used by the default port implementation when no native gradient shader is available. Samples an ARGB color for the pixel at (px, py) within a rectangle of the given width / height. Ports overriding fillGradient directly do not call this.
      Specified by:
      sampleArgb in class Gradient
    • copy

      public LinearGradient copy()
      Description copied from class: Gradient
      Returns a defensive deep copy. Implemented by each concrete subclass so async-paint queues can capture an immutable snapshot.
      Specified by:
      copy in class Gradient