Class CelestialSprite

java.lang.Object
com.massifmaps.celestial.CelestialObject
com.massifmaps.celestial.CelestialSprite

public class CelestialSprite extends CelestialObject
A flat, camera-facing object in the sky: a disc, a point of light, an icon overhead.

Its size is given either as an ANGULAR size in degrees - which is what a real body has, so it
grows and shrinks with the field of view like everything else in the world - or as a fixed
SCREEN size in pixels, which is what an icon or a marker wants. A sprite with no bitmap is
drawn as a soft disc in its own color, which is enough for most bodies and costs no
texture at all.
  • Constructor Details

    • CelestialSprite

      public CelestialSprite()
  • Method Details

    • getAngularSize

      public float getAngularSize()
      Returns the angular size of the sprite.
      Returns:
      The angular diameter in degrees, or 0 if the sprite is sized in pixels.
    • setAngularSize

      public void setAngularSize(float degrees)
      Sets the angular size of the sprite, the way a real body is measured - the disc then
      covers the same angle whatever the field of view.
      Parameters:
      degrees - The angular diameter in degrees.
    • getScreenSize

      public float getScreenSize()
      Returns the screen size of the sprite.
      Returns:
      The diameter in pixels, or 0 if the sprite is sized by angle.
    • setScreenSize

      public void setScreenSize(float pixels)
      Sets a fixed on-screen size, in pixels, independent of the field of view. Use this for
      icons and markers rather than for bodies.
      Parameters:
      pixels - The diameter in pixels.
    • getBitmap

      public Bitmap getBitmap()
      Returns the bitmap of the sprite.
      Returns:
      The bitmap, or null if the sprite is drawn as a plain disc.
    • setBitmap

      public void setBitmap(Bitmap bitmap)
      Sets the bitmap of the sprite. Sprites are batched per bitmap, so objects that share one
      bitmap - a catalogue of thousands, for instance - cost a single draw call.
      Parameters:
      bitmap - The new bitmap, or null to draw a plain disc.
    • getSoftness

      public float getSoftness()
      Returns the edge softness of a disc sprite.
      Returns:
      The softness, 0 for a hard edge and 1 for a fully soft one.
    • setSoftness

      public void setSoftness(float softness)
      Sets the edge softness of a disc sprite. It has no effect on a sprite with a bitmap.
      Parameters:
      softness - The softness, 0 for a hard edge and 1 for a fully soft one.
    • getClickRadius

      public float getClickRadius()
      Returns the extra radius that responds to a click.
      Returns:
      The extra click radius in degrees.
    • setClickRadius

      public void setClickRadius(float degrees)
      Sets an extra angular radius that responds to a click, added to the sprite's own size. A
      sprite half a pixel across is impossible to hit otherwise.
      Parameters:
      degrees - The extra click radius in degrees.