Skip to content

Commit

Permalink
v3.0
Browse files Browse the repository at this point in the history
Ading independent Scaling in X and Y axis feature.
  • Loading branch information
sureskumar committed Dec 27, 2018
1 parent a40162e commit ff8e6ac
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 39 deletions.
Empty file modified LICENSE
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion Looper.sketchplugin/Contents/Sketch/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Looper",
"identifier": "com.sureskumar.sketch.looper",
"version": "2.9.0",
"version": "3.0.0",
"compatibleVersion": "52.0",
"appcast": "https://github.com/sureskumar/Looper/raw/master/assets/looper.xml",
"description": "Looper is a sketch plugin that helps automate duplication of groups and layers.",
Expand Down
106 changes: 84 additions & 22 deletions Looper.sketchplugin/Contents/Sketch/scripts/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ MD.extend({
return this.MDPanel({
url: this.pluginSketch + "/panel/table.html",
width: 473,
height: 495,
height: 540,
data: data,
identifier: 'com.google.material.pattern',
floatWindow: false,
Expand Down Expand Up @@ -370,6 +370,7 @@ MD.extend({
rotate_select,
opacity,
scale,
scale_dir,
scale_px,
scale_pr,
scale_rnd,
Expand Down Expand Up @@ -450,6 +451,9 @@ MD.extend({
MD.superDebug("scale", scale);
//sendEvent(MD.context, 'Parameter: scale', scale);

scale_dir = MD.configs.table.send_scale_dir;
MD.superDebug("scale_dir", scale_dir);

scale_px = MD.configs.table.send_scale_px;
MD.superDebug("scale_px", scale_px);

Expand Down Expand Up @@ -507,18 +511,24 @@ MD.extend({
var layerName = layer.name();
MD.superDebug("ori_layer_name", ori_layer_name);
if(!ori_layer_name) {
ori_layer_name = "original_" + layerName + "_" + Math.floor(Math.random() * 100000000);
//ori_layer_name = "original_" + layerName + "_" + Math.floor(Math.random() * 100000000);
//ori_layer_name = layerName + "_original";
ori_layer_name = layerName;
}
layer.setName(ori_layer_name);

// Create a group
groupLayer = MSLayerGroup.new();
groupLayer.setName(layerName + " Group");
groupLayer.setName(layerName + "_looper");

// Add original to the group
//MD.current.removeLayer(layer);
//groupLayer.addLayers([layer]);

// Duplicate just the first copy
layer.duplicate();
layer.setIsVisible(1);
layer.setName("duplicate_1_" + layerName);
layer.setName(layerName + "_1");

// Add it to the group
MD.current.removeLayer(layer);
Expand Down Expand Up @@ -561,7 +571,7 @@ MD.extend({
if(loop > 1) {
layer.duplicate();
tempCount = j+2;
layer.setName("duplicate_" + tempCount + "_" + layerName);
layer.setName(layerName + "_" + tempCount);
}
MD.superDebug("tempCount", tempCount, 0);

Expand Down Expand Up @@ -621,24 +631,72 @@ MD.extend({
var r_temp = Math.floor(Math.random() * scale_rnd);
MD.superDebug("r_temp", r_temp, 0);
if(Math.random() > 0.5) {
newWidth = Math.floor(grid_old_w + r_temp);
newHeight = Math.floor(grid_old_h + r_temp);
switch(scale_dir) {
case 0:
newWidth = Math.floor(grid_old_w + r_temp);
newHeight = Math.floor(grid_old_h + r_temp);
break;
case 1:
newWidth = Math.floor(grid_old_w + r_temp);
newHeight = oldHeight;
break;
case 2:
newWidth = oldWidth;
newHeight = Math.floor(grid_old_h + r_temp);
break;
}
} else {
newWidth = Math.floor(grid_old_w - r_temp);
newHeight = Math.floor(grid_old_h - r_temp);
switch(scale_dir) {
case 0:
newWidth = Math.floor(grid_old_w - r_temp);
newHeight = Math.floor(grid_old_h - r_temp);
break;
case 1:
newWidth = Math.floor(grid_old_w - r_temp);
newHeight = oldHeight;
break;
case 2:
newWidth = oldWidth;
newHeight = Math.floor(grid_old_h - r_temp);
break;
}
}
break;
case 2:
//Scale PX
newWidth = Math.floor(oldWidth) + Math.floor(scale_px);
var scale_ratio = newWidth / oldWidth;
MD.superDebug("scale_ratio", scale_ratio, 0);
newHeight = Math.floor(oldHeight) * scale_ratio;
switch(scale_dir) {
case 0:
newWidth = Math.floor(oldWidth) + Math.floor(scale_px);
var scale_ratio = newWidth / oldWidth;
MD.superDebug("scale_ratio", scale_ratio, 0);
newHeight = Math.floor(oldHeight) * scale_ratio;
break;
case 1:
newWidth = Math.floor(oldWidth) + Math.floor(scale_px);
newHeight = oldHeight;
break;
case 2:
newWidth = oldWidth;
newHeight = Math.round(oldHeight) + Math.floor(scale_px);
break;
}
break;
case 3:
//Scale Percentage
newWidth = Math.round(oldWidth * (scale_pr / 100));
newHeight = Math.round(oldHeight * (scale_pr / 100));
switch(scale_dir) {
case 0:
newWidth = Math.round(oldWidth * (scale_pr / 100));
newHeight = Math.round(oldHeight * (scale_pr / 100));
break;
case 1:
newWidth = Math.round(oldWidth * (scale_pr / 100));
newHeight = oldHeight;
break;
case 2:
newWidth = oldWidth;
newHeight = Math.round(oldHeight * (scale_pr / 100));
break;
}
break;
}

Expand Down Expand Up @@ -707,20 +765,24 @@ MD.extend({
}

// Create a parent group called 'Looper_Group'
groupLayer1 = MSLayerGroup.new();
MD.current.addLayers([groupLayer1]);
groupLayer1.setName("Looper_Group");
//groupLayer1 = MSLayerGroup.new();
//MD.current.addLayers([groupLayer1]);
//groupLayer1.setName("Looper_Group");

// Add group to Canvas
MD.current.addLayers([groupLayer]);

// Remember the group's ID
created_looper_group = groupLayer1.objectID();
created_looper_group = groupLayer.objectID();


// Add child group and settings text to parent group 'Looper_Group'
MD.current.removeLayer(groupLayer);
groupLayer1.addLayers([groupLayer]);
//MD.current.removeLayer(groupLayer);
//groupLayer1.addLayers([groupLayer]);

// Resize group to fit all children
groupLayer.resizeToFitChildrenWithOption(0);
groupLayer1.resizeToFitChildrenWithOption(0);
//groupLayer1.resizeToFitChildrenWithOption(0);

MD.superDebug("- - runLooper function completed - -");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ html {
margin-top: 6px;
margin-bottom: 8px;
}
.ui_dropdown_1 {
margin-top: 0px;
margin-bottom: 8px;
}
.ui1 {
margin-top: 8px;
}
Expand All @@ -140,6 +144,12 @@ html {
.fl_cor {
margin-top: 7px;
}
.fl_cor_1 {
margin-top: 12px;
}
.fl_cor_2 {
margin-top: 2px;
}
.fr {
float: right;
}
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
send_grid_x,
send_grid_y,
send_scale,
send_scale_dir,
send_scale_px,
send_scale_pr,
send_scale_rnd;
Expand Down Expand Up @@ -70,6 +71,7 @@
move_rnd_y,
scale_selection,
scale_perf,
scale_dir,
scale_px,
scale_pr,
scale_rnd;
Expand Down Expand Up @@ -131,6 +133,9 @@
scale_perf = $('#input_scale_dropdown').val().trim();
_looperDebug("scale_perf", scale_perf);

scale_dir = $('#input_scale_dir_dropdown').val().trim();
_looperDebug("scale_dir", scale_dir);

scale_px = $('#input_scale_txt_1').val().trim();
_looperDebug("scale_px", scale_px);

Expand Down Expand Up @@ -258,11 +263,26 @@
options.send_scale = 1;
break;
}

} else {
options.send_scale = 0;
options.send_scale_inc = scale_px;
}

switch(scale_dir) {
case "both":
options.send_scale_dir = 0;
break;
case "x":
options.send_scale_dir = 1;
break;
case "y":
options.send_scale_dir = 2;
break;
}
_looperDebug("options.send_scale_dir", options.send_scale_dir);


options.send_scale_px = scale_px;
options.send_scale_pr = scale_pr;
options.send_scale_rnd = scale_rnd;
Expand Down Expand Up @@ -572,6 +592,7 @@
// Scale
_onChangeTrigger("#input_scale_toggle");
_onChangeTrigger("#input_scale_dropdown");
_onChangeTrigger("#input_scale_dir_dropdown");

// Move
_onChangeTrigger("#input_move_toggle");
Expand Down
Empty file.
52 changes: 37 additions & 15 deletions Looper.sketchplugin/Contents/Sketch/scripts/panel/table.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<div class="form-field-label" >Duplication count</div>
<div id="input_count_txt_div">
<label class="fl fl_cor">Number of copies</label>
<input type="text" id="input_count_txt" value="50" size="5" class="ui_txt fr">
<input type="text" id="input_count_txt" value="5" size="5" class="ui_txt fr">
</div>
<span class="recom">Recommended range: 1-1000</span>
<span class="recom">* total number of layers</span>
</div>

<div class="form_cont">
Expand All @@ -31,16 +31,25 @@
<div id="input_scale_controls">

<div class="ui1">
<label class="fl fl_cor">Increment in</label>
<select id="input_scale_dropdown" class="ui_dropdown fr">
<label class="fl fl_cor">Direction</label>
<select id="input_scale_dir_dropdown" class="ui_dropdown fr">
<option value="both">X and Y</option>
<option value="x">X only</option>
<option value="y">Y only</option>
</select>
</div>

<div class="ui1">
<label class="fl fl_cor_1">Increment in</label>
<select id="input_scale_dropdown" class="ui_dropdown_1 fr">
<option value="Pixels">Pixels</option>
<option value="Percentage">Percentage</option>
<option value="Randomly">Randomly</option>
</select>
</div>

<div id="input_scale_txt_1_div" class="ui1 fl_cor">
<label class="fl">Increment by <span class="grey_txt">(px)</span></label><br/>
<label class="fl fl_cor_2">Increment by <span class="grey_txt">(px)</span></label><br/>
<input type="text" id="input_scale_txt_1" value="5" size="5" class="fr">
<span class="recom">Recommended range: 5-20</span>
</div>
Expand Down Expand Up @@ -87,7 +96,7 @@

<div id="input_move_txt_1_div" class="ui1">
<div>
<label class="fl">Increment by <span class="grey_txt">(px)</span></label>
<label class="fl fl_cor_2">Increment by <span class="grey_txt">(px)</span></label>
<input type="text" id="input_move_txt_1" value="20" size="5" class="fr">
</div>
<span class="recom">Recommended range: 1-500</span>
Expand All @@ -110,6 +119,26 @@










</div>
</div>
</div>

<div class="settings-panel1">
<div class="block">
<div class="block__content">






<div class="form_cont">
<div class="form-field-label-new">
<input type="checkbox" id="input_grid_toggle" class="chcBox">
Expand Down Expand Up @@ -141,15 +170,8 @@





</div>
</div>
</div>

<div class="settings-panel1">
<div class="block">
<div class="block__content">


<div class="form-field form_cont">
<div class="form-field-label-new">
<input class="chcBox" type="checkbox" id="input_angle_checkbox_1" checked>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Looper v2.9 `⌘ + L`
# Looper v3.0 `⌘ + L`

Looper is a sketch plugin that helps automate duplication of groups and layers. One can control properties like Rotate, Scale and Opacity while duplicating. This powerful combination enables artists and designers to create interesting geometric and organic patterns.

Expand Down
12 changes: 12 additions & 0 deletions assets/looper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,17 @@
<pubDate>Wed, 03 Oct 2018 10:00:00 +0000</pubDate>
<enclosure url="https://github.com/sureskumar/Looper/releases/download/v2.9/Looper.sketchplugin.zip" sparkle:version="2.9" length="318529" type="application/octet-stream" />
</item>
<item>
<title>Version 3.0</title>
<description>
<![CDATA[
<ul>
<li>Adding independent Scaling in X and Y axis</li>
</ul>
]]>
</description>
<pubDate>Wed, 26 Dec 2018 10:00:00 +0000</pubDate>
<enclosure url="https://github.com/sureskumar/Looper/releases/download/v3.0/Looper.sketchplugin.zip" sparkle:version="3.0" length="307518" type="application/octet-stream" />
</item>
</channel>
</rss>

0 comments on commit ff8e6ac

Please sign in to comment.