bHive.Bitmap

Properties

  • src {string}
    Path to the image file
  • x {Int}
    X position on the canvas of the bitmap
  • y {Int}
    Y Position on the canvas of the bitmap
  • registration_x {Int}
    X Origin point of the object
  • registration_y {Int}
    Y Origin point of the object
  • rotation {Int}
    Rotation of the object in degrees
  • visibile {Boolean}
    Boolean value to toggle the visibility of the object
  • alpha {Int}
    Transparency level of the object, 100 being completely opaque, 0 being completely transparent
  • x_scale {Int}
    Percentage of scale in the X direction
  • y_scale {Int}
    Percentage of scale in the Y direction

Constructor

To create a bitmap you need to call the main bHive.createBitmap function with an object constructor. The object constructor’s format is exactly the same as if you were creating an object within JavaScript. This needs to be passed either by variable or direct within the parentheses of the function.

Basic Constructor

myImage = bHive.createBitmap({
    src: 'images/myImage.png',
    x: 10,
    y: 10
});

Methods

Draw

draw([x,y])

The draw method instructs bHive to render the bitmap to the canvas object using the current properties of the object. Example

myImage.draw();

addEventListener

addEventListener(Event, Handler)Events for Bitmaps

  • onload
    Is fired when an image is successfully loaded into the browser cache
  • onerror
    Is fired when an image cannot be loaded

Adding and Event Listener

myImage.addEventListener('onload',myFunction)