I want to mask a CCSprite in my training project with bezier path - make a path programmatically and use it as a mask on CCSprite's image. I googled a lot but I only found tutorials for simple masking (image - image), not shapes and paths.
Any tutorials or approaches would be greatly appreciated. Thanks
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 one requirement to show the a shape (like Home or Car etc) and depending upon the percentage of the condition will be filled with animation
I was trying with image but when I googled, I found this can be achieved by drawing image using Bezier curve.
So this is the image I am trying to draw and there are other images too.
So here are my two questions :
Can I achieve this using UIImage directly.
If not then how can i draw bezier
curve for such images. How will I calculate the points.
I'm trying to change the shape of a CAShapeLayer from a circle to a different shape. Looking at this question:
Smooth shape shift animation
I found the solution but my question is how can I visually see how many points a UIBezierPath has. Is there a way to color a point different than the line it produces?
For example,it's simple with a line to understand that there are two point, but if we make a circle with bezierPathWithRoundedRect, does that count as one point or are there more?
You would need to add the circle yourself to visually see the dots. Just keep track of the CGPoints you give to the path and draw a circle around each one.
Btw.. if you use PaintCode, you can edit the bezier path and see the point -- it's very useful.
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.