CG.Bitmap Class
CG.Bitmap is a simple bitmap class.
var b = new CG.Bitmap({
width: 100,
height: 100
})
Item Index
Methods
Methods
AABB
()
Object
returns the bounds of rotated rectangle
Returns:
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
Arraya array of objects to check for collision => Sprites, Animations, MapAreas
-
callback
Callbackwhat to do after collision?
clearBuffer
()
clearCircle
-
x
-
y
-
radius
clearRect
-
x
-
y
-
width
-
height
drawContour
-
vertices
draws the traced contour for debuging at the moment
Parameters:
-
vertices
Array
drawImageToBuffer
()
getPixel
-
x
-
y
Returns:
data from canvas
getPixels
-
x
-
y
-
width
-
height
Parameters:
Returns:
data from canvas
ifClicked
()
True/false
checks click inside of the rectangle, supports rotation
Returns:
ifMouseOver
()
checks if the mouse/pointer is over the rectangle
lightenContour
-
vertices
-
tolerance
removes points that doesn't affect much to the visual appearance. the order after ClipperLib.JS.Lighten is counter clockwise (CCW)
Returns:
loadImage
-
imgpath,
Loads an image and draws it to the buffer
Parameters:
-
imgpath,
String, image, atlasimageimage object or atlasimage object to use
setImage
-
image
initialize image for object. for now => sprite, particle, buffer, bitmap and button use it
Parameters:
-
image
Imageimage path, image or atlasimage
traceContour
()
Array
trace the outer contour of an bitmap body clockwise (CW) http://www.emanueleferonato.com/2013/03/01/using-marching-squares-algorithm-to-trace-the-contour-of-an-image/)
Returns:
Properties
bitmap_ctx
Context
transform
Transform
Transform object for matrix transformation