Skip to content
Merged
16 changes: 7 additions & 9 deletions Pika/Services/Eyedroppers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,10 @@ class Eyedropper: ObservableObject {

init(type: Types, color: NSColor) {
self.type = type
self.color = color
self.color = color.usingColorSpace(.sRGB) ?? color

// Load colors
closestVector = ClosestVector(colorNames.map { $0.color.toRGB8BitArray() })

Defaults.observe(.colorSpace) { change in
self.color = self.color.usingColorSpace(change.newValue)!
}.tieToLifetime(of: self)
}
Comment thread
superhighfives marked this conversation as resolved.

func getClosestColor() -> String {
Expand All @@ -98,7 +94,7 @@ class Eyedropper: ObservableObject {
self.set(previousColor)
}

color = selectedColor.usingColorSpace(Defaults[.colorSpace])!
color = selectedColor.usingColorSpace(.sRGB)!
}
Comment thread
superhighfives marked this conversation as resolved.
Comment thread
superhighfives marked this conversation as resolved.

@objc func colorDidChange(sender: AnyObject) {
Expand All @@ -108,7 +104,7 @@ class Eyedropper: ObservableObject {
self.set(previousColor)
}

color = picker.color.usingColorSpace(Defaults[.colorSpace])!
color = picker.color.usingColorSpace(.sRGB)!
}
Comment thread
superhighfives marked this conversation as resolved.
}

Expand Down Expand Up @@ -139,14 +135,16 @@ class Eyedropper: ObservableObject {
sampler.show { selectedColor in

if let selectedColor = selectedColor {
let normalizedColor = selectedColor.usingColorSpace(.sRGB)!

if Defaults[.showColorOverlay] {
let colorText = selectedColor.toFormat(
let colorText = normalizedColor.toFormat(
format: Defaults[.colorFormat], style: Defaults[.copyFormat]
)
let cursorPosition = NSEvent.mouseLocation
self.overlayWindow.show(
colorText: colorText,
pickedColor: selectedColor,
pickedColor: normalizedColor,
nearCursor: cursorPosition,
duration: Defaults[.colorOverlayDuration]
)
Expand Down
Loading