Hartix
Hartix

Reputation: 330

Matching AppKit and SpriteKit colors

I am building a small utility app for macOS that combines SpriteKit with AppKit. Specifically, I am using an SKView as the "background" for the app window (mostly for specific types of animations that are easier in SpriteKit). I am also changing colors of the Window's background property to adjust the title bar color. Switching between green and red.

The issue I am running into is matching colors between AppKit and SpriteKit. In short, they don't match. As you can see in the image the title bar is a bit different than the SKView.

enter image description here

After a bit of playing, I found that the background color in the SKView is in the "Device RGB colorspace" and the Window's colors are in "sRGB IEC61966-2.1 colorspace." I changed the AppKit colors to device RGB and the colors still don't match.

I'm creating the colors with a regular old NSColor initializer.

I'm not sure if you can change the color space of a color. The backgroundColor property on the Window and SKView is read only.

Any ideas?

Upvotes: 9

Views: 258

Answers (2)

Dave Weston
Dave Weston

Reputation: 6635

My guess is that this is due toNSWindow.StyleMask.fullSizeContentView. When this is set, the title bar applies a blur by default.

If you want the colors to be the same, tell the window to use a transparent title bar:

window.titlebarAppearsTransparent = true

Upvotes: 0

E. Huckabee
E. Huckabee

Reputation: 1818

if im reading this right what you are wanting to do is match colors could you not just do something like yourAppKit.backgroundColor = yourSKView.backgroundColor that should set them to equal

and my second question is do you need them to match? most of the time people arent gonna notice and if they do notice they wont really care

also here is some data on converting RGB to sRGB

Upvotes: 1

Related Questions