User Tools

Site Tools


script_wheel_of_items

====== About the script ====== * Purpose : This is a customizable wheel of items. * Author : [[https://plus.google.com/u/1/105066926163073195690|TrianguloY]] * Link: https://plus.google.com/+TrianguloY/posts/dMG96rAsFt6 (With video) * [[http://www.pierrox.net/android/applications/lightning_launcher/wiki/doku.php?id=script_wheel_of_items#modifications|Modification]] ====== How to use the script ====== Settings: * - X position: -1 left ; 0 center ; 1 right * - Y position: -1 bottom ; 0 center ; 1 top * - Rotation: the rotation the items will have relative to itself (recommended 0 or 180) * - Sensitivity: the velocity of rotating (the more, the faster) Instructions: * copy paste the script. * set it in the 'position changed' of the panel (or desktop). * IMPORTANT: pin the items, and detach them from the grid. * In the panel settings, check the 'no scroll limit' under scroll options. * Wheeeeeeeel This script will use all the items in the container, that's why I recommend to use a panel. ====== Script code ====== <sxh javascript> /*Config: */ var h = 0; //horizontal alignment (-1 , 0 , 1 ) var v = -1; //vertical alignment ( -1 , 0 , 1 ) var r = 0; //rotation offset ( 0 = default) in angles, not very implemented (0 or 180 recommended) var f = 2; //sensitivity var event = LL.getEvent(); var desktop = event.getContainer(); var a = desktop.getItems(); var na = a.getLength(); var radius = Math.min( desktop.getHeight()/ (v==0?4:2) , desktop.getWidth()/ (h==0?4:2) ); var alt = 0.5; var size = [ radius*(2-alt)*Math.PI/na , radius*2 ]; var desf = (desktop.getPositionX()*(v>0?-1:1)+desktop.getPositionY()*(h>0?-1:1) )*Math.PI/desktop.getWidth(); desf*=f; for ( var i=0; i<na; i+=1 ) { var angle = Math.PI*2*i/na-desf; var x = Math.cos( angle -Math.PI/2 ) * radius; var y = Math.sin( angle -Math.PI/2 ) * radius; var rot = angle*180/Math.PI+r; x+= (h<0? 0 : desktop.getWidth()/ (h==0? 2 : 1) ) ; y+= (v>0? 0 : desktop.getHeight()/ (v==0? 2 : 1) ); x-= size[0]/2; y-= size[1]/2; var t = a.getAt(i); t.setRotation(0); t.setSize(size[0] ,size[1]); t.setPosition(x, y); t.setRotation(rot); } </sxh> ====== Modifications ====== * Ready-to-use and possibility of having different settings in different containers. No need to set up settings! Follow all other instructions with the code below by [[http://www.google.com/+LukasMorawietz|F43nd1r]] === modified script === <sxh javascript;> var event = LL.getEvent(); var desktop = event.getContainer(); var data=JSON.parse(desktop.getTag()||"null"); if(data==null) { data=new Object(); data.h=parseInt(prompt("No Settings found.\nInput your horizontal Alignment (-1 , 0 , 1 )",0))||0; data.v=parseInt(prompt("Input your vertical Alignment (-1 , 0 , 1 )",0))||0; data.r=parseInt(prompt("Input your rotation offset ( 0 = default) in angles, not very implemented (0 or 180 recommended) ",0))||0; data.f=parseInt(prompt("Input your sensitivity",2))||2; } desktop.setTag(JSON.stringify(data)); var h=data.h; var v=data.v; var r=data.r; var f=data.f; var a = desktop.getItems(); var na = a.getLength(); var radius = Math.min( desktop.getHeight()/ (v==0?4:2) , desktop.getWidth()/ (h==0?4:2) ); var alt = 0.5; var size = [ radius*(2-alt)*Math.PI/na , radius*2 ]; var desf = (desktop.getPositionX()* (v>0?-1:1)+desktop.getPositionY()*(h>0?-1:1) )*Math.PI/desktop.getWidth(); desf*=f; for ( var i=0; i<na; i+=1 ) { var t = a.getAt(i); size=[t.getWidth(),t.getHeight()]; var angle = Math.PI*2*i/na-desf; var x = Math.cos( angle -Math.PI/2 ) * radius; var y = Math.sin( angle -Math.PI/2 ) * radius; var rot = angle*180/Math.PI+r; x+= (h<0? 0 : desktop.getWidth()/ (h==0? 2 : 1) ) ; y+= (v>0? 0: desktop.getHeight()/ (v==0? 2 : 1) ); x-= size[0]/2; y-= size[1]/2; t.setRotation(0); t.setSize(size[0] ,size[1]); t.setPosition(x, y); t.setRotation(rot); } </sxh>

script_wheel_of_items.txt · Last modified: 2018/08/14 16:56 by f43nd1r