Core graphics color blending - iphone

I have a line of text which I want to display behind a CALayer, and when behind, then the text color should appear in a different color in the overlapping area.
The color of the text is black, and the text color should appear as white on the red layer when they overlap (they may both move around, so this needs to be continuously updated).
How may this be accomplished?

This can’t be done with any blend mode. You’ll need to render the text into the foreground layer in white by hand.
One trick you could try is to keep the white text always visible, but clipped by the layer that moves around using a second layer that also moves, set as the text’s mask.

Related

Flutter change transparency of png image with finger touch

I have a png image with transparent areas and opaque areas.
I want to be able to draw with my finger, with GestureDetector for example, on that image to be able to add transparency in the opaque areas and add opaque areas in the transparent areas. Both. For example with a button that allows you to switch between erase and paint modes.
The objective is that it can represent two images on the screen, inside a stack, one after the other. The back image is completely opaque and the front image has areas with transparency and you can paint over it as I mentioned before. In this way, as you add transparent areas in the front image, what is in the back image will be revealed. And conversely, you can add opacity to the image so that the image behind is hidden by the image in front.
I've tried CustonPaint but it's very difficult since you would have to add the image with drawImage, and do a lot of complicated steps. And I couldn't change the transparency of the image either, also, even if I could, with CustonPaint if you draw a lot, the screen slows down.

Incorrect white matte behind antialiasing on imported sprites

I'm importing a sprite into Unity, and adding it to a Screen Space Overlay canvas to use for a UI.
The image I'm importing looks exactly as I want it, but in Unity the anti-aliased edges look like they're going to a white background color, instead of just fading over whatever is actually behind them.
I'm using these import settings:
I'm using a default UI/Image component to add it to the canvas.
This is the image I'm importing - it's a 32 bit PNG exported from Fireworks: (also shown over a black background)
Just to confirm, this looks fine everywhere else in Unity, preview panels, pickers etc. I am packing this sprite using the built in Sprite Packer if that changes anything.
And the final result:
How can I get rid of these artifacts on the corners?
The problem was the RGB values of the transparent pixels. By default they are white, and any scaling operations cause this white color to be blended with the partially transparent pixels.
I essentially made a slightly larger version of the button background shape, put it in a layer behind everything, and then wrote back into the alpha channel making it transparent. This means that the neighboring pixels are then the same color as the partially transparent ones.
The end result:

How to create an art asset that can be dynamically colored in software?

I asked this question on the Graphic Design site, but it includes a programming component that might be better answered here.
Specifically, I have a bunch of photographic crayon images. I would like to remove the color from one to produce a neutral image that I can load into an iPhone app that I'm writing and dynamically color. The crayon images have dark regions (shadows) and light regions (shine) which I would like to preserve. I will be dynamically coloring it with many different colors, ranging from white to rainbow colors to black.
My first inclination is to turn the image into a grayscale image and then somehow turn the color channel into an alpha channel, and change the color of all pixels to black. Then I could use it as a mask. However, this would only preserve the shadows, and I would lose all the highlights.
Any ideas?
Two options come to mind:
Make a grayscale version that could be tinted as you said, with the shadows and highlights simply white and gray.
Make an outline, i.e. an image with alpha that had 0% opacity in the colored parts, say 10% white over the highlights, 10% black on the shadows, and 100% black/dark gray for the lines/edges. The idea being that you could put any color under the outline and it would look right.

Change background color of UIModalTransitionStyleFlipHorizontal

I would like to change the color behind the flip from white to a different color or picture. Is that possible?
Change the background colour of the UIWindow in MainWindow.nib. Either "black" or "clear" should both work (I think...)
It's one of the first things I do to any app, otherwise you get bits of white showing on a view rotation (in the very old days of 2.x there were huge patches of white; they've since masked off the screen edges during a rotation, but a few pixels still show through) and when you show/hide the status bar (e.g. for UIImagePicker) and stuff. Black looks a lot better than white for the window background.

How to align an 90 deg rotated label perfectly with the pixels?

When rotating a label, the text is rendered very ugly. Is there an convenient way to get the label aligned with the pixels? Maybe there is some way of rounding the transform of the view, so that it isn't misaligned?
If you use CGAffineTransformRotate or a similar function you won't see any artifacts in the text because the label is drawn first and then rotated in its entirety.
If you are seeing artifacts using a transform, then the most likely source is a transparent label background distorting the appearance of the text. If the background is variable, such as pin stripe or a picture, then rotating the text will put different pixels adjacent to the text which can muddle its outline and apparent color.