User Tools

Site Tools


script_toggle_animation

====== Differences ====== This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
script_toggle_animation [2014/05/19 09:10]
lm13 [Script Code]
script_toggle_animation [2014/07/24 16:17] (current)
lm13 [Compatible scripts]
Line 2: Line 2:
   * Purpose : This script will toggle one of my animation scripts   * Purpose : This script will toggle one of my animation scripts
   * Author : [[https://​plus.google.com/​+LukasMorawietz|LM13]]   * Author : [[https://​plus.google.com/​+LukasMorawietz|LM13]]
-  * Current Version : 2.1+  * Current Version : 2.2
   * Link: ...   * Link: ...
 +  * **//​Deprecated//​**
  
 ====== Changelog ====== ====== Changelog ======
   * Version 2.1 (19/​5/​2014):​ standardized for all animations   * Version 2.1 (19/​5/​2014):​ standardized for all animations
 +  * Version 2.2 (26/​6/​2014):​ added rotation
  
  
 ====== Compatible scripts ====== ====== Compatible scripts ======
-  * [[script_animation_bulldoze|Scrollanimation "​Bulldoze"​]] +  * [[script_animation_bulldoze|Scrollanimation "​Bulldoze"​]] ​(below Version 3) 
-  * [[script_animation_flip|Scrollanimation "​Flip"​]] +  * [[script_animation_flip|Scrollanimation "​Flip"​]] ​(below Version 3) 
-  * [[script_animation_shrink|Scrollanimation "​Shrink"​]] +  * [[script_animation_shrink|Scrollanimation "​Shrink"​]] ​(only Version 1) 
-  * [[script_animation_zigzag|Scrollanimation "​Zigzag"​]]  +  * [[script_animation_zigzag|Scrollanimation "​Zigzag"​]] ​(only Version 1) 
-  * There may be more, but these ones are proved ​+  * [[script_animation_inAndOut|Scrollanimation "In and out"]] (only Version 1) 
 +  * [[script_animation_turn|Scrollanimation "​Turn"​]] (only Version 1) 
 +  * <del>There may be more, but these ones are proved</​del>​ this Script is at EOL
  
  
  
 ====== Script Code ====== ====== Script Code ======
-<code> +<sxh javascript;>//​config ​
-//config+
 var mainScriptsName= "​Animation";​ var mainScriptsName= "​Animation";​
-//endconfig + //​endconfig ​
- +
 var d=LL.getEvent().getContainer();​ var d=LL.getEvent().getContainer();​
 var box=d.getBoundingBox();​ var box=d.getBoundingBox();​
-var cont=JSON.parse(d.getTag()||"​null"​);​+var cont=JSON.parse(d.getTag()||"​null"​); ​
 if(cont==null) cont=new Object(); if(cont==null) cont=new Object();
-cont.minx=box.getLeft();​ +cont.minx=box.getLeft();​  
-cont.maxx=box.getRight();​ +cont.maxx=box.getRight();​  
-cont.miny=box.getTop();​ +cont.miny=box.getTop();​  
-cont.maxy=box.getBottom();​ +cont.maxy=box.getBottom();​  
-var items=d.getItems();​ +var items=d.getItems();​  
-LL.runScript(mainScriptsName,​null);​ +LL.runScript(mainScriptsName,​null);​  
-var dwidth=d.getWidth();​ +var dwidth=d.getWidth();​  
-var dheight=d.getHeight();​ +var dheight=d.getHeight();​  
-if(cont.setup!=true) +if(cont.setup!=true)  
-+{  
-for(x=0;​x<​items.length;​x++) +for(x=0;​x<​items.length;​x++)  
-+{  
-var i=items.getAt(x);​ +var i=items.getAt(x);​  
-var data=new Object(); +var data=new Object();  
-data.posx=i.getPositionX();​+data.posx=i.getPositionX(); ​
 data.posy=i.getPositionY();​ data.posy=i.getPositionY();​
-if(i.getProperties().getBoolean("​i.onGrid"​)) data.onGrid=true;​ +data.rot=i.getRotation();​  
-else data.onGrid=false;​ +if(i.getProperties().getBoolean("​i.onGrid"​)) data.onGrid=true;​  
-i.getProperties().edit().setBoolean("​i.onGrid",​false).commit();​ +else data.onGrid=false;​  
-i.setTag(JSON.stringify(data));​ +i.getProperties().edit().setBoolean("​i.onGrid",​false).commit();​  
-+i.setTag(JSON.stringify(data));​  
-cont.setup=true;​+}  
 +cont.setup=true; ​
 Android.makeNewToast("​Animation enabled",​true).show();​ Android.makeNewToast("​Animation enabled",​true).show();​
-}+
 else else
-+{  
-var cellw=d.getCellWidth();​ +var cellw=d.getCellWidth();​  
-var cellh=d.getCellHeight();​ +var cellh=d.getCellHeight();​  
-for(x=0;​x<​items.length;​x++) +for(x=0;​x<​items.length;​x++)  
-+{  
-var i=items.getAt(x);​+var i=items.getAt(x); ​
 var data=JSON.parse(i.getTag());​ var data=JSON.parse(i.getTag());​
-if(data!=null && data.onGrid==true) +i.setScale(1,​1);​ i.setVisibility(true);​ 
-+i.setRotation(data.rot);​ 
-iwidth=i.getWidth();​ +if(data!=null&&​ data.onGrid==true)  
-iheight=i.getHeight();​ +{  
-i.getProperties().edit().setBoolean("​i.onGrid",​true).commit();​ +iwidth=i.getWidth();​  
-i.setCell(Math.round(data.posx/​cellw),​Math.round(data.posy/​cellh),​Math.round((data.posx+iwidth)/​cellw),​Math.round(( data.posy+iheight)/​cellh));​ +iheight=i.getHeight();​  
-} +i.getProperties().edit().setBoolean("​i.onGrid",​true).commit();​  
-i.setScale(1,​1);​ +i.setCell(Math.round(data.posx/​cellw),​Math.round(data.posy/​cellh),​Math.round((data.posx+iwidth)/​cellw),​Math.round(( data.posy+iheight)/​cellh));​  
-i.setVisibility(true);​ +  
-+}  
-cont.setup=false;​ +cont.setup=false;​  
-Android.makeNewToast("​Animation disabled",​true).show();​ +Android.makeNewToast("​Animation disabled",​true).show();​  
-}+
 d.setTag(JSON.stringify(cont));​ d.setTag(JSON.stringify(cont));​
-</code>+</sxh>
script_toggle_animation.1400490622.txt.gz · Last modified: 2014/05/19 09:10 by lm13