I have drawn a path on a view, All I need is to apply a gradient blur effect from the outer edge of the closed drawn path to the view's bounds. My question is mainly about the Gradient blur effect rather than applying it on the path.
I've not tried this but believe you could make it work:
create the path
use the path as a mask can create an new image that is clear outside the path while selecting the interior of the path (the interior has to be opaque)
use a radial blur on the whole image
composite the saved interior path OVER the blurred image
stroke the path to get a clear definition between the original interior and the blurred exterior
Related
I have two images, one that is a monochrome one which is a mask and another one with full color. What I need to do is find the CGRect of the mask (white pixels) in the other full color one.
What I did is to first find the contour of the mask using the Vision framework. Now, this returns a CGPath which is normalised. How can I translate this path into coordinates to the other image? Both have been scaled the same way to make them the same size so the translation should be "easy" but I can't figure it out.
Need to achieve this by detecting shape path within the image.
Creating images from bezier path is one solution but can we get path or draw a border around the shape with any other way?
Image will be in the even odd rule layer. How to detect path in it?
I have downloaded the new Facebook messanger App for iOS. I was wondering, is there some option that allows to "crop" an image and leave only a circle?
Would be great to be able to put a UIImage which is rectangular and crop the circular part.
Or do you think this is done server-side? In other words, there is no special iOS cropping function but simply a cropping software on the Facebook server?
use
imageView.layer.cornerRadius=imageView.frame.size.width/2.0;
imageView.clipsToBounds=YES;
This is actually quite easy to do.
What you want to do is to create a CAShapeLayer the same size as your view. Create a UIBezierPath that uses a rounded rectangle who's corner radius is 1/2 the height/width. That gives you a circular path.
Install the bezier path's CGPath into the shape layer. Then set the shape layer to fill with an opaque color.
Finally, install the shape layer as the mask on your view's layer. The result is that the shape layer clips the view and only shows the opaque parts of the shape layer.
I have two shapes in a UIView - one, an ellipse and two, a triangle drawn using UIBezierPath. I need to draw the outline of these two shapes combined. How can I do it?
You can do an "outside" stroke (like stroke->outside in photoshop/pixelmator) by calling stroke to draw the outline and setting the inverse of your shapes as the clipping path first. To do the inverse of the clipping path see this answer: https://stackoverflow.com/a/10639523/461492 (read comments too).
So here are the steps:
Set the full area as the clipping path.
Call CGContextEOClip() for each of your shapes as described in the comments to the answer linked above.
Stroke your shapes.
This might not be exactly what you want - it will draw the stroke as normal but the whole interior (the fill area) of your shapes will not be drawn. So whereas the thickness of the stroke would normally extend within the interior of your shapes, and the internal angles of your stroke would normally have the correct corners (rounded/mitered) - in this case it would be more like you stroked the shapes then deleted the fill-area, or did an "outside" stroke in an image editing program.
I have logo text drawn as shapes (closed CGBezierPaths) that I want to fill with a gradient.(Light at the top, moving to dark at the bottom) How can I fill each shape with gradient such that the gradient is the same color for each shape.
The problem is drawing the gradient for each shape, if the letters are different height then the gradient has a different ramp since the distance is smaller. Hope that makes sense.
So basically I want draw a single gradient down the rect and use all the shapes as a clipping mask. Is this possible?
For gradient drawing - take a look at this project:
https://github.com/wczekalski/CDPieMenu
It creates gradient using two colors programmatically.