Posted by: pierrot | on August 9, 2014
YAPI-HUD
Yet Another Page Indicator
Head Up Display – style
Scripted with Canvas Paint.
Posted in | 13 Comments » Tags: Jappie Toutenhoofd
< ![CDATA[
Very very cool Jappie…nice work 🙂
]]>
///////////////////////////////////////////////
//———————————————
// YAPI – Yet Another Page Indicator
// HUD-style – Head Up Display
//
// set this script on event Position-Changed
//////////////////////////////////////////////
/* config */
var BG_color = 0x33000000;
var HUD_color = 0x7777FF77;
/* end-config */
// Complete Image size
var d = LL.getCurrentDesktop();
if (d.getItemByLabel(“HUD”)==null) { Initialsetup();}
var hud = d.getItemByLabel(“HUD”);
var hudW = hud.getWidth();
var hudH = hud.getHeight();
var hud_ratio = hudW / hudH;
var img = LL.createImage( hudW, hudH);
hud.setBoxBackground(img, “n”);
var p = new Paint();
p.setAntiAlias(true);
var c = img.draw();
// Outer Hud base on BoundingBox
var bb = d.getBoundingBox();
var cntW = bb.getRight() – bb.getLeft();
var cntH = bb.getBottom() – bb.getTop();
var cnt_ratio = cntW / cntH;
if (hud_ratio > cnt_ratio)
{ // Container is higher
var cnt_scale = hudH / cntH;
}
else
{ // Container is wider
var cnt_scale = hudW / cntW;
p.setStyle(Paint.Style.FILL);
p.setColor(BG_color);
c.drawRect (0, 0, (cntW * cnt_scale), (cntH * cnt_scale), p);
p.setStyle(Paint.Style.STROKE);
p.setColor(HUD_color);
p.setStrokeWidth(2);
// Inner Hud based on Current View
//drawRect ( Left, Top, Right, Bottom, Paint)
var VwL = (d.getPositionX() – bb.getLeft());
var VwT = (d.getPositionY() – bb.getTop()) ;
var VwR = VwL+ ( d.getWidth() / d.getPositionScale());
var VwB = VwT+ ( d.getHeight() / d.getPositionScale()) ;
//d.getPositionScale();
c.drawRect (VwL * cnt_scale , VwT * cnt_scale , VwR * cnt_scale , VwB * cnt_scale , p);
img.update();
function Initialsetup()
{
var newHud = d.addShortcut(“HUD”,new Intent(),0,0);
d.setItemZIndex(newHud.getId(),d.getItems().getLength());
var pe = newHud.getProperties().edit();
pe.setBoolean(“i.onGrid”,false);
pe.setString(“i.pinMode”,”XY”);
pe.setBoolean(“i.enabled”,false);
pe.setBoolean(“s.iconVisibility”,false);
pe.setBoolean(“s.labelVisibility”,false);
pe.commit();
Awesome, good work.
A possible suggestion will be to paint the home page if possible, anyway you made a nice script with canvas.
Congratulations
Thanks guys, anything is posible. Maybe I have time to make it full C&C-map style:
Red = app or shortcut
Blue = widget or panel
😉
And, if you run out of ideas:
Lines indicating the pages
Smaller lines indicating the grid.
A small cross with stop points (you can take the size of the stop point but instead of fill it draw two lines)
Also I should separate widgets and panels.
But hey, it’s your script. (Maybe I’ll make some tests, I’ll tell you if I make something)
@Josh im afraid im not familiar with Nova. Any Youtube example?
TrianguloY forget C&C-map…. How about True-map:
var item = LL.getEvent().getItem();
var img = item.getDefaultIcon();
var bmp = img.getBitmap();
var px = bmp.getPixel(20,20);
Android.makeNewToast(Color.blue(px),false).show();
Not really sure what you mean.
Are you talking about drawing the icon when shortcuts?
We talked about filling the HUD with red dots for icons.
But with above script i can capture the real color of an icon and fill the HUD with that.
I really enjoyed this script but was curious if there is a way to get it fade away after a set amount of time.
That ‘s certainly on my Todo.
Thanks for the incredibly fast reply and I look forward to using this script in the future.
HUD v2 in minutes from now….
Your email address will not be published. Required fields are marked *
Comment
Name *
Email *
Website
< ![CDATA[
Very very cool Jappie…nice work 🙂
]]>
< ![CDATA[
///////////////////////////////////////////////
//———————————————
// YAPI – Yet Another Page Indicator
// HUD-style – Head Up Display
//
//———————————————
// set this script on event Position-Changed
//———————————————
//
//////////////////////////////////////////////
/* config */
var BG_color = 0x33000000;
var HUD_color = 0x7777FF77;
/* end-config */
// Complete Image size
var d = LL.getCurrentDesktop();
if (d.getItemByLabel(“HUD”)==null) { Initialsetup();}
var hud = d.getItemByLabel(“HUD”);
var hudW = hud.getWidth();
var hudH = hud.getHeight();
var hud_ratio = hudW / hudH;
var img = LL.createImage( hudW, hudH);
hud.setBoxBackground(img, “n”);
var p = new Paint();
p.setAntiAlias(true);
var c = img.draw();
// Outer Hud base on BoundingBox
var bb = d.getBoundingBox();
var cntW = bb.getRight() – bb.getLeft();
var cntH = bb.getBottom() – bb.getTop();
var cnt_ratio = cntW / cntH;
if (hud_ratio > cnt_ratio)
{ // Container is higher
var cnt_scale = hudH / cntH;
}
else
{ // Container is wider
var cnt_scale = hudW / cntW;
}
p.setStyle(Paint.Style.FILL);
p.setColor(BG_color);
c.drawRect (0, 0, (cntW * cnt_scale), (cntH * cnt_scale), p);
p.setStyle(Paint.Style.STROKE);
p.setColor(HUD_color);
p.setStrokeWidth(2);
c.drawRect (0, 0, (cntW * cnt_scale), (cntH * cnt_scale), p);
// Inner Hud based on Current View
//drawRect ( Left, Top, Right, Bottom, Paint)
var VwL = (d.getPositionX() – bb.getLeft());
var VwT = (d.getPositionY() – bb.getTop()) ;
var VwR = VwL+ ( d.getWidth() / d.getPositionScale());
var VwB = VwT+ ( d.getHeight() / d.getPositionScale()) ;
//d.getPositionScale();
p.setStyle(Paint.Style.FILL);
p.setColor(HUD_color);
c.drawRect (VwL * cnt_scale , VwT * cnt_scale , VwR * cnt_scale , VwB * cnt_scale , p);
img.update();
function Initialsetup()
{
var newHud = d.addShortcut(“HUD”,new Intent(),0,0);
d.setItemZIndex(newHud.getId(),d.getItems().getLength());
var pe = newHud.getProperties().edit();
pe.setBoolean(“i.onGrid”,false);
pe.setString(“i.pinMode”,”XY”);
pe.setBoolean(“i.enabled”,false);
pe.setBoolean(“s.iconVisibility”,false);
pe.setBoolean(“s.labelVisibility”,false);
pe.commit();
}
]]>
< ![CDATA[
Awesome, good work.
A possible suggestion will be to paint the home page if possible, anyway you made a nice script with canvas.
Congratulations
]]>
< ![CDATA[
Thanks guys, anything is posible. Maybe I have time to make it full C&C-map style:
Red = app or shortcut
Blue = widget or panel
😉
]]>
< ![CDATA[
And, if you run out of ideas:
Lines indicating the pages
Smaller lines indicating the grid.
A small cross with stop points (you can take the size of the stop point but instead of fill it draw two lines)
Also I should separate widgets and panels.
But hey, it’s your script. (Maybe I’ll make some tests, I’ll tell you if I make something)
]]>
< ![CDATA[
@Josh im afraid im not familiar with Nova. Any Youtube example?
]]>
< ![CDATA[
TrianguloY forget C&C-map…. How about True-map:
var item = LL.getEvent().getItem();
var img = item.getDefaultIcon();
var bmp = img.getBitmap();
var px = bmp.getPixel(20,20);
Android.makeNewToast(Color.blue(px),false).show();
]]>
< ![CDATA[
Not really sure what you mean.
Are you talking about drawing the icon when shortcuts?
]]>
< ![CDATA[
We talked about filling the HUD with red dots for icons.
But with above script i can capture the real color of an icon and fill the HUD with that.
]]>
< ![CDATA[
I really enjoyed this script but was curious if there is a way to get it fade away after a set amount of time.
]]>
< ![CDATA[
That ‘s certainly on my Todo.
]]>
< ![CDATA[
Thanks for the incredibly fast reply and I look forward to using this script in the future.
]]>
< ![CDATA[
HUD v2 in minutes from now….
]]>