Skip to content

Commit 8495bcd

Browse files
authored
Merge pull request #22 from viktorstrate/fix-grid-offset
Move crosshair and grid by 0.5 pixels
2 parents f843510 + 32d8f24 commit 8495bcd

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Pixel Picker/OverlayPanel/PPOverlayPreview.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class PPOverlayPreview: NSView, CALayerDelegate {
3737

3838
// Update the crosshair with the correct color, position and size.
3939
func updateCrosshair(_ pixelSize: CGFloat, _ middle: CGFloat, _ color: CGColor) {
40-
let pos: CGFloat = (pixelSize * middle) - (pixelSize / 2)
40+
let pos: CGFloat = (pixelSize * middle) - (pixelSize / 2) + 0.5
4141
let pixelRect = NSMakeRect(pos, pos, pixelSize, pixelSize)
4242

4343
crosshair.path = CGPath(rect: pixelRect, transform: nil)
@@ -58,11 +58,11 @@ class PPOverlayPreview: NSView, CALayerDelegate {
5858
lastNumberOfCells = n
5959

6060
let path = NSBezierPath()
61-
let start = CGFloat(0)
62-
let end = CGFloat(n) * size
61+
let start = CGFloat(0) + 0.5
62+
let end = CGFloat(n) * size + 0.5
6363

6464
for i in 1..<n {
65-
let pos = CGFloat(i) * size
65+
let pos = CGFloat(i) * size + 0.5
6666
path.move(to: NSPoint(x: pos, y: start))
6767
path.line(to: NSPoint(x: pos, y: end))
6868
path.move(to: NSPoint(x: start, y: pos))

0 commit comments

Comments
 (0)