CGContextSetAlpha is acting like multiply - ios

I have a painting app, and if i paint a red dot, then try to paint over it with a yellow dot but at a low alpha value it acts like a multiply blend mode, even if i keep going over the red dot with the yellow. Shouldnt it start to cover up the red dot, even if the yellow alpha is 0.5 or another lower value? How can I make a low alpha value continue to build up when applied and cover a color with a higher alpha? I'm I making sense?
Im calling these methods below in this order with red, then changing the color to yellow and drawing over the red, the result is in the attached image.
CGContextSetFillColorWithColor();
CGContextSetAlpha();
CGContextMoveToPoint();
CGContextAddEllipseInRect();
CGContextFillPath();
thanks

Related

Skip a particular color in smart invert mode of accessibility

Is there any way to skip a particular color in whole app when device is in smart invert mode of accessibility?
I don't want the blue color in my app to be inverted. I have am image which have black and blue color text in it. I want the black color text to be inverted but want to skip blue color.
Any help would be appreciated.
P.S -I am familiar with accessibilityIgnoresInvertColors. But this property can be applied on uiview or object but i need to skip a color.
do it inside the appcolor constant file :- you can check UIAccessibilityIsInvertColorsEnabled() if its true then return clear color else reurn the blue color.

Change text color of page which is in form of UIImage

I am making an app for book reading, the content of the book is in form of images and I want to change the text colour of the page (image). I have tried many of filters like CIFalseColor, CIColorInvert etc. background colour of the page is white and text colour is black. How can I change the only text colour to green etc. and how can I change the background colour of the image which is white now.
You should be able to achieve this using CIColorMatrix.
To transform black text on white to black text on green you can apply a CIColorMatrix to "turn off" the red and blue channels, so you'll be left with just green. Use [0 0 0 0] as the input vectors for R and B but keep inputGVector as [0 1 0 0]. White will become green (0,1,0) and black will still be black (0,0,0).
To transform black text on white to green text on white you can apply a CIColorMatrix to force the green channel to 1, keeping the others intact. Use all the default input vectors except inputGVector which you set to [1 1 1 0]. White will still be white (1,1,1) and black will now be green (0,1,0).

Zeroing channels of cut out area

I imagine there is probably going to be an easy solution for this in GIMP, but I for the life of me can't figure it out.
I'm using the color picker tool with the use info window selected to verify pixel values.
Basically, I have some pixels in an image that I need to zero out. By that I mean I want the RGBA values to all be set to 0.
I attempted to:
use the rectangular select tool to select the group of pixels
use bucket fill to set the pixels to black with opacity set to 0.0
Then, to verify it was done correctly, I use the color picker to test the value of the rectangle I just filled.
Unfortunately, it seems to just contain the previous value. What am I missing here?
The "opacity" of the bucket-fill is the opacity of the paint, not the opacity of the resulting pixels. In other words the less opaque it is, the less visible the result. What you want to do is bucket-fill selection with black, then [delete].

UIView background color set is not what appears

I created a UIView with a set background color. Lets say RGB value 185, 45, 42. For some reason, when I take a screenshot of this view, it is not that color. It is a little bit darker. Is there a reason why UIView would do this?
The UIView background color is set in interface builder like this:
When I run it on the simulator and take a screenshot and use the eye drop tool to determine the color, the numbers that show up are a little bit darker than what I entered. Same with a button.
I have other screens with the same red color and the screenshot I take of those, the red actually comes out correctly. I've been trying to determine what the difference is between those screens, but so far have not seen any. So I was just wondering if anyone would have any knowledge of anything that "could" case such a color change.
A common mistake when setting a color numerically in Interface Builder is to neglect the color space:
Different color spaces will give different colors (visually) for the same RGB values.
When you set RGB color, you should notice that all the three color values range from 0 to 1, so give them a value greater than 1 would never work. Try this:
RGB(185 / 255.0, 45 / 255.0, 42 / 255.0)

Rounded textBox

Is ShapeRenderer class has the ability to do this,I would like to create boundaries for a custom object (such as a rectangle with rounded corners) and then fill it.And after that some text on that filled rounded box.
shapeRenderer.begin(ShapeType.Filled);
shapeRenderer.setColor(Color.RED);
//shapeRenderer.line(...);
shapeRenderer.curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments);
shapeRenderer.line(...);
shapeRenderer.curve(...);
shapeRenderer.line(...);
shapeRenderer.curve(...);
shapeRenderer.line(...);
shapeRenderer.curve(...);
shapeRenderer.setColor(Color.BLACK);
shapeRenderer.fill();
shapeRenderer.end();
Any suggestion to do it in libgdx.
As Lestat said, you can use Scene2d.
Whether you are using Scene2d or not, a NinePatch would probably be suitable if you want to draw a rounded rectangle that scales well (check this link).
If you want to be able to set the color of your image/control, you can use NinePatch.setColor().
Here are two example scenarios regarding colors:
You will always have a black stroke/outline, and an arbitrary fill. In this case make the original image have black stroke/outline and white interior. When you 'tint' the image using NinePatch.setColor(), the stroke/outline will be unaffected and will remain black, while the interior (fill) will be the same as the color provide to the mentioned method.
You have arbitrary fill and arbitrary stroke. In this case you need 2 separate original images. First one would contain the 'fill' and would be completely white. Second one would contain the 'stroke' in white color and would be transparent inside. When drawing you would draw first the fill with its tint and then the stroke with its tint and that's all.
If for some reason you needed different corner curve radii, you would probably need separate images (or image pairs) for each radius to get the best result.

Resources