Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanRutzky committed Aug 5, 2014
0 parents commit 6924aa6
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Swap Fill & Border
Sketch.app plugin for swapping the fill and border color for all selected layers. Works with gradients and solid filled objects.

## Installation
1. Download and open `Swap-Fill-Border-master.zip`
2. Navigate the Sketch menu bar to `Plugins ▸ Reveal Plugins Folder...`
3. Place `Swap Fill & Border.sketchplugin` into the revealed plugins directory
4. That's it...

## How to Use
Select `Plugins ▸ Swap Fill & Border` in the Sketch menu bar or use the keyboard shortcut to swap the fill and border color for all selected layers. To use with text layers, you must first convert the selection to outlines.

**Keyboard Shortcut**
`Command` + `/`

## Feedback
If you discover any issues or have questions regarding usage, please send a message to [[email protected]](mailto:[email protected]) or find me on twitter [@NathanRutzky](http://twitter.com/NathanRutzky).
82 changes: 82 additions & 0 deletions Swap Fill & Border.sketchplugin
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Sketch Plugin: Swap Fill & Border (command /)
// Source: github.com/NathanRutzky/Swap-Fill-Border
// Version: 1.0

(function() {

for (var i=0; i<[selection count]; i++) {

var layer = [[selection objectAtIndex:i] style]
var fills = [[layer fills] count]
var borders = [[layer borders] count]

if (fills && !borders) {

var fillType = [[layer fill] fillType]
var fillColor = [[layer fill] color]
var fillGradient = [[layer fill] gradient]

[[layer fill] setIsEnabled:0]
[[layer borders] addNewStylePart]
[[layer border] setThickness:2]
[[layer border] setPosition:1]
[[layer border] setFillType:fillType]
[[layer border] setGradient:fillGradient]
[[layer border] setColor:fillColor]
}

if (!fills && borders) {

var borderType = [[layer border] fillType]
var borderColor = [[layer border] color]
var borderGradient = [[layer border] gradient]

[[layer border] setIsEnabled:0]
[[layer fills] addNewStylePart]
[[layer fill] setFillType:borderType]
[[layer fill] setColor:borderColor]
[[layer fill] setGradient:borderGradient]
}

if (fills && borders) {

var borderEnabled = [[layer border] isEnabled]
var borderSize = [[layer border] thickness]
var borderType = [[layer border] fillType]
var borderColor = [[layer border] color]
var borderGradient = [[layer border] gradient]
var fillEnabled = [[layer fill] isEnabled]
var fillType = [[layer fill] fillType]
var fillColor = [[layer fill] color]
var fillGradient = [[layer fill] gradient]

if (fillEnabled && borderEnabled) {

[[layer border] setThickness:borderSize]
[[layer border] setFillType:fillType]
[[layer border] setColor:fillColor]
[[layer border] setGradient:fillGradient]
[[layer fill] setFillType:borderType]
[[layer fill] setColor:borderColor]
[[layer fill] setGradient:borderGradient]
}

if (!fillEnabled && borderEnabled) {

[[layer border] setIsEnabled:0]
[[layer fill] setIsEnabled:1]
[[layer fill] setColor:borderColor]
[[layer fill] setGradient:borderGradient]
}

if (fillEnabled && !borderEnabled) {

[[layer fill] setIsEnabled:0]
[[layer border] setIsEnabled:1]
[[layer border] setColor:fillColor]
[[layer border] setGradient:fillGradient]
}
}
}

})();

0 comments on commit 6924aa6

Please sign in to comment.