From 61723ddf0d9310b123e8edc09c2d524629136947 Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Sat, 13 Jul 2024 12:45:53 +0200 Subject: [PATCH 1/4] [] iconbits: initial import --- apps/iconbits/ChangeLog | 1 + apps/iconbits/README.md | 3 + apps/iconbits/app-icon.js | 2 + apps/iconbits/app.png | Bin 0 -> 2459 bytes apps/iconbits/iconbits.app.js | 345 ++++++++++++++++++++++++++++++++++ apps/iconbits/metadata.json | 14 ++ 6 files changed, 365 insertions(+) create mode 100644 apps/iconbits/ChangeLog create mode 100644 apps/iconbits/README.md create mode 100644 apps/iconbits/app-icon.js create mode 100644 apps/iconbits/app.png create mode 100644 apps/iconbits/iconbits.app.js create mode 100644 apps/iconbits/metadata.json diff --git a/apps/iconbits/ChangeLog b/apps/iconbits/ChangeLog new file mode 100644 index 000000000..263d4078d --- /dev/null +++ b/apps/iconbits/ChangeLog @@ -0,0 +1 @@ +0.01: attempt to import diff --git a/apps/iconbits/README.md b/apps/iconbits/README.md new file mode 100644 index 000000000..21acfa5a0 --- /dev/null +++ b/apps/iconbits/README.md @@ -0,0 +1,3 @@ +# Icon Bits ![](app.png) + +Bitmap editor suitable for creating icons and fonts for BangleJS2. diff --git a/apps/iconbits/app-icon.js b/apps/iconbits/app-icon.js new file mode 100644 index 000000000..d32528cb6 --- /dev/null +++ b/apps/iconbits/app-icon.js @@ -0,0 +1,2 @@ +require("heatshrink").decompress(atob("mEwhHXAH4A/AH4A/ACkAgAuuGFovuL2Qu/F2amDABRdgC5QKDHSIvdOZQuaApYuGJBYvPJYwvLPBgvOJY4hGRYwvYJZAFGXQy/mdRAvqZpguSF5waMF8IaNF74aPF6ghTF/4UFAApfuGoyPwABoufSEQv/BpowRF6i6IF8oEDHAwueF/4vwD6gvZbyA/VCwIXHL8hQZZ8CQSIRhAiGIbhEcxQvaGo4YCAgQAJF7pBUIQgvnVY4vrAHQ=")) + diff --git a/apps/iconbits/app.png b/apps/iconbits/app.png new file mode 100644 index 0000000000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1T@w5jiI>UygODZLM$|5}{2fwU2-bxVjsmQ#zw8&nrznKjL9j-XJi z%)bU?vY$S~JYD$j2tu~p*h1!_-j}*)qTj0lD3voNX^3 zs{7zQJ{PQ8KhB_|H!~4@6BBnVrr%6C*&#-!-)ZvgGUKfUd<`91G2kseys-WB@k~)^ zUiO*=l^0HBrxQ5+%R|P+vJj2QmrF_huqQHjez0KS;2*<4OY{KGiFIneQ#J7fDkeW~ zy)WK#d-e0iV?$P5QP*6y?_}l&ll|a9^yYHCSW~vZs;g9a@Lq!DlEdQlY*@SN{%}9d zq*HFkag@*e*x+!{@nIw1IQZ5;w1iI zqbD>+i|F5D%Lz&7cs(71>ZFmS-u2eTP&EJeZ1i~(fStURY;5G5jLU{AGQUl62V{LM zkxq`@x~6Ry?#yf4#}|NS0FZjn)A*B2LN-Bp`XaRaZGFGlwcO+s+S2Gx75 zuE-qX^R#sIW=Q`FcMtVdO2+JG);)cY_D>rW(O+yq^xzyvmgo`t#OJo5H0CaVG4@4u zW?Ut>8uOh-TOyrTPU?p#Vks6Cuf4^_ai;@WvCp!s2)*173$Mk#WUFO?rXdHuYgHMd zO2zt(fkh*gKJCROx}lr9ufO_beR?fEe50u!s2jocuLr*+-8~}LrCoH-%m}8qYHd)u z6v-7C)9=;ZV!0k{hWem1(~tgj*MT{HB|?h_?uK`dpa;kcKc~B}SKX}mm!A`N>xy8u znUTq#`qrlCzVsh*t^K0nA4f-BGTV1b|KDa9_k+|nuYU+S-2VY#O@9YOAGJ()7lP0U MB_Pzll? g.getWidth() - 32 && tap.y < 32) { + if (tap.b === 1) { + if (tapTimer === null) { + tapTimer = setTimeout(function () { + g.clear(); + drawUtil(); + oldX = -1; oldY = -1; + + tapTimer = null; + }, 800); + } + if (discard) { + clearTimeout(discard); + discard = null; + return; + } + nextPen(); + } + drawUtil(); + return; + } else if (tap.y < 32) { + if (mode == "draw") + nextColor(); + else + selectColor(tap.x); + drawUtil(); + return; + } + oldX = to.x; + oldY = to.y; + sg.setColor(kule[0], kule[1], kule[2]); + g.setColor(kule[0], kule[1], kule[2]); + + do_draw(from, to); + drawUtil(); + } + function on_btn_old(n) { + } + function on_btn(n) { + function f(i) { + return "\\x" + i.toString(16).padStart(2, '0'); + } + print("on_btn", n); + print(g.getPixel(0, 0)); + s = f(0) + f(font_width) + f(font_height) + f(1); + // 0..black, 65535..white + for (let y = 0; y < font_height; y++) { + let v = 0; + for (let x = 0; x < font_width; x++) { + let p = sg.getPixel(x, y); + v = v << 1 | (p==0); + } + s += f(v); + } + print("Manual bitmap\n"); + print('ft("' + s + '");'); + if (1) { + s = ""; + var im = sg.asImage("string"); + for (var v of im) { + //print("val", v, typeof v); + s += f(v); + } + //print("wh", im, typeof im, im[0], typeof im[0]); + //print("Image:", im.length, s); + print('fi("'+btoa(im)+'");'); + } + + + } + + setup("icon"); + drawArea(); + Bangle.setUI({ + "mode": "custom", + "drag": on_drag, + "btn": on_btn, + }); + drawUtil(); + + +function ft(icon) { + g.reset().clear(); + g.setFont("Vector", 26).drawString("Hellord" + icon, 0, 0); +} + +function fi(icon) { + g.reset().clear(); + g.drawImage(atob(icon), 40, 40); +} + +icon_gps = "\x00\x08\x16\x01\x00\x00\x00\x99\xbd\xff\xbd\x99\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; +icon_hpa = "\x00\x08\x16\x01\x00\x80\xb0\xc8\x88\x88\x88\x00\xf0\x88\x84\x84\x88\xf0\x80\x8c\x92\x22\x25\x19\x00\x00"; +icon_foot = "\x00\x08\x16\x01\x00\x18\x3c\x7e\x7e\x7e\x7c\x78\x78\x00\x78\x78\x78\x30\x00\x00\x00\x00\x00\x00\x00\x00"; +icon_9 = "\x00\x08\x16\x01\x00\x00\x00\x00\x38\x44\x44\x4c\x34\x04\x04\x38\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; +icon_10 = "\x00\x08\x16\x01\x00\x08\x18\x28\x08\x08\x08\x00\x00\x18\x24\x24\x24\x24\x18\x00\x00\x00\x00\x00\x00\x00"; +icon_sunrise = "\x00\x08\x16\x01\x00\x00\x00\x24\x00\x99\x24\x42\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; +icon_sunset = "\x00\x08\x16\x01\x00\x00\x24\x00\x81\x00\xff\x42\x24\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; +icon_gps_no_paused = "\x00\x08\x16\x01\x00\x24\x24\x24\x24\x24\x00\x80\x9c\xa2\xe3\xa2\x9c\x80\x00\x00\x00\x00\x00\x00\x00\x00"; + +//ft(icon_10 + "23.1" + icon_hpa); \ No newline at end of file diff --git a/apps/iconbits/metadata.json b/apps/iconbits/metadata.json new file mode 100644 index 000000000..b98a43953 --- /dev/null +++ b/apps/iconbits/metadata.json @@ -0,0 +1,14 @@ +{ "id": "iconbits", + "name": "Icon bits", + "version": "0.01", + "description": "Bitmap editor suitable for creating icons", + "icon": "app.png", + "readme": "README.md", + "supports" : ["BANGLEJS2"], + "allow_emulator": true, + "tags": "tools", + "storage": [ + {"name":"iconbits.app.js","url":"iconbits.app.js"}, + {"name":"iconbits.img","url":"app-icon.js","evaluate":true} + ] +} From 422892cb4866581eb6886a7aa59c3208a6642c81 Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Sat, 13 Jul 2024 13:09:00 +0200 Subject: [PATCH 2/4] [] iconbits: fix warnings --- apps/iconbits/iconbits.app.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/iconbits/iconbits.app.js b/apps/iconbits/iconbits.app.js index c45af382b..6d9ff2973 100644 --- a/apps/iconbits/iconbits.app.js +++ b/apps/iconbits/iconbits.app.js @@ -64,6 +64,7 @@ Bangle.on("lock", function() { kule[2] = Math.random(); } function selectColor (x) { + let c; if (x < g.getWidth()/2) { c = 0; } else { @@ -114,7 +115,6 @@ Bangle.on("lock", function() { g.clear(); if (mode == "draw") return; - const w = g.getWidth; g.setColor(0, 0, 0.5); g.fillRect(0, 0, g.getWidth(), g.getHeight()); g.setColor(1, 1, 1); @@ -278,15 +278,13 @@ Bangle.on("lock", function() { do_draw(from, to); drawUtil(); } - function on_btn_old(n) { - } function on_btn(n) { function f(i) { return "\\x" + i.toString(16).padStart(2, '0'); } print("on_btn", n); print(g.getPixel(0, 0)); - s = f(0) + f(font_width) + f(font_height) + f(1); + let s = f(0) + f(font_width) + f(font_height) + f(1); // 0..black, 65535..white for (let y = 0; y < font_height; y++) { let v = 0; @@ -342,4 +340,4 @@ icon_sunrise = "\x00\x08\x16\x01\x00\x00\x00\x24\x00\x99\x24\x42\xff\x00\x00\x00 icon_sunset = "\x00\x08\x16\x01\x00\x00\x24\x00\x81\x00\xff\x42\x24\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; icon_gps_no_paused = "\x00\x08\x16\x01\x00\x24\x24\x24\x24\x24\x00\x80\x9c\xa2\xe3\xa2\x9c\x80\x00\x00\x00\x00\x00\x00\x00\x00"; -//ft(icon_10 + "23.1" + icon_hpa); \ No newline at end of file +//ft(icon_10 + "23.1" + icon_hpa); From b6f02430741f02c0c07d14b742339cb3b9178ee1 Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Sat, 13 Jul 2024 17:37:18 +0200 Subject: [PATCH 3/4] [] iconbits: disable unused warnings. --- apps/iconbits/iconbits.app.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/apps/iconbits/iconbits.app.js b/apps/iconbits/iconbits.app.js index 6d9ff2973..625070dd5 100644 --- a/apps/iconbits/iconbits.app.js +++ b/apps/iconbits/iconbits.app.js @@ -1,5 +1,7 @@ // Icon bits, thanks to tinydraw - +/* eslint-disable no-unused-vars */ +/* We have functions we expect user to call from command line, so they + * appear "unused" to lint */ // font, draw, icon let mode; @@ -331,13 +333,4 @@ function fi(icon) { g.drawImage(atob(icon), 40, 40); } -icon_gps = "\x00\x08\x16\x01\x00\x00\x00\x99\xbd\xff\xbd\x99\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; -icon_hpa = "\x00\x08\x16\x01\x00\x80\xb0\xc8\x88\x88\x88\x00\xf0\x88\x84\x84\x88\xf0\x80\x8c\x92\x22\x25\x19\x00\x00"; -icon_foot = "\x00\x08\x16\x01\x00\x18\x3c\x7e\x7e\x7e\x7c\x78\x78\x00\x78\x78\x78\x30\x00\x00\x00\x00\x00\x00\x00\x00"; -icon_9 = "\x00\x08\x16\x01\x00\x00\x00\x00\x38\x44\x44\x4c\x34\x04\x04\x38\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; -icon_10 = "\x00\x08\x16\x01\x00\x08\x18\x28\x08\x08\x08\x00\x00\x18\x24\x24\x24\x24\x18\x00\x00\x00\x00\x00\x00\x00"; -icon_sunrise = "\x00\x08\x16\x01\x00\x00\x00\x24\x00\x99\x24\x42\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; -icon_sunset = "\x00\x08\x16\x01\x00\x00\x24\x00\x81\x00\xff\x42\x24\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; -icon_gps_no_paused = "\x00\x08\x16\x01\x00\x24\x24\x24\x24\x24\x00\x80\x9c\xa2\xe3\xa2\x9c\x80\x00\x00\x00\x00\x00\x00\x00\x00"; - //ft(icon_10 + "23.1" + icon_hpa); From 91c489bada4cb1fff31f0abfe55f534270ebfb35 Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Tue, 16 Jul 2024 11:16:30 +0200 Subject: [PATCH 4/4] [] iconbits: provide better README. --- apps/iconbits/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/iconbits/README.md b/apps/iconbits/README.md index 21acfa5a0..c5c524ab0 100644 --- a/apps/iconbits/README.md +++ b/apps/iconbits/README.md @@ -1,3 +1,7 @@ # Icon Bits ![](app.png) Bitmap editor suitable for creating icons and fonts for BangleJS2. + +You'll want to run a copy of this in simulator, and another one on +watch to view the results. Draw using the provided tools, then press +the button, and you'll get result on the console.