Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Set compolr in docs and templetes are differ #68

Open
MaxGraey opened this issue Sep 6, 2021 · 2 comments
Open

[docs] Set compolr in docs and templetes are differ #68

MaxGraey opened this issue Sep 6, 2021 · 2 comments
Labels
documentation Improvements or additions to documentation

Comments

@MaxGraey
Copy link
Contributor

MaxGraey commented Sep 6, 2021

Docs show example which uses 0x42

store<u16>(w4.DRAW_COLORS, 0x42);
w4.rect(10, 10, 32, 32);

But template uses store<u16>(w4.DRAW_COLORS, 2) for this.

Will be great explain what 0x42 mean and how it created. For example: 0x04 << 4 | 0x02. Even better have some util function like:

function encodeColors(xx: u32, yy: u32, zz: u32, ww: u32): u16 {
  return ((xx & 0x3) | (yy & 0x3) << 4 | (zz & 0x3) << 8 | (ww & 0x3) << 12) as u16;
}
@eXponenta
Copy link
Contributor

eXponenta commented Sep 6, 2021

This is same.

Draw colors said that:
0x[1, 2, 3, 4] remap current palette colors. 4 colors but 5 variants. 0 - transparent. Other lookups is shifted by 1, for handle a transparent. 1 means a 0 palette index etc.
This all will be mapped onto framebuffer by lookup table.

0x2 same as 0x0002, this means that you replace a FILL color as 2 of pallete and 0 for stroke.

@aduros
Copy link
Owner

aduros commented Sep 6, 2021

DRAW_COLORS holds 4 color slots. You can think of each hex digit as a color slot, starting from right (least significant digit). So setting DRAW_COLORS to 0x42 will set the 1st draw color to 2 (the 2nd palette color), and the 2nd draw color 4 (the 4th palette color). A zero digit in any color slot means transparency.

Could this be made clearer in the docs somehow?

@aduros aduros added the documentation Improvements or additions to documentation label Sep 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants