Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add checkerboard background for the trim view (#140)
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
- Loading branch information
1 parent
1a8f426
commit 91dd426
Showing
7 changed files
with
133 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
38 changes: 38 additions & 0 deletions
38
Gifski/Assets.xcassets/CheckerboardFirstColor.colorset/Contents.json
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,38 @@ | ||
{ | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
}, | ||
"colors" : [ | ||
{ | ||
"idiom" : "universal", | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"red" : "1.000", | ||
"alpha" : "1.000", | ||
"blue" : "1.000", | ||
"green" : "1.000" | ||
} | ||
} | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"appearances" : [ | ||
{ | ||
"appearance" : "luminosity", | ||
"value" : "dark" | ||
} | ||
], | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"red" : "0.261", | ||
"alpha" : "1.000", | ||
"blue" : "0.261", | ||
"green" : "0.261" | ||
} | ||
} | ||
} | ||
] | ||
} |
38 changes: 38 additions & 0 deletions
38
Gifski/Assets.xcassets/CheckerboardSecondColor.colorset/Contents.json
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,38 @@ | ||
{ | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
}, | ||
"colors" : [ | ||
{ | ||
"idiom" : "universal", | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"red" : "209", | ||
"alpha" : "1.000", | ||
"blue" : "209", | ||
"green" : "209" | ||
} | ||
} | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"appearances" : [ | ||
{ | ||
"appearance" : "luminosity", | ||
"value" : "dark" | ||
} | ||
], | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"red" : "0x83", | ||
"alpha" : "1.000", | ||
"blue" : "0x85", | ||
"green" : "0x84" | ||
} | ||
} | ||
} | ||
] | ||
} |
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,37 @@ | ||
import Cocoa | ||
|
||
final class CheckerboardView: NSView { | ||
private let gridSize = CGSize(width: 8, height: 8) | ||
private let clearRect: CGRect | ||
|
||
init(frame: CGRect, clearRect: CGRect) { | ||
self.clearRect = clearRect | ||
|
||
super.init(frame: frame) | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
self.clearRect = .zero | ||
|
||
super.init(coder: coder) | ||
} | ||
|
||
override func draw(_ dirtyRect: CGRect) { | ||
super.draw(dirtyRect) | ||
|
||
NSColor.Checkerboard.first.setFill() | ||
dirtyRect.fill() | ||
|
||
NSColor.Checkerboard.second.setFill() | ||
|
||
for y in 0...Int(bounds.size.height / gridSize.height) { | ||
for x in 0...Int(bounds.size.width / gridSize.width) where x.isEven == y.isEven { | ||
let origin = CGPoint(x: x * Int(gridSize.width), y: y * Int(gridSize.height)) | ||
let rect = CGRect(origin: origin, size: gridSize) | ||
rect.fill() | ||
} | ||
} | ||
|
||
clearRect.fill(using: .clear) | ||
} | ||
} |
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
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
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