API Docs for: 0.1.0
Show:

CG.Bitmap Class

Extends CG.Entity
Module: CG

CG.Bitmap is a simple bitmap class.


                        var b = new CG.Bitmap({
                          width: 100,
                          height: 100
                        })
                        

Methods

AABB

() Object

returns the bounds of rotated rectangle

Returns:

Object:

returns the calculated bounds

checkCollision

(
  • objects
  • callback
)

checks if there is a collision of the given objects to this object http://devmag.org.za/2009/04/13/basic-collision-detection-in-2d-part-1/

Parameters:

  • objects Array

    a array of objects to check for collision => Sprites, Animations, MapAreas

  • callback Callback

    what to do after collision?

clearBuffer

()

clearCircle

(
  • x
  • y
  • radius
)

Parameters:

  • x Number

    the x position for clearCircle

  • y Number

    the y position for clearCircle

  • radius Number

    the radius for clearCircle

clearRect

(
  • x
  • y
  • width
  • height
)

Parameters:

  • x Number

    the x position for clearRect

  • y Number

    the y position for clearRect

  • width Number

    the width for clearRect

  • height Number

    the height for clearRect

drawContour

(
  • vertices
)

draws the traced contour for debuging at the moment

Parameters:

drawImageToBuffer

()

getPixel

(
  • x
  • y
)
Imagedata

Parameters:

  • x Number

    the x position for getPixel

  • y Number

    the y position for getPixel

Returns:

Imagedata:

data from canvas

getPixelAlpha

(
  • x
  • y
)

Parameters:

Returns:

:

getPixels

(
  • x
  • y
  • width
  • height
)
Imagedata

Parameters:

  • x Number

    the x position for getPixels

  • y Number

    the y position for getPixels

  • width Number

    for getPixels

  • height Number

    for getPixels

Returns:

Imagedata:

data from canvas

getSquareValue

(
  • x
  • y
)
Number

get four squared pixels to trace a contour

Parameters:

Returns:

getStartingPixel

() Object | False

scanline trace to get the first pixel

Returns:

Object | False:

ifClicked

() True/false

checks click inside of the rectangle, supports rotation

Returns:

True/false:

ifMouseOver

()

checks if the mouse/pointer is over the rectangle

init

(
  • options
)

Inherited from CG.Entity but overwritten in cangaja/base/bitmap.js:24

Options: width {number} height {number}

Parameters:

Returns:

:

lightenContour

(
  • vertices
  • tolerance
)
Array

removes points that doesn't affect much to the visual appearance. the order after ClipperLib.JS.Lighten is counter clockwise (CCW)

Parameters:

Returns:

loadImage

(
  • imgpath,
)

Loads an image and draws it to the buffer

Parameters:

  • imgpath, String, image, atlasimage

    image object or atlasimage object to use

setImage

(
  • image
)

initialize image for object. for now => sprite, particle, buffer, bitmap and button use it

Parameters:

  • image Image

    image path, image or atlasimage

traceContour

() Array

Returns:

triangulateContour

(
  • vertices
)
array. | | Array

Parameters:

Returns:

array. | | Array:

Properties

bitmap_canvas

Object

bitmap_canvas.height

Number

bitmap_canvas.width

Number

bitmap_ctx

Context

bitmap_ctx.fillStyle

String

boundingradius

Number

clicked

Boolean

dragable

Boolean

height

Number

mapcollision

Boolean

rotation

Number

tolerance

Number

tolerance for the getSquareValues method

transform

Transform

Transform object for matrix transformation

visible

Boolean

visibility option

xhandle

Number

xscale

Number

yhandle

Number

yscale

Number