Images

Image | CompositeImage

 

Image
class : GenericImage, RequiresCleanup
  • DESCRIPTION
    • Wrapper class for a hardware-accelerated image. Image objects don't contain the actual image data, but instead store an index that the native layer uses to identify images.
  • PROPERTIES
    • size : Vector2
      • The nominal size of the given image, in pixels. Change 'size' if you want the image's standard size to be a given number of pixels or change 'scale' if you want the image to be proportionally larger or smaller.
    • scale : Vector2
      • The size multiplier for rendering, (1.0,1.0) by default. Setting "scale = Vector2(2.0,0.5)" would cause the image to render at twice the width and half the height. Change 'size' instead if you want to achieve particular pixel dimensions.
    • handle : Vector2
      • Specifies the drawing and rotation origin of this image. This can be set to a pixel value relative to the upper-left of the image (0,0) or a Handle category such as "Handle.center" or "Handle.bottom_center". The handle is the top-left corner (0,0) by default.
    • color : Color
      • The multiplier for each pixel in this image as it's drawn. The default color of Color(255,255,255,255) ensures that the image will appear "normal". A color of Color(255,255,0) would not draw any of the blue channel, making a grey-scale image appear to be tinted yellow. A color of Color(255,255,255,128) would draw the image halfway transparent.
    • render_flags : Render
      • Any combination of Render constants, or 0 for no special rendering options.
      • Example:
          ghost.render_flags = (Render.overexpose | Render.fixed_color)
        
    • blend : Blend
      • Blending mode. See class BlendManager for more examples.
    • angle : Radians
      • The angle property variable. This may be set to a new Radians or Degrees value.
    • hflip : Logical
      • Specifies that an image should be flipped horizontally when drawn. This mirroring is applied before the image is rotated and does not affect the spatial positioning.
    • vflip : Logical
      • Specifies that an image should be flipped vertically when drawn. This mirroring is applied before the image is rotated and does not affect the spatial positioning.
    • alpha : Int32
      • Internal use. Prevents 'alpha' from being declared again by mistake and being intercepted by access methods.
    • texture : Texture
      • The index used to identify the associated image to the native layer.
    • uv : Corners
      • The texture (u,v) coordinates, each [0..1].
    • texture_sheet_corner : Vector2
      • Typically used to keep track of where this image's texture resides on its texture sheet.
    • alpha_mask : Image
      • Another image to take alpha values from when this image is drawn. If "null" (default), both alpha and color values are taken from this image.
    • manager : TextureSheetManager
      • Internal use. If non-null, is the object that manages the texture data for this image.
  • METHODS
    • init(String filename[,String texture_sheet_name][,Int32 pixel_format])
      • Creates an image from the given png or jpeg file. Some platforms may support additional formats.
      • The following variations of 'filename' are checked:
      •   filename
          filename.ext  (.ext = [.png|.jpg|.jpeg])
          data/filename
          data/filename.ext
        
        

        'pixel_format' is a pixel format suggestion for how the loaded image should be stored in video memory. Choices are "rgb32", "rgb16", and "indexed".

      • Note: if a PNG isn't loading correctly, try running Ken Silverman's PNGOUT program on it. This is a good idea anyways as PNGOUT compression is generally better and decompresses faster than normal PNG compression.
    • init(Bitmap src_bitmap[,String texture_sheet_name][,Int32 pixel_format])
      • Creates an image from the given software bitmap.
      • 'pixel_format' is a pixel format suggestion for how the loaded image should be stored in video memory. Choices are "rgb32", "rgb16", and "indexed".
    • init(Image existing,Int32 x,Int32 y,Int32 w,Int32 h)
      • Creates an image as a subset of an existing image. The actual texture is shared with the original image; only a minimal amount of additional memory is required.
      • Parameters:
          existing
            An existing image to pick a subset of.
        
          x,y
            The top-left corner of the image subset relative to the
            top-left corner of the existing image.
        
          w,h
            The width and height of the image subset.
        
    • init(Image existing,Vector2 top_left,Vector2 init:size)
      • Creates an image as a subset of an existing image. The actual texture is shared with the original image; only a minimal amount of additional memory is required.
      • Parameters:
          existing
            An existing image to pick a subset of.
        
          top_left
            The top-left corner of the image subset relative to the
            top-left corner of the existing image.
        
          size
            The width and height of the image subset.
        
    • init(Image existing,Box box)
      • Creates an image as a subset of an existing image. The actual texture is shared with the original image; only a minimal amount of additional memory is required.
      • Parameters:
          existing
            An existing image to pick a subset of.
        
          box
            The rectangular region of the desired subset.
        
    • clean_up()
      • Internal use. Calls release().
    • release()
    • hash_code().Int32
    • alpha_mask(Image new_alpha_mask)
    • draw(Vector2 v)
    • draw(Box box)
      • Draws this image at the specified rectangular coordinates.
    • draw(Box box,ColorGradient colors)
      • Draws this image at the specified rectangular coordinates with the given corner colors.
    • draw(Quad q)
      • Draws this image at the specified quadrangular coordinates.
    • draw(Quad q,ColorGradient colors)
      • Draws this image at the specified quadrangular coordinates with the given corner colors.
    • crop(Real64 pixels_to_contract)
      • Contracts the edge UV texture coordinates by 'pixels_to_contract' along each edge and reduces the 'size' of this image by "2*pixels_to_contract" in each dimension.
      • The existing 'size' is used to calculate how much the UV coordinates should be adjusted by.
      • Does not change the 'handle', which may need to be reset.
    • crop(Box bounds)
      • Adjusts the UV coordinates and size of this image to match the pixel dimensions of the given 'bounds' box.
      • Does not change the 'handle', which may need to be reset.
    • split_into_tiles(Int32 tiles_wide,Int32 tiles_high).Image[]
      • Splits this Image into a list of separate Image tiles.
    • init_object()
    • create_duplicate().Object
    • to_String().String
    • op==(Object other).Logical {multimethod}
    • op<>(Object other).Logical {multimethod}
    • type_name().String : native
    • runtime_type().RuntimeType : native
    • runtime_properties().RuntimeProperties
    • runtime_methods().RuntimeMethods
    • handle(Vector2 new_handle)
    • handle(Handle h)
    • angle(Radians new_angle)
    • angle(Degrees deg)
    • scale(Vector2 new_scale)
    • scale(Real64 uniform_scale)
    • point_filter(Logical setting)
    • point_filter().Logical
    • fixed_color(Logical setting)
    • fixed_color().Logical
    • texture_wrap(Logical setting)
    • texture_wrap().Logical
    • alpha().Int32
    • alpha(Int32 new_alpha)
    • bounding_box().Box
    • bounding_circle().Circle
    • draw(Real64 x,Real64 y)
    • clear([Color c])

 

CompositeImage
class : Panel, RequiresCleanup
  • DESCRIPTION
    • A composite image is designed for loading and displaying large splash screens and other background graphics. Upon initialization it loads a given image and then breaks it up into 256x256-pixel chunks - which are then redrawn pieced together as a whole.
  • PROPERTIES
    • size : Vector2
      • The nominal size of the given image, in pixels. Change 'size' if you want the image's standard size to be a given number of pixels or change 'scale' if you want the image to be proportionally larger or smaller.
    • scale : Vector2
      • The size multiplier for rendering, (1.0,1.0) by default. Setting "scale = Vector2(2.0,0.5)" would cause the image to render at twice the width and half the height. Change 'size' instead if you want to achieve particular pixel dimensions.
    • handle : Vector2
      • Specifies the drawing and rotation origin of this image. This can be set to a pixel value relative to the upper-left of the image (0,0) or a Handle category such as "Handle.center" or "Handle.bottom_center". The handle is the top-left corner (0,0) by default.
    • color : Color
      • The multiplier for each pixel in this image as it's drawn. The default color of Color(255,255,255,255) ensures that the image will appear "normal". A color of Color(255,255,0) would not draw any of the blue channel, making a grey-scale image appear to be tinted yellow. A color of Color(255,255,255,128) would draw the image halfway transparent.
    • render_flags : Render
      • Any combination of Render constants, or 0 for no special rendering options.
      • Example:
          ghost.render_flags = (Render.overexpose | Render.fixed_color)
        
    • blend : Blend
      • Blending mode. See class BlendManager for more examples.
    • angle : Radians
      • The angle property variable. This may be set to a new Radians or Degrees value.
    • hflip : Logical
      • Specifies that an image should be flipped horizontally when drawn. This mirroring is applied before the image is rotated and does not affect the spatial positioning.
    • vflip : Logical
      • Specifies that an image should be flipped vertically when drawn. This mirroring is applied before the image is rotated and does not affect the spatial positioning.
    • alpha : Int32
      • Internal use. Prevents 'alpha' from being declared again by mistake and being intercepted by access methods.
    • parent : Panel
      • The parent Panel of this component.
    • position : Vector2
      • The position this component is drawn at.
    • screen_to_view : Transform
      • Internal use - used to transform raw mouse positions into screen coordinates.
    • active : Logical
      • When "true" this component receives messages (including calls to update() and draw()) normally.
    • components : Component[]
      • A list of child components contained in this Panel.
  • METHODS
    • init(String filename[,String sheet_name])
      • Initializes this CompositeImage to draw the given image.
    • init(Bitmap bmp[,String sheet_name])
      • Initializes this CompositeImage to draw the given bitmap.
    • init(Vector2 init:size)
      • Initializes this object to an empty image of the given size. Additional image subparts may be added with the add() method.
    • add(GenericImage img,Vector2 offset)
      • Adds 'img' to this composite image - 'img' may be an Image or a CompositeImage object. It will be drawn with its handle at 'offset' relative to the top-left corner of this image.
    • draw-inner()
    • release()
      • Calls release() on each of this CompositeImage object's constituent parts.
    • clean_up()
    • init_object()
    • hash_code().Int32
    • create_duplicate().Object
    • to_String().String
    • op==(Object other).Logical {multimethod}
    • op<>(Object other).Logical {multimethod}
    • type_name().String : native
    • runtime_type().RuntimeType : native
    • runtime_properties().RuntimeProperties
    • runtime_methods().RuntimeMethods
    • handle(Vector2 new_handle)
    • handle(Handle h)
    • angle(Radians new_angle)
    • angle(Degrees deg)
    • scale(Vector2 new_scale)
    • scale(Real64 uniform_scale)
    • point_filter(Logical setting)
    • point_filter().Logical
    • fixed_color(Logical setting)
    • fixed_color().Logical
    • texture_wrap(Logical setting)
    • texture_wrap().Logical
    • alpha().Int32
    • alpha(Int32 new_alpha)
    • bounding_box().Box
    • bounding_circle().Circle
    • draw(Real64 x,Real64 y)
    • clear([Color c])
    • on(KeyEvent event)
    • on(MouseEvent event)
    • on(JoystickEvent event)
    • on(AccelerationEvent event)
    • on(SystemEvent event)
    • listen_to(DispatcherType dispatcher)
    • stop_listening_to(DispatcherType dispatcher)
    • init(Panel init:parent)
    • push_transform()
    • pop_transform()
    • draw(Vector2 init:position)
    • draw()
    • update()
    • fill(Color c)
    • bring_to_front()
  • CompositeImage currently extends Panel which is an inappropriate base class.  It will be reworked to extend GenericImage soon.