Dithering for clocks, etc #6955
Replies: 1 comment
-
Posted at 2024-06-24 by @gfwilliams That looks really neat! There are actually some options that might help you to do it without having to have separate images for each colour (or dither/non-dithered):
Posted at 2024-06-24 by fanoushs-punching-bag This looks really awesome! Posted at 2024-06-25 by Chriz Thank you @andiohn for your feedback. If anyone is interested (in which of the two?), I could try to create clocks. @gfwilliams thank you for your inspiration.
It worked really well and looks almost the same: I use a 2 bit image with four colors. One color for the border of the number, one for the shadow at the top, one color for the inside of the number and one to be transparent. So it is possible to configure all color combinations that the users are interested in. But what's the best way to change the colors on the fly? I don't think the suggestions from above work when we want to support mix colors and also transparency is needed because the numbers overlap. I hoped there is some kind of callback that I could use when I pixel will be painted, but setCallback doesn't work for the existing "g". Scanning the mapped image from storage and use g.setPixel seems very slow; I guess because on every call the display get's updated. Currently the best approach seems copying the image from storage to make it editable, changing the pixels and then drawing it. But this is three loops (copying, modifying, drawing) where one should be enough. Posted at 2024-06-26 by @gfwilliams Ahh, ok - so you can use FG/BG colors in Graphics if you just want 2 colours (even in 2 bit images), but then color 0=bg, 3=fg, and 1 and 2 are blends between. You can use And in that, you can override the palette:
or if you want to just use drawImage, when you're using the https://www.espruino.com/Image+Converter select Ideally you want to avoid intercepting any setPixel/etc call as it'll be slow enough it'll cause you real problems :) Posted at 2024-06-28 by Chriz With your help I now have only one image per number and can colorize the border and inside with every possible color that can be represented with 2x2 dithering. Take a look at the number 9 I attached. It consists only of the 8 bangle js 2 colors. The background is red and will be set to transparent, the shadow has a color of it's own. The border and the inside each consist of 3 different colors. The image is then converted with the espruino online converter to 3 bit image object with nearest color. Then only the base64 encoded buffer is transformed to binary and copied to the watch. That seemed to be the only way to reference it from flash memory but still be able to set the palette:
Also take a look at the array conversion for the palette. This was the only way to create a flat string, because using it without the conversion on a 8 color pallete like this:
will give the error XXX when drawing the image:
Attachments: Posted at 2024-07-01 by @gfwilliams That's really strange about the palette - I'd have thought Uint16Array would have automatically used a flat string in that case, but glad you got it sorted!
Actually if you just use the base64 text with |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2024-06-22 by Chriz
Just experimented with the image converter and was impressed by the results with only 3 bit color using error diffusion. And e.g. what clocks would be possible. Both are based on existing watch faces. The analog one could easily be created. For the first one individual images for the shadowed numbers would be needed.
Attachments:
Beta Was this translation helpful? Give feedback.
All reactions