Class ParticleImage

All Implemented Interfaces:
Shape

public class ParticleImage extends ParticleShaper
This class is generally meant to be used with particles that extend ColorableParticle to properly display a colored image
(ParticleDustColored, ParticleEffectColored)
however it allows you to use normal particles to draw detailed objects by reading transparent images
(or by using addIgnoredColor(Color) and setFuzz(int))
  • Field Details

    • rng

      protected final ThreadLocalRandom rng
    • images

      protected final List<BufferedImage> images
    • ignoredColors

      protected final List<Color> ignoredColors
    • xRadius

      protected double xRadius
    • zRadius

      protected double zRadius
    • fuzz

      protected int fuzz
    • frameDelay

      protected int frameDelay
    • frame

      protected int frame
    • displaysThisFrame

      protected int displaysThisFrame
    • currentThread

      protected Thread currentThread
  • Constructor Details

  • Method Details

    • display

      public void display()
      Specified by:
      display in interface Shape
      Specified by:
      display in class ParticleShaper
    • clone

      public ParticleImage clone()
      using this method will cause the current thread to stall until any currently running image production is finished.
      If you don't want to cause lag, use an asynchronous BukkitRunnable!
      Specified by:
      clone in interface Shape
      Overrides:
      clone in class ParticleShaper
    • cloneConstructor

      protected ParticleShaper cloneConstructor()
      Specified by:
      cloneConstructor in class ParticleShaper
    • scale

      public void scale(double x, double y, double z)
      Description copied from interface: Shape
      Rescales this shape such that a shape with the xyz radiuses of 4, 3, 4, resized by 1.25, 1.25, 1.25, would have its radiuses become 5, 3.75, 5.
      Specified by:
      scale in interface Shape
      Overrides:
      scale in class RotationHandler
      Parameters:
      x - x scale
      y - y scale
      z - z scale
    • addOrRemoveImages

      protected void addOrRemoveImages(Object toLoad, boolean remove, int index)
    • addImage

      public void addImage(int index, String link)
      adds an image from a URL (gifs supported!)

      using this method will cause the current thread to stall until any currently running image production is finished.
      If you don't want to cause lag, use an asynchronous BukkitRunnable!
      Parameters:
      index - index to put the image
      link - URL of image
    • addImage

      public void addImage(int index, File path)
      adds an image from a file (gifs supported!)

      using this method will cause the current thread to stall until any currently running image production is finished.
      If you don't want to cause lag, use an asynchronous BukkitRunnable!
      Parameters:
      index - index to put the image
      path - location of file
    • addImage

      public void addImage(String link)
      adds an image from a URL (gifs supported!)

      using this method will cause the current thread to stall until any currently running image production is finished.
      If you don't want to cause lag, use an asynchronous BukkitRunnable!
      Parameters:
      link - URL of image
    • addImage

      public void addImage(File path)
      adds an image from a file (gifs supported!)

      using this method will cause the current thread to stall until any currently running image production is finished.
      If you don't want to cause lag, use an asynchronous BukkitRunnable!
      Parameters:
      path - location of file
    • addIgnoredColor

      public ParticleImage addIgnoredColor(Color color)
    • removeImage

      public void removeImage(String link)
      gets an image from a URL and removes it (gifs supported!)

      using this method will cause the current thread to stall until any currently running image production is finished.
      If you don't want to cause lag, use an asynchronous BukkitRunnable!
      Parameters:
      link - URL of image
    • removeImage

      public void removeImage(File path)
      gets an image from a file and removes it (gifs supported!)

      using this method will cause the current thread to stall until any currently running image production is finished.
      If you don't want to cause lag, use an asynchronous BukkitRunnable!
      Parameters:
      path - location of file
    • removeFrame

      public void removeFrame(int index)
      using this method will cause the current thread to stall until any currently running image production is finished.
      If you don't want to cause lag, use an asynchronous BukkitRunnable!
      Parameters:
      index - index of frame you want to remove from the frame list
    • removeIgnoredColor

      public void removeIgnoredColor(int index)
    • setCurrentFrame

      public void setCurrentFrame(int index)
      using this method will cause the current thread to stall until any currently running image production is finished.
      If you don't want to cause lag, use an asynchronous BukkitRunnable!
      Parameters:
      index - index of frame you want to be displaying
    • setCenter

      public void setCenter(LocationSafe center)
    • setRadius

      public ParticleImage setRadius(double radius)
      using this method will cause the current thread to stall until any currently running image production is finished.
      If you don't want to cause lag, use an asynchronous BukkitRunnable!

      This method uses the current image's aspect ratio to set the X/Z radius, such that the largest side is set to the given radius and the smallest side is set to (smallest / largest) * radius.
      Parameters:
      radius - max radius
    • setXRadius

      public void setXRadius(double xRadius)
    • setZRadius

      public void setZRadius(double zRadius)
    • setFuzz

      public ParticleImage setFuzz(int fuzz)
      Parameters:
      fuzz - how similar pixel colors have to be to ignored colors in order to be ignored
    • setFrameDelay

      public ParticleImage setFrameDelay(int frameDelay)
      Parameters:
      frameDelay - amount of times to display before switching to the next frame
    • getPixelColor

      public Color getPixelColor(int index, int x, int z)
      using this method will cause the current thread to stall until any currently running image production is finished.
      If you don't want to cause lag, use an asynchronous BukkitRunnable!
      Parameters:
      index - frame to get the color from
      x - horizontal position of pixel
      z - vertical position of pixel
      Returns:
      color at pixel
    • getCenter

      public org.bukkit.Location getCenter()
    • getXRadius

      public double getXRadius()
    • getZRadius

      public double getZRadius()
    • getFuzz

      public int getFuzz()
      Returns:
      how similar pixel colors have to be to ignored colors in order to be ignored
    • getFrameDelay

      public int getFrameDelay()
      Returns:
      amount of times to display before switching to the next frame
    • getIgnoredColor

      public Color getIgnoredColor(int index)
    • getIgnoredColorAmount

      public int getIgnoredColorAmount()
    • getFrameAmount

      public int getFrameAmount()
      using this method will cause the current thread to stall until any currently running image production is finished.
      If you don't want to cause lag, use an asynchronous BukkitRunnable!
      Returns:
      amount of images stored