forked from FOSS/BangleApps
iconbits: cleanups, finish color selector
parent
aedb898177
commit
9697902e40
|
@ -13,6 +13,7 @@
|
||||||
var color = true;
|
var color = true;
|
||||||
let oldLock = false;
|
let oldLock = false;
|
||||||
let sg = null;
|
let sg = null;
|
||||||
|
const top_bar = 20;
|
||||||
|
|
||||||
function clear(m) {
|
function clear(m) {
|
||||||
sg.setColor(1,1,1).fillRect(0,0, font_width, font_height);
|
sg.setColor(1,1,1).fillRect(0,0, font_width, font_height);
|
||||||
|
@ -61,9 +62,9 @@
|
||||||
}
|
}
|
||||||
g.setColor('#fff');
|
g.setColor('#fff');
|
||||||
g.fillRect(0, 0, g.getWidth(), 20);
|
g.fillRect(0, 0, g.getWidth(), 20);
|
||||||
g.setFont('6x8', 2);
|
g.setFont('Vector', 22);
|
||||||
g.setColor('#000');
|
g.setColor('#000');
|
||||||
g.drawString('PLEASE UNLOCK', 10, 2);
|
g.drawString('PLEASE\nUNLOCK', 10, 2);
|
||||||
oldLock = true;
|
oldLock = true;
|
||||||
}
|
}
|
||||||
Bangle.on("lock", function() {
|
Bangle.on("lock", function() {
|
||||||
|
@ -74,14 +75,14 @@ Bangle.on("lock", function() {
|
||||||
drawUtil();
|
drawUtil();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
function nextColor () {
|
function nextColor() {
|
||||||
kule[0] = Math.random();
|
kule[0] = Math.random();
|
||||||
kule[1] = Math.random();
|
kule[1] = Math.random();
|
||||||
kule[2] = Math.random();
|
kule[2] = Math.random();
|
||||||
}
|
}
|
||||||
function selectColor (x) {
|
function selectColor(x) {
|
||||||
if (color) {
|
if (color) {
|
||||||
i = Math.floor((x - 25) / 4);
|
i = Math.floor((x - 32) / 4);
|
||||||
kule = toColor(i);
|
kule = toColor(i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -131,7 +132,7 @@ Bangle.on("lock", function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawArea () {
|
function drawArea() {
|
||||||
g.clear();
|
g.clear();
|
||||||
if (mode == "draw")
|
if (mode == "draw")
|
||||||
return;
|
return;
|
||||||
|
@ -158,17 +159,17 @@ Bangle.on("lock", function() {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawUtil () {
|
function drawUtil() {
|
||||||
if (Bangle.isLocked()) {
|
if (Bangle.isLocked()) {
|
||||||
updateLock();
|
updateLock();
|
||||||
}
|
}
|
||||||
// titlebar
|
// titlebar
|
||||||
g.setColor(kule[0], kule[1], kule[2]);
|
g.setColor(kule[0], kule[1], kule[2]);
|
||||||
g.fillRect(0, 0, g.getWidth(), 20);
|
g.fillRect(0, 0, g.getWidth(), top_bar);
|
||||||
for (let i = 0; i < 3*3*3; i++) {
|
for (let i = 0; i < 3*3*3; i++) {
|
||||||
r = toColor(i);
|
r = toColor(i);
|
||||||
g.setColor(r[0], r[1], r[2]);
|
g.setColor(r[0], r[1], r[2]);
|
||||||
g.fillRect(25+4*i, 20, 25+4*i+3, 24);
|
g.fillRect(32+4*i, 12, 32+4*i+3, top_bar);
|
||||||
}
|
}
|
||||||
// clear button
|
// clear button
|
||||||
g.setColor('#000'); // black
|
g.setColor('#000'); // black
|
||||||
|
@ -183,7 +184,7 @@ Bangle.on("lock", function() {
|
||||||
drawBrushIcon();
|
drawBrushIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
function transform (p) {
|
function transform(p) {
|
||||||
if (p.x < zoom_x || p.y < zoom_y)
|
if (p.x < zoom_x || p.y < zoom_y)
|
||||||
return p;
|
return p;
|
||||||
p.x = ((p.x - zoom_x) / zoom_f);
|
p.x = ((p.x - zoom_x) / zoom_f);
|
||||||
|
@ -193,7 +194,7 @@ Bangle.on("lock", function() {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
function __draw (g, from, to) {
|
function __draw(g, from, to) {
|
||||||
let XS = (to.x - from.x) / 32;
|
let XS = (to.x - from.x) / 32;
|
||||||
let YS = (to.y - from.y) / 32;
|
let YS = (to.y - from.y) / 32;
|
||||||
|
|
||||||
|
@ -258,7 +259,6 @@ Bangle.on("lock", function() {
|
||||||
oldY = -1;
|
oldY = -1;
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
let top_bar = 20;
|
|
||||||
// tap and hold the clear button
|
// tap and hold the clear button
|
||||||
if (tap.x < 32 && tap.y < top_bar) {
|
if (tap.x < 32 && tap.y < top_bar) {
|
||||||
if (tap.b === 1) {
|
if (tap.b === 1) {
|
||||||
|
@ -343,19 +343,16 @@ Bangle.on("lock", function() {
|
||||||
print('fi("'+btoa(im)+'");');
|
print('fi("'+btoa(im)+'");');
|
||||||
print(btoa(require('heatshrink').compress(im)));
|
print(btoa(require('heatshrink').compress(im)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setup("icon");
|
setup("icon");
|
||||||
drawArea();
|
drawArea();
|
||||||
Bangle.setUI({
|
Bangle.setUI({
|
||||||
"mode": "custom",
|
"mode": "custom",
|
||||||
"drag": on_drag,
|
"drag": on_drag,
|
||||||
"btn": on_btn,
|
"btn": on_btn,
|
||||||
});
|
});
|
||||||
drawUtil();
|
drawUtil();
|
||||||
|
|
||||||
|
|
||||||
function ft(icon) {
|
function ft(icon) {
|
||||||
g.reset().clear();
|
g.reset().clear();
|
||||||
|
|
Loading…
Reference in New Issue