New function suggestions
qigongBea opened this issue · comments
Can you add a variable to switch between using palette numbers or HEX values?
For example, if ra.usePalette = 1;
, you can write code such as ra.setColor(14);
.
But if ra.usePalette = 0;
, you can directly use code such as ra.setColor(0x0000ff);
.
By default, this variable is 1.
This article has been translated by machine, and please bear with me if there are any inaccuracies. I hope you can understand it.
A method to use an rgb color directly already exists:
ra.setTrueColor(0x0000ff)
This method will add the rgb color to the current palette, or find if it is already there, and then use it. It won't work correctly if the palette is frozen (that is, if one of the pre-defined named palettes are in use such as ra.usePalette('c64')
. It also has undefined behavior if the palette fills up and has more then 255 colors. This edge case behavior may change in the future, so use with care.
The reason this works this way is that raster.js is highly dependent on having an 8-bit palette in order to render the image. It isn't possible to use rgb directly, because raster doesn't "think" in rgb. However, setTrueColor is pretty close to the desired behavior.
Okay thanks
You're welcome!