-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added remaining color types for PNTS (#391)
* Added rgb565torgb function in utils * Added rgba, rgb565 and constant_rgba support * Added a check for opacity if it is less than one * Updated rgb565torgb to a simpler unpacking * Added info for rgb565 unpacking * Disable depth write when setting transparency * Small style changes --------- Co-authored-by: Garrett Johnson <[email protected]>
- Loading branch information
Showing
2 changed files
with
65 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// The implementation of rgb565 to rgb888 is from | ||
// https://rgbcolorpicker.com/565 | ||
|
||
export function rgb565torgb( rgb565 ) { | ||
|
||
// Shift the red value to the right by 11 bits. | ||
const red5 = rgb565 >> 11; | ||
// Shift the green value to the right by 5 bits and extract the lower 6 bits. | ||
const green6 = ( rgb565 >> 5 ) & 0b111111; | ||
// Extract the lower 5 bits. | ||
const blue5 = rgb565 & 0b11111; | ||
|
||
// Convert 5-bit red to 8-bit red. | ||
const red8 = Math.round( ( red5 / 31 ) * 255 ); | ||
// Convert 6-bit green to 8-bit green. | ||
const green8 = Math.round( ( green6 / 63 ) * 255 ); | ||
// Convert 5-bit blue to 8-bit blue. | ||
const blue8 = Math.round( ( blue5 / 31 ) * 255 ); | ||
|
||
return [ red8, green8, blue8 ]; | ||
|
||
} |