====== Differences ====== This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
script_circle_icons [2014/02/23 16:06] tbog [About the script] |
script_circle_icons [2014/03/03 12:32] (current) tbog [How to use the script] |
||
|---|---|---|---|
| Line 5: | Line 5: | ||
| ====== How to use the script ====== | ====== How to use the script ====== | ||
| + | - Make sure the items are not on a grid. | ||
| + | - Make a shortcut that runs this script and put a . as the first character of the label. | ||
| + | - Click on the shortcut and all items of type 'Shortcut' that do not have a dot as the first character in the label will be positioned on a circle. | ||
| + | - You can change the order of the items in the circle using "Move forward/backwards" button. The top-most item is at 12-o'clock and going clockwise. | ||
| + | - If the order of the items is not to your liking, make changes then go to step 3. | ||
| + | - You can now delete the shortcut to the script. | ||
| - | Make sure the items are not on a grid. | + | Note: The top-most item will set the size of all other items. |
| - | Just make a shortcut that runs this script and put a . as the first character of the label. | + | I have tested this script on a 1080 x 1920 screen (portrait). If you have some other resolution you can change the margin values and the radius (read comments in the script). |
| - | All items of type 'ai' that do not have a dot as the first character in the label will be positioned on a circle. | + | |
| - | I have tested this script on a 1080 x 1920 screen. If you have some other resolution you can change the offsets and the radius (read comments in the script). | + | |
| ====== Script code ====== | ====== Script code ====== | ||
| <code> | <code> | ||
| Line 20: | Line 23: | ||
| { | { | ||
| var item = items.getAt(i); | var item = items.getAt(i); | ||
| - | if ( item.getType()!='ai' ) | + | if ( item.getType()!='Shortcut' ) |
| { | { | ||
| alert(item.getType()+" "+item.getLabel()); | alert(item.getType()+" "+item.getLabel()); | ||
| Line 29: | Line 32: | ||
| a[na++] = item; | a[na++] = item; | ||
| } | } | ||
| - | var x,y; | + | if (!na) |
| + | return; | ||
| + | var x, y; | ||
| + | var size = Math.max(a[0].getWidth(), a[0].getHeight()); | ||
| + | var radius = (Math.min( desktop.getWidth(), desktop.getHeight() ) - size) * 0.5; | ||
| + | var margin = 0.2 * size; | ||
| + | radius-= margin; | ||
| for ( var i=0; i<na; i+=1 ) | for ( var i=0; i<na; i+=1 ) | ||
| { | { | ||
| - | /* 400 is the radius */ | + | x = Math.cos(Math.PI*2*i/na-Math.PI/2) * radius; |
| - | x = Math.cos(Math.PI*2*i/na-Math.PI/2) * 400; | + | y = Math.sin(Math.PI*2*i/na-Math.PI/2 ) * radius; |
| - | y = Math.sin(Math.PI*2*i/na-Math.PI/2 ) * 400; | + | |
| - | /* move circle to the middle of the screen */ | + | |
| x+= desktop.getWidth()/2; | x+= desktop.getWidth()/2; | ||
| - | y+= desktop.getHeight()/2; | + | y+= desktop.getHeight()-radius; |
| - | /* offset (would be nice to know item width) */ | + | x-= size/2; |
| - | x-= 67; | + | y-= size + margin; |
| - | y+= 300; | + | |
| + | a[i].setScale(1, 1); | ||
| + | a[i].setSize(size, size); | ||
| a[i].setPosition(x , y); | a[i].setPosition(x , y); | ||
| } | } | ||
| </code> | </code> | ||