ImageAtlas API Reference


b5.ImageAtlas

An Image Atlas (also known as an Image Brush) represents a bitmap and a collection of sub images within that bitmap. Generally an ImageAtlas should be added to either a scene or the global app’s resources so that it can be managed by them. Image atlases are used by Actors to create frame based bitmap animations.

Public properties

  • name – The name of the ImageAtlas, this name is used when searching for brush resources in a Scene’s resources or the the app’s global resources
  • parent – The parent container
  • bitmap – The bitmap object that images will be used as a source for sub images

Internal properties

  • frames – Array of atlas frame objects in the form {x, y, w, h}

Methods

ImageAtlas(name, bitmap, x, y, w, h) – Creates an instance of an ImageAtlas

  • The name of the ImageAtlas, this name is used when searching for brush resources in a Scene’s resources or the the app’s global resources
  • bitmap – The source bitmap object
  • x, y, w, h – The top-left position and width / height of the initial atlas frame (optional)

addFrame(sx, sy, sw, sh) – Adds a new frame to the atlas

  • sx, sy – Top-left hand position of sub image
  • sw. sh, Width and height of the sub image

getFrame(index) – Returns the frame at the specified index

  • index – The index of the requested frame
  • returns the specified frame object

getMaxFrames() – Returns total number of available frames in this atlas

generate(start_x, start_y, frame_w, frame_h, count_x, count_y, total) – Generates multiple atlas frames, working from left to right, top to bottom

  • start_x – Start x position
  • start_y – Start y position
  • frame_w – The width of each frame
  • frame_h – The height of each frame
  • count_x – Total frames to generate across the image
  • count_y – Total frames to generate down the image
  • total – Optional parameter that can be used to limit total number of generated frames

destroy() – Removes the atlas from the scene / app and destroys it

Examples

Adding bitmap animation to an actor

Automatically generating frames

 

686 total views, 1 views today