Sprites
Sprites
are graphical representations made up of multi-line character strings. Each line corresponds to a row of pixels, and each character represents an individual pixel.
- Digits (0-9): Each digit corresponds to a specific color, for instance: 0 for black, 1 for white, 2 for gray, etc.
- New lines: Indicate the start of a new row of pixels.
- Whitespace, tabs, and blank lines: Are ignored and do not affect the sprite’s display.
- Other characters: Represent a transparent pixel.
Tip
To create a solid rectangle, simply use the digit for the desired color.
Dimensions
By default, sprites
are 8x8 pixel squares. You can adjust this size by modifying the cellWidth
and cellHeight
properties.
Colors
Default Colors
Here is a table of default colors with their hexadecimal codes:
Index | Color | Hex Code |
---|---|---|
0 | black | #212529 |
1 | white | #f8f9fa |
2 | gray | #ced4da |
3 | blue | #228be6 |
4 | red | #fa5252 |
5 | yellow | #fcc419 |
6 | orange | #ff922b |
7 | green | #40c057 |
8 | pink | #f06595 |
9 | brown | #a52f01 |
Note
These colors come from the excellent open-color palette.
Customizing Colors
You can customize the colors used for sprites
by defining an array of strings that can be interpreted as CSS colors. These colors can be hexadecimal codes, color names, RGB values, etc.
Example: