Class jaws.PixelMap
jaws.PixelMap
- Defined in: pixel_map.js
Constructor Attributes | Constructor Name and Description |
---|---|
jaws.PixelMap(options)
|
Field Attributes | Field Name and Description |
---|---|
the image of the terrain
|
|
Scale the image by this factor
|
Method Summary
Method Attributes | Method Name and Description |
---|---|
at(x, y)
Read current color at given coordinates X/Y
|
|
draw()
Draws the pixel map on the maincanvas
|
|
nameColor(color, name)
Give a RGBA-array a name.
|
|
namedColorAt(x, y)
Get previously named color if it exists at given x/y-coordinates.
|
|
namedColorAtRect(Rect, Color_Filter)
Trace the outline of a Rect until a named color found.
|
|
update(x, y, width, height)
Updates internal pixel-array from the canvas.
|
Class Detail
jaws.PixelMap(options)
tile_map = new jaws.Parallax({image: "map.png", scale_image: 4}) // scale_image: 4 for retro blocky feeling! tile_map.draw() // draw on canvas tile_map.nameColor([0,0,0,255], "ground") // give the color black the name "ground" tile_map.namedColorAtRect("ground", player.rect()) // True if players boundingbox is touching any black pixels on tile_map
- Parameters:
- options
Field Detail
{string}
image
the image of the terrain
{int}
scale_image
Scale the image by this factor
Method Detail
-
{array} at(x, y)Read current color at given coordinates X/Y
- Parameters:
- x
- y
- Returns:
- {array} 4 integers [R, G, B, A] representing the pixel at x/y
-
draw()Draws the pixel map on the maincanvas
-
nameColor(color, name)Give a RGBA-array a name. Later on we can work with names instead of raw colorvalues.
pixel_map.nameColor([0,0,0,255], "ground") // Give the color black (with no transparency) the name "ground"
- Parameters:
- color
- name
-
{string} namedColorAt(x, y)Get previously named color if it exists at given x/y-coordinates.
- Parameters:
- x
- y
- Returns:
- {string} name or color
-
{string} namedColorAtRect(Rect, Color_Filter)Trace the outline of a Rect until a named color found.
- Parameters:
- {object} Rect
- Instance of jaws.Rect()
- {string} Color_Filter
- Only look for this named color
- Returns:
- {string} name of found color
-
update(x, y, width, height)Updates internal pixel-array from the canvas. If we modify the 'terrain' (paint on pixel_map.context) we'll need to call this method.
- Parameters:
- x
- y
- width
- height