-
Notifications
You must be signed in to change notification settings - Fork 2
Update/solid outline #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
eed8545
3c47755
36a2b2c
90c909f
9807919
54de2ea
3fe8d5e
f113d54
20b1e3c
73e64c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Screen Shot 2020-09-09 at 5.43.19 PM.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Screen Shot 2020-09-09 at 5.40.22 PM.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Screen Shot 2020-09-09 at 5.41.50 PM.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Screen Shot 2020-09-09 at 5.33.41 PM.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import AppKit | ||
|
||
public struct TextAttributes { | ||
|
||
// outline attributes | ||
public static func outline(outlineWidth: CGFloat, outlineColor: NSColor) -> [NSAttributedString.Key: Any] { | ||
[ | ||
NSAttributedString.Key.strokeColor: outlineColor, | ||
NSAttributedString.Key.strokeWidth: outlineWidth, | ||
] | ||
} | ||
|
||
// shadow attributes with all available shadow settings | ||
public static func shadow(color: NSColor, | ||
offsetX: CGFloat, | ||
offsetY: CGFloat, | ||
blur: CGFloat) -> [NSAttributedString.Key: Any] { | ||
let textShadow = NSShadow() | ||
textShadow.shadowColor = color | ||
textShadow.shadowOffset = NSMakeSize(offsetX, offsetY) | ||
textShadow.shadowBlurRadius = blur | ||
return [ | ||
NSAttributedString.Key.shadow: textShadow, | ||
] | ||
} | ||
|
||
// outline attributes plus shadow attributes with all available shadow settings | ||
public static func outlineWithShadow(outlineWidth: CGFloat, | ||
outlineColor: NSColor, | ||
shadowColor: NSColor, | ||
shadowOffsetX: CGFloat, | ||
shadowOffsetY: CGFloat, | ||
shadowBlur: CGFloat | ||
) -> [NSAttributedString.Key: Any] { | ||
let shadow = NSShadow() | ||
shadow.shadowColor = shadowColor | ||
shadow.shadowOffset = NSSize(width: shadowOffsetX, | ||
height: shadowOffsetY) | ||
shadow.shadowBlurRadius = shadowBlur | ||
|
||
return [ | ||
.strokeColor: outlineColor, | ||
.strokeWidth: outlineWidth, | ||
.shadow: shadow | ||
] | ||
} | ||
|
||
// currently used in the app | ||
public static func defaultOutlineAttributes() -> [NSAttributedString.Key: Any] { | ||
outline(outlineWidth: -1.5, outlineColor: NSColor.white) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ulian-onua I added this stub for a parameter struct that makes clear which options we have.
We should make it easy to wire this up with a settings interface and be able to serialize it.
The current way the parameters are passed in is a bit hard to understand - for example I didn't understand how the font color and separate color param is different.
If we can just use a simple struct like this and make it the public interface of the package that would make it easy to customize.
I'm thinking we should allow passing in an optional params struct like this which can also be used in the Annotations module to serialize to JSON. This way we can easily construct JSON-based examples for different scenarios in the Annotations module.
We might even decide to let Zappy users tweak these parameters in an advanced settings section later.
Let's add these params the public interface of this lib and then move the SwiftUI previews into the Annotations package.