-
• #2
Nice! For the disc, you could try something like:
let yOffset = -Radius; setTimeout(function cb() { for (let xOffset = -Radius; xOffset <= Radius; xOffset++) { let OffsetSquared = xOffset*xOffset + yOffset*yOffset; if (OffsetSquared <= RadiusSquared) { let Hue = Rad2Deg(Math.atan2(yOffset,xOffset)); let Saturation = Math.sqrt(OffsetSquared)/Radius; let RGB = HSVtoRGB(Hue, Saturation, Value); let Color = RGB[0] << 11 | RGB[1] << 5 | RGB[2]; g.setPixel(Radius+xOffset,Radius+yOffset, Color); } } yOffset++; if (yOffset <= Radius) setTimeout(cb,10); },10);
To ensure that it doesn't 'hang' the browser while computing it :)
-
• #3
Indeed, a good idea!
Although that code will slow down execution even further...
Let's see how it will perform on a real device...
-
• #4
even setTimeout(cb,0); keeps the browser interactive and it takes 20 vs 16 seconds
EDIT:
and if I enable pretokenize on thatsetTimeout(function cb()
part it fails later that cb is not defined, is this known bug of pretokenizer? -
• #5
is this known bug of pretokenizer?
Not that I'm aware of. Just tried to reproduce and I can't see it here - please could you slim your code down to something minimal that fails and post it as a new thread?
-
• #6
oh, it is combination of closure online simple optimizations and pretokenisation, even the gist as is breaks if you enable both checkboxes first and then open the link of the colordisc as is. if I disable pretokenization the minification works and it runs fine.
Edit: oh it breaks even with minification turned off now. just enable pretokenization, close emulator and then click the colordisc emulator link again, I see HSVtoRGB is not defined, do you see it?
-
• #7
...infinite loop locks up the emulator ide... only way to get out of it is wait for the ide (browser) popup whether to continue waiting or kill / close it. So saving code before upload is always a good thing.
-
• #8
Ahh ok, I can reproduce, and just fixed this (it'll need both a new IDE and firmware) - so just to be clear:
E.setFlags({pretokenise: 1})
(pretokenisation in Espruino) works fine- Web IDE pretokenise minification setting causes errors
-
• #9
I don't know if you like this. but have a look and enjoy:
https://www.espruino.com/ide/emulator.html?gist=c63a9d49a09847144666ea8b0a6a2fd5&upload
@MaBe - add this feature in his list Enhancement for Graphics #1702
-
• #10
@Abhinav fell free to add anything you like to see on this list by your own.
-
• #11
Great!! thanks!
Since I had some trouble with color encoding on Bangle.js (see this conversation), I thought it might be a good idea to post two colorful experiments:
Enjoy!