diff --git a/misc/icons/noun-project/sheep/icon_8389.png b/misc/icons/noun-project/sheep/icon_8389.png new file mode 100644 index 00000000..2e3dbf76 Binary files /dev/null and b/misc/icons/noun-project/sheep/icon_8389.png differ diff --git a/misc/icons/noun-project/sheep/icon_8389.svg b/misc/icons/noun-project/sheep/icon_8389.svg new file mode 100644 index 00000000..673f4f70 --- /dev/null +++ b/misc/icons/noun-project/sheep/icon_8389.svg @@ -0,0 +1,41 @@ + + + + + + diff --git a/misc/icons/noun-project/sheep/license.txt b/misc/icons/noun-project/sheep/license.txt new file mode 100644 index 00000000..31ca6c35 --- /dev/null +++ b/misc/icons/noun-project/sheep/license.txt @@ -0,0 +1,8 @@ +Thank you for using The Noun Project. This icon is licensed under Creative +Commons Attribution and must be attributed as: + + Sheep by Unrecognized MJ from The Noun Project + +If you have a Premium Account or have purchased a license for this icon, you +don't need to worry about attribution! We will share the profits from your +purchase with this icon's designer. diff --git a/src/css/tools.css b/src/css/tools.css index 216c39a0..89a2e907 100644 --- a/src/css/tools.css +++ b/src/css/tools.css @@ -108,6 +108,12 @@ background-size: 26px; } +.tool-icon.tool-clone { + background-image: url(../img/tools/clone.png); + background-position: 9px 15px; + background-size: 30px; +} + /* * Tool cursors: */ diff --git a/src/img/tools/clone.png b/src/img/tools/clone.png new file mode 100644 index 00000000..ca02ff71 Binary files /dev/null and b/src/img/tools/clone.png differ diff --git a/src/js/controller/TransformationsController.js b/src/js/controller/TransformationsController.js index c7cff937..d1e3a71d 100644 --- a/src/js/controller/TransformationsController.js +++ b/src/js/controller/TransformationsController.js @@ -8,8 +8,9 @@ }; this.tools = [ - toDescriptor('flip', 'F', new pskl.tools.transform.Flip()), - toDescriptor('rotate', 'V', new pskl.tools.transform.Rotate()) + toDescriptor('flip', '', new pskl.tools.transform.Flip()), + toDescriptor('rotate', '', new pskl.tools.transform.Rotate()), + toDescriptor('clone', '', new pskl.tools.transform.Clone()) ]; this.toolIconRenderer = new pskl.tools.IconMarkupRenderer(); diff --git a/src/js/tools/IconMarkupRenderer.js b/src/js/tools/IconMarkupRenderer.js index 93fcbef2..e4979283 100644 --- a/src/js/tools/IconMarkupRenderer.js +++ b/src/js/tools/IconMarkupRenderer.js @@ -5,6 +5,7 @@ ns.IconMarkupRenderer.prototype.render = function (tool, shortcut, tooltipPosition) { tooltipPosition = tooltipPosition || 'right'; + shortcut = shortcut ? '(' + shortcut + ')' : ''; var tpl = pskl.utils.Template.get('drawingTool-item-template'); return pskl.utils.Template.replace(tpl, { cssclass : ['tool-icon', tool.toolId].join(' '), diff --git a/src/js/tools/transform/Clone.js b/src/js/tools/transform/Clone.js new file mode 100644 index 00000000..e648adb7 --- /dev/null +++ b/src/js/tools/transform/Clone.js @@ -0,0 +1,25 @@ +(function () { + var ns = $.namespace('pskl.tools.transform'); + + ns.Clone = function () { + this.toolId = "tool-clone"; + this.helpText = "Clone current layer to all frames"; + this.tooltipDescriptors = []; + }; + + pskl.utils.inherit(ns.Clone, ns.Transform); + + ns.Clone.prototype.apply = function (evt) { + var ref = pskl.app.piskelController.getCurrentFrame(); + var layer = pskl.app.piskelController.getCurrentLayer(); + layer.getFrames().forEach(function (frame) { + if (frame !== ref) { + frame.setPixels(ref.getPixels()); + } + }); + $.publish(Events.PISKEL_RESET); + $.publish(Events.PISKEL_SAVE_STATE, { + type : pskl.service.HistoryService.SNAPSHOT + }); + }; +})(); \ No newline at end of file diff --git a/src/piskel-script-list.js b/src/piskel-script-list.js index c09dc748..677428f1 100644 --- a/src/piskel-script-list.js +++ b/src/piskel-script-list.js @@ -164,6 +164,7 @@ "js/tools/drawing/ColorPicker.js", "js/tools/drawing/ColorSwap.js", "js/tools/transform/Transform.js", + "js/tools/transform/Clone.js", "js/tools/transform/Flip.js", "js/tools/transform/Rotate.js", diff --git a/src/templates/drawing-tools.html b/src/templates/drawing-tools.html index 479dbdef..20fb8290 100644 --- a/src/templates/drawing-tools.html +++ b/src/templates/drawing-tools.html @@ -41,7 +41,7 @@