Improve the perf
parent
fe3229c262
commit
006c4e6960
|
|
@ -1035,7 +1035,7 @@
|
||||||
"name": "Touch Launcher",
|
"name": "Touch Launcher",
|
||||||
"shortName":"Menu",
|
"shortName":"Menu",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"version":"0.04",
|
"version":"0.05",
|
||||||
"description": "Touch enable left to right launcher.",
|
"description": "Touch enable left to right launcher.",
|
||||||
"tags": "tool,system,launcher",
|
"tags": "tool,system,launcher",
|
||||||
"type":"launch",
|
"type":"launch",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
0.01: New App!
|
0.01: New App!
|
||||||
0.02: Add swipe support and doucle tap to run application
|
0.02: Add swipe support and doucle tap to run application
|
||||||
0.03: Close launcher when lcd turn off
|
0.03: Close launcher when lcd turn off
|
||||||
0.04: Complete rewrite to add animation and loop ( issue #210 )
|
0.04: Complete rewrite to add animation and loop ( issue #210 )
|
||||||
|
0.05: Improve perf
|
||||||
|
|
@ -19,7 +19,7 @@ function getApps(){
|
||||||
const HEIGHT = g.getHeight();
|
const HEIGHT = g.getHeight();
|
||||||
const WIDTH = g.getWidth();
|
const WIDTH = g.getWidth();
|
||||||
const HALF = WIDTH/2;
|
const HALF = WIDTH/2;
|
||||||
const ANIMATION_FRAME = 3;
|
const ANIMATION_FRAME = 4;
|
||||||
const ANIMATION_STEP = HALF / ANIMATION_FRAME;
|
const ANIMATION_STEP = HALF / ANIMATION_FRAME;
|
||||||
|
|
||||||
function getPosition(index){
|
function getPosition(index){
|
||||||
|
|
@ -35,6 +35,8 @@ const back = {
|
||||||
back: true
|
back: true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let icons = {};
|
||||||
|
|
||||||
const apps = [back].concat(getApps());
|
const apps = [back].concat(getApps());
|
||||||
apps.push(back);
|
apps.push(back);
|
||||||
|
|
||||||
|
|
@ -54,6 +56,12 @@ function drawIcons(offset){
|
||||||
const y = HALF - (HALF*0.3);//-(HALF*0.7);
|
const y = HALF - (HALF*0.3);//-(HALF*0.7);
|
||||||
let diff = (x - HALF);
|
let diff = (x - HALF);
|
||||||
if(diff < 0) diff *=-1;
|
if(diff < 0) diff *=-1;
|
||||||
|
|
||||||
|
const dontRender = x+(HALF/2)<0 || x-(HALF/2)>120;
|
||||||
|
if(dontRender) {
|
||||||
|
delete icons[app.name];
|
||||||
|
return;
|
||||||
|
}
|
||||||
let size = 30;
|
let size = 30;
|
||||||
if((diff*0.5) < size) size -= (diff*0.5);
|
if((diff*0.5) < size) size -= (diff*0.5);
|
||||||
else size = 0;
|
else size = 0;
|
||||||
|
|
@ -72,8 +80,12 @@ function drawIcons(offset){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// icon
|
// icon
|
||||||
const icon = app.icon ? Storage.read(app.icon) : null;
|
|
||||||
|
const icon = app.icon ?
|
||||||
|
icons[app.name] ? icons[app.name] : Storage.read(app.icon)
|
||||||
|
: null;
|
||||||
if(icon){
|
if(icon){
|
||||||
|
icons[app.name] = icon;
|
||||||
try {
|
try {
|
||||||
g.drawImage(icon, x-(scale*24), y-(scale*24), { scale: scale });
|
g.drawImage(icon, x-(scale*24), y-(scale*24), { scale: scale });
|
||||||
} catch(e){
|
} catch(e){
|
||||||
|
|
@ -100,7 +112,8 @@ function drawIcons(offset){
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw(ignoreLoop){
|
function draw(ignoreLoop){
|
||||||
g.clear();
|
g.setColor(0,0,0);
|
||||||
|
g.fillRect(0,0,WIDTH,HEIGHT);
|
||||||
drawIcons(slideOffset);
|
drawIcons(slideOffset);
|
||||||
g.flip();
|
g.flip();
|
||||||
if(slideOffset == target) return;
|
if(slideOffset == target) return;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue