Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/seymar/pixelmapper
Maps 2D coordinates to an array of pixels, useful for LED strip mapping
https://github.com/seymar/pixelmapper
Last synced: 7 days ago
JSON representation
Maps 2D coordinates to an array of pixels, useful for LED strip mapping
- Host: GitHub
- URL: https://github.com/seymar/pixelmapper
- Owner: seymar
- Created: 2016-08-15T09:55:44.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-10-22T20:51:53.000Z (about 8 years ago)
- Last Synced: 2024-12-15T04:39:42.092Z (about 1 month ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Documentation
### Creating a mapping from components
add - Adds a single pixel
line - Adds a line of pixels
zigzag - Adds a zigzag pattern rectangle of pixels
fillEmpty - Adds a number of pixels without corresponding coordinateExample:
```javascript
// Create a 3x3 zigzag mapping
var mapping = new Pixelmapper()
.zigzag(0, 0, 3, 3, false);
```### Functions to do something with the created mapping
getPixel - Get the pixel at a coordinate
getCoordinate - Get the coordinate of a pixel### Object functions
toJSON - Creates a JSON string that can be used to re-create the mapping using `fromJSON`
fromJSON - Used to create a mapping from a JSON string created with `toSJON`
Instead of using `fromJSON` you can also use the constructor:### Using the JSON conversion functions
The object can be converted and created to JSON:
Example:
```javascript
// Create a 3x3 zigzag mapping
var mapping = new Pixelmapper()
.zigzag(0, 0, 3, 3, false);// Convert object to JSON string
var json = mapping.toJSON();// Create new mapping object from JSON string
var mapping2 = new Pixelmapper(json);// Or:
var mapping3 = new Pixelmapper().fromJSON(json);
```
For the exact arguments of the functions themselves take a look at the comments in `pixelmapper.js`.