Class HalftoneGradient

  • All Implemented Interfaces:
    Paint, Transparency


    public class HalftoneGradient
    extends TransformedTexturePaint
    A gradient that resembles halftoning.

    This creates an image as a tile and uses an underlying TexturePaint to do most of the rendering.

    • Field Detail

      • DEFAULT_WIDTH

        public static final int DEFAULT_WIDTH
        The default suggested width for the tiled pattern.
        See Also:
        Constant Field Values
      • cycle

        protected boolean cycle
      • x1

        protected final double x1
      • y1

        protected final double y1
      • x2

        protected final double x2
      • y2

        protected final double y2
      • color1

        protected final int color1
      • color2

        protected final int color2
    • Constructor Detail

      • HalftoneGradient

        public HalftoneGradient(Point2D p1,
                                Color c1,
                                Point2D p2,
                                Color c2)
        Create a new HalftoneGradient using circles and the default width.
        Parameters:
        p1 - the first point.
        c1 - the first color.
        p2 - the second point.
        c2 - the second color.
      • HalftoneGradient

        public HalftoneGradient(Point2D p1,
                                Color c1,
                                Point2D p2,
                                Color c2,
                                int width,
                                int type,
                                boolean cycle,
                                float offset,
                                float shear)
        Create a new HalftoneGradient.
        Parameters:
        p1 - the first point.
        c1 - the first color.
        p2 - the second point.
        c2 - the second color.
        width - the width of the repeating pattern.
        type - the type (TYPE_DIAMOND, TYPE_CIRCLE or TYPE_TRIANGLE)
        cycle - whether this gradient repeats or not.
        offset - a float from [0,1] that can be used to animate this gradient.
        shear - a float (default should be zero) that shears the transform. In general this should be between [-2,2] for best results.
      • HalftoneGradient

        public HalftoneGradient(float x1,
                                float y1,
                                Color c1,
                                float x2,
                                float y2,
                                Color c2,
                                int width,
                                int type,
                                boolean cycle,
                                float offset,
                                float shear)
        Create a new HalftoneGradient.
        Parameters:
        x1 - the x-coordinate of the first point.
        y1 - the y-coordinate of the first point.
        c1 - the first color.
        x2 - the x-coordinate of the second point.
        y2 - the y-coordinate of the second point.
        c2 - the second color.
        width - the width of the repeating pattern.
        type - the type (TYPE_DIAMOND, TYPE_CIRCLE or TYPE_TRIANGLE)
        cycle - whether this gradient repeats or not.
        offset - a float from [0,1] that can be used to animate this gradient.
        shear - a float (default should be zero) that shears the transform. In general this should be between [-2,2] for best results.
    • Method Detail

      • getPoint1

        public Point2D getPoint1()
        Returns a copy of the point P1 that anchors the first color.
        Returns:
        a copy of the point that anchors the first color.
      • getPoint2

        public Point2D getPoint2()
        Returns a copy of the point P2 which anchors the second color.
        Returns:
        a copy of the point that anchors the second color.
      • getColor1

        public Color getColor1()
        Returns the color C1 anchored by the point P1.
        Returns:
        the first color anchored by the point P1.
      • getColor2

        public Color getColor2()
        Returns the color C2 anchored by the point P2.
        Returns:
        the second color anchored by the point P2.