Package snap.gfx

Class ImagePaint

java.lang.Object
snap.gfx.ImagePaint
All Implemented Interfaces:
Paint, XMLArchiver.Archivable

public class ImagePaint extends Object implements Paint, XMLArchiver.Archivable
A paint implementation to fill shapes with an image pattern.
  • Constructor Details

    • ImagePaint

      public ImagePaint()
      Creates a new ImagePaint.
    • ImagePaint

      public ImagePaint(Image anImage)
      Creates a new ImagePaint.
    • ImagePaint

      public ImagePaint(Image anImage, Rect aRect)
      Creates a new ImagePaint.
    • ImagePaint

      public ImagePaint(Image anImage, Rect aRect, boolean isAbs)
      Creates a new ImagePaint.
    • ImagePaint

      public ImagePaint(Image anImage, double aX, double aY, double aW, double aH, boolean isAbs)
      Creates a new ImagePaint.
  • Method Details

    • getImage

      public Image getImage()
      Returns the image.
    • getX

      public double getX()
      Returns the bounds x.
    • getY

      public double getY()
      Returns the bounds y.
    • getWidth

      public double getWidth()
      Returns the bounds width.
    • getHeight

      public double getHeight()
      Returns the bounds height.
    • getBounds

      public Rect getBounds()
      Returns the bounds.
    • getScaleX

      public double getScaleX()
      Returns the scale x of the image fill image.
    • getScaleY

      public double getScaleY()
      Returns the scale y of the image fill image.
    • isTiled

      public boolean isTiled()
      Returns whether paint is defined in terms independent of primitive to be filled.
    • isAbsolute

      public boolean isAbsolute()
      Returns whether paint is defined in terms independent of primitive to be filled.
      Specified by:
      isAbsolute in interface Paint
    • isOpaque

      public boolean isOpaque()
      Returns whether paint is opaque.
      Specified by:
      isOpaque in interface Paint
    • getColor

      public Color getColor()
      Returns the closest color approximation of this paint.
      Specified by:
      getColor in interface Paint
    • copyForColor

      public Paint copyForColor(Color aColor)
      Returns a copy of this paint modified for given color.
      Specified by:
      copyForColor in interface Paint
    • copyForRect

      public ImagePaint copyForRect(Rect aRect)
      Returns an absolute paint for given bounds of primitive to be filled.
      Specified by:
      copyForRect in interface Paint
    • copyForRectAndTile

      public ImagePaint copyForRectAndTile(Rect aRect, boolean isAbs)
      Returns an paint for given bounds and absolute flag.
    • copyTiled

      public ImagePaint copyTiled(boolean isTiled)
      Creates a new image fill identical to this image fill, but with new value for given attribute.
    • copyForScale

      public ImagePaint copyForScale(double aScaleX, double aScaleY)
      Creates a new image fill identical to this image fill, but with new value for given attribute.
    • equals

      public boolean equals(Object anObj)
      Standard equals implementation.
      Overrides:
      equals in class Object
    • toXML

      public XMLElement toXML(XMLArchiver anArchiver)
      XML archival.
      Specified by:
      toXML in interface XMLArchiver.Archivable
    • fromXML

      public Object fromXML(XMLArchiver anArchiver, XMLElement anElement)
      XML unarchival.
      Specified by:
      fromXML in interface XMLArchiver.Archivable
    • toString

      public String toString()
      Standard toString implementation.
      Overrides:
      toString in class Object