-
Here it is . For some reason, only the german Wikipedia page mentions the cirlce algorithm. Look under "Kreisvariante des Algorithmus".
-
Funny, i would have thought Bresenham´s would be a lot faster. It seems to be (i just checked in the emulator, not on the real hardware), but only below a radius of about 12. Most of the code is straight from Wikipedia, no optimization at all:
function bRoundedRectangle (x1,y1,x2,y2,r) { var f = 1 - r; var ddF_x = 0; var ddF_y = -2 * r; var x = 0; var y = r; g.drawLine(x1+r,y1,x2-r,y1); g.drawLine(x1+r,y2,x2-r,y2); g.drawLine(x1,y1+r,x1,y2-r); g.drawLine(x2,y1+r,x2,y2-r); var cx1=x1+r; var cx2=x2-r; var cy1=y1+r; var cy2=y2-r; while(x < y) { if(f >= 0) { y--; ddF_y += 2; f += ddF_y; } x++; ddF_x += 2; f += ddF_x + 1; g.setPixel(cx2 + x, cy2 + y); g.setPixel(cx1 - x, cy2 + y); g.setPixel(cx2 + x, cy1 - y); g.setPixel(cx1 - x, cy1 - y); g.setPixel(cx2 + y, cy2 + x); g.setPixel(cx1 - y, cy2 + x); g.setPixel(cx2 + y, cy1 - x); g.setPixel(cx1 - y, cy1 - x); } }
-
I had some problem creating a settings menu for my clock. I wanted to preview different clock faces, for which i would need some functions from the clock app. Apparently, it is impossible to import functions into the settings app. My workaround was to just write a very basic settings.js:
(function(back) { var settings = require('Storage').readJSON("contourclock.json", true) || {}; settings.editMode=true; require('Storage').writeJSON("contourclock.json", settings); load('contourclock.app.js'); })
The clock app just has to check for "settings.editMode", disable UI and enter its own settings mode.
Are there any problems with this approach? -
-
-
-
My app shows up in my version of the App loader, but when i try to upload i get the following message after about 90%: "Upload failed, Unexpected response Uncaught SyntaxError: Got var expected EOF"
What does that mean? When i upload the code manually via the IDE it works fine. Sending it to the emulator also works. -
-
Here you are. This is far from a finished program, just a quick hack to generate some images from font data. Use it like this:
- Use the Espruino font converter to convert your font. You will need three pieces of data from the output window.
- Copy the encoded string after g.setFontCustom(atob(" into the script after "fontEncoded". This is where the actual characters are encoded.
- Change the value of fontsize in the script to the size of your converted font.
- Copy the second (shorter) encoded string into the script after "width". The width of each character is encoded here.
- Run the script. It should output a list of image definitions that the Graphics library can use
Edit: The forum code viewer does not seem to like python code. I uploaded the script instead...
- Use the Espruino font converter to convert your font. You will need three pieces of data from the output window.
-
-
I made this clock with overlapping digits. The digits are first drawn in foreground color, then in a lighter font in background color. Is there an easier way to do this? I tried "hollowing out" the characters, but then the insides just get treated as transparent. Is there a way to tell the Graphics library which parts of a font are transparent?
-
Sorry about the confusion, i just corrected the README and app description. This is my first app.
@Gordon: I will have a look at that, thanks! -
The one called "Bluetooth Widget" in the App loader. I think line 10 is to blame:
WIDGETS["bluetooth"]={area:"tr",width:15,draw:function() { g.reset(); if (NRF.getSecurityStatus().connected) g.setColor((g.getBPP()>8) ? "#07f" : (g.theme.dark ? "#0ff" : "#00f")); else g.setColor(g.theme.dark ? "#666" : "#999"); g.drawImage(atob("CxQBBgDgFgJgR4jZMawfAcA4D4NYybEYIwTAsBwDAA=="),2+this.x,2+this.y); },changed:function() { WIDGETS["bluetooth"].draw(); Bangle.setLCDPower(1); // turn screen on }}; NRF.on('connect',WIDGETS["bluetooth"].changed); NRF.on('disconnect',WIDGETS["bluetooth"].changed);
-
-
Why not just draw a filled circle, then a larger dark circle on top of that? That is how real moon phases work, after all :)