Skip to content

Commit

Permalink
updat egraphics docs for setCOlor
Browse files Browse the repository at this point in the history
  • Loading branch information
gfwilliams committed Sep 24, 2018
1 parent cd81964 commit 8ef686d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions libs/graphics/jswrap_graphics.c
Expand Up @@ -545,7 +545,18 @@ void jswrap_graphics_setPixel(JsVar *parent, int x, int y, JsVar *color) {
["b","JsVar","Blue (between 0 and 1)"]
]
}
Set the color to use for subsequent drawing operations
Set the color to use for subsequent drawing operations.
If just `r` is specified as an integer, the numeric value will be written directly into a pixel. eg. On a 24 bit `Graphics` instance you set bright blue with either `g.setColor(0,0,1)` or `g.setColor(0x0000FF)`.
The mapping is as follows:
* 32 bit: `r,g,b` => `0xFFrrggbb`
* 24 bit: `r,g,b` => `0xrrggbb`
* 16 bit: `r,g,b` => `0brrrrrggggggbbbbb` (RGB565)
* Other bpp: `r,g,b` => white if `r+g+b > 50%`, otherwise black (use `r` on its own as an integer)
If you specified `color_order` when creating the `Graphics` instance, `r`,`g` and `b` will be swapped as you specified.
**Note:** On devices with low flash memory, `r` **must** be an integer representing the color in the current bit depth. It cannot
be a floating point value, and `g` and `b` are ignored.
Expand All @@ -561,7 +572,9 @@ be a floating point value, and `g` and `b` are ignored.
["b","JsVar","Blue (between 0 and 1)"]
]
}
Set the background color to use for subsequent drawing operations
Set the background color to use for subsequent drawing operations.
See `Graphics.setColor` for more information on the mapping of `r`, `g`, and `b` to pixel values.
**Note:** On devices with low flash memory, `r` **must** be an integer representing the color in the current bit depth. It cannot
be a floating point value, and `g` and `b` are ignored.
Expand Down

0 comments on commit 8ef686d

Please sign in to comment.