Using PencilKit in dark mode results in wrong color - ipados

When in dark mode, it seems that all the color set in PKInkingTool are reversed in brightness. If I choose a bright red I got a dark red, and vice versa.
For example, if I use UIColorPickerViewController to select a color:
PKInkingTool(.pencil, color:color, width:10)
The color that shows up in PKCanvasView is not the correct color. The only way that seems to work is not to support dark mode.
overrideUserInterfaceStyle = .light
Is there a way to get PencilKit to use the correct color rather than convert color automatically?

You can use 'colorUserInterfaceStyle' for 'PKToolPicker' but in that case if you want to save the drawn part you might have to concern.
colorUserInterfaceStyle = .light

Related

How Do I Change NavigationBar Color For WatchOS?

I am building watchOS app and I am trying to change navigationBar background color from black to transparent, but I am not able to find anything. I saw this question which was asked in 2015, according to which it is impossible to change navigationBar color in watchOS. I was wondering if now there is any API for that.
Thanks for any help.
This is about Color in the human-interface-guidelines from apple:
Make sure your app’s colors work well in both light and dark
appearance modes. With the exception of watchOS, which always uses a
pure black background, the platforms offer a dark alternative to the
default light appearance. Dark Mode uses a darker color palette for
all screens, views, menus, and controls, and can increase vibrancy — a
subtle effect that dynamically blends foreground and background colors
— to make foreground content stand out against darker backgrounds.
System colors automatically support both appearances; if you use a
custom color, you need to supply both light and dark variants. For
guidance, see Dark Mode.

How can I programmatically access Dark mode colors when in light mode and vice versa in SwiftUI?

An accentColor can have an "Any Appearance" color and a "Dark Appearance" color. Lets say, I'm in light mode, how can I access the dark mode color programmatically without manually setting the color mode to dark mode?
You need to resolve your named color to trait collection of dark style, like
.background(
Color(UIColor(named: "testColor")?.resolvedColor(with:
UITraitCollection(userInterfaceStyle: .dark)) ?? UIColor.darkText)
)
Tested with Xcode 12.4 / iOS 14.4
Note: tune to your color name and any default color to unwrap optional

How do I set a view's background to the gray'ish one in SwiftUI?

I noticed that whenever I create a view it automatically gets a white background color. If you insert a list however, no matter the size, the entire view seems to get a sort of grey background, which looks better to me than a white background. I'm wondering how I can get my background to look like this (without using a list, or an invisible dummy list maybe)? I've already tried getting the color code but that just gives me a dark grey background. I tried adjusting the opacity but it just isn't the same as the native one.
edit: It appears the size of the list does matter, it seems to have something to do with NavigationViews and NavigationLinks
That is the default group table view background color (systemGroupedBackground) with the color code #F2F2F7. You can use it as a background color like this:
.background(Color(red: 0.949, green: 0.949, blue: 0.97, opacity: 1.0))
...or simply:
.background(Color(.systemGroupedBackground))
Keep in mind that with the latter solution, the color might change in later iOS versions if Apple decides to change the value of the constant.

cmd how do i use 24 colors?

When i select the dark colors they get inverted to a color that don't applies to the console. If i select dark yellow "rgb 0 128 128" it inverts to a light blue "rgb 127 127 255" color, that color is not a standard color and can't be used by ordinary methods like,
SetConsoleTextAttribute, ANSI.SYS \033[1;34m
It would help me so much if i could get the answer.
Thanks! :)
Picture Of The Colors
The question is: how to make colors of selected-cells on a console window look like some reversed version (e.g., foreground and background switching) of the unselected colors.
This behavior is built into the console window (or more generally, a terminal). There is no escape sequence or other documented feature of console windows which can do this.
In the more general sense, this aspect is different on various terminals. xterm for example can:
exchange foreground and background colors, or
use specific colors for the selected text.
xterm does this by mapping between different items in its color table.
Some other terminal may implement the color change by XOR'ing the color value, mapping 0 to 255 and 255 to 0 (white/black). This is very simple to implement. However, for colors other than white and black, it produces an effect like that shown in your picture.

ClearType ruins transparency

I have a bitmap which background needs to be replaced with part of another bitmap. Everything works fine until I enable ClearFont on my WindowsXP.
In order to explain my problem better, let us label first bitmap as bmpDestination and second as bmpSource.
Here is how the bmpSource looks like :
Here is how bmpDestination looks like :
When ClearType is off, here is how the correct result looks like :
And here is the incorrect result of their combining when ClearType is on:
ClearType alters some parts of the text background color, so they aren't white anymore ( RGB( 255, 255, 255 ) ) but a combination of white and text color.
I am using BitBlt() and monochrome bitmap to create a mask, and to simulate transparency. I have tried using TransparentBlt() too, but got the same result.
How can I combine bmpSource and bmpDestination, when ClearType is enabled, so I can create correct result like above ?
Thank you for your help.
Best regards.
Render the treeview with black text on a white background. Use a font with grey-scale anti-aliasing. Don't use ClearType anti-aliasing. I'm moderately sure you can achieve this with one of the fdwQuality parameters to CreateFont, but I wouldn't swear to it.
Each pixel will have a shade of grey between white and black. You can interpret this as transparency. White is fully transparent; black is fully opaque. Use this information to create a bitmap with transparency. Render this transparent bitmap over your multi-coloured background.