Matching AppKit and SpriteKit colors
Asked Answered
F

2

9

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?

Fortin answered 29/9, 2017 at 15:57 Comment(2)
sounds annoying!! I know that SKColor for osX is NSColor and SKColor for iOS is UIColor... interested to learn more about this as well!Ruthenium
First of all use SpriteKit scene in UIView Decompose all R,G,B,A values alone and math them R with R and so onVenter
K
1

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

Kush answered 7/10, 2017 at 9:4 Comment(2)
Yes, they need to match. I guess I could purposely move them further apart and make it purposeful, it just isn't what I'd like.Fortin
could you edit your anwser with some screen shots so I can see exactly what you mean (shift+cmd+4 to take a screenshot of selected area)Kush
F
0

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
Flexion answered 2/5, 2021 at 16:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.