new Tiles(data)
- Source:
Properties:
Name | Type | Description |
---|---|---|
data |
Array | A 2D Array of tile values. |
Creates an instance of Tiles
Example
// Both calls create the same set of object tiles
const { Tiles } = require('lucid-dream');
const tiles1 = new Tiles([ [ 1, 2 ], [ 3, 4 ] ]);
const tiles2 = new Tiles('12\n34\n');
Parameters:
Name | Type | Description |
---|---|---|
data |
Array | String | A 2D Array of tile values, or a String of values for a 2D Array of tiles. |
Methods
minimizeTilesString(emptyValueopt, separatoropt) → {String}
- Source:
Using the 2D Array of tile data in the Tiles object, generate a minimized String version for encoding.
Example
// returns '123\n120\n'
const { Tiles } = require('lucid-dream');
const tiles = new Tiles('1230\n1200\n');
tiles.minimizeTilesString('0', '');
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
emptyValue |
String |
<optional> |
'0'
|
This string is considered the "empty" value in a set of tile values and is used to determine how to minimize the resulting encoded string. |
separator |
String |
<optional> |
'0'
|
The separator for vales in the resulting encoded string. |
Returns:
The minimized encoded tile data string
- Type
- String
size()
- Source:
Returns [width,height]
size of instance in pixels
Example
// returns `[ 32, 16 ]`
const { Tiles } = require('lucid-dream');
const tiles = new Tiles('1111\n2234\n');
tiles.size();