forked from nathco/Swap-Fill-Border
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
NathanRutzky
committed
Aug 5, 2014
0 parents
commit 6924aa6
Showing
2 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | ||
} | ||
} | ||
} | ||
|
||
})(); |