how to set circle shape of rectangle sprite in cocos2d? - ios

I have images in rectangle shape. When I use them in CCSprite, they are displayed as in Rectangle shape. But I want to change the shape of rectangle to circle and that circle image should be set in to another circle sprite. As displayed below.
Here, chicken original image is in rectangle shape and another chicken border image is circle. I want that chicken original image to be displayed in circle shape and after fit in to chicken border image that's circle.
i also check link

you will need to use box2d with cocos2d.
please check the link blow:
http://www.codeandweb.com/blog/2011/06/16/using-texturepacker-and-physicseditor-together

Related

Swift 3, draw circle with special lineCap

Currently I'm using CAShapeLayer and UIBezierPath to draw a line for avatar. It's Ok for the normal one with lineCap = kCALineCapRound. BUT I've been STRUGGLING to draw line with START and END lineCap like image below:
You can't draw this circle with a shape layer, because a shape layer supports only one single stroke color. You should write your own layer class where you should draw three separate circle segments with kCALineCapRound:
A full yellow circle.
Draw the blue segment over the yellow circle. It is visible and you can see the rounded ends.
Draw a segment of the yellow circle, say 5 degrees of the top. Then you can also see the rounded end of the yellow line.
You should use CGPath and CGContext instead of UIBezierPath.

How can i blur and focus on image in ios sdk

i want to blur Whole image and display circle or rectangle area on image.
with move the circle and rectangle on image.save the blur image without circle and rectangle.

CAGradientLayer with Angle

I am drawing CGPath which is not rectangle or square,and adding CGPath to CAShapeLayer. This CAShapeLayer's frame getting from CGPath using CGPathGetBoundingBox(path). So it will be rectangle or square. Now i want to set gradient color to layer but my path is not rectangle or square so it is not spreading gradient color equally in whole CGPath. Is there any way to set gradient color to CGPath or how can i set gradient color with angle?
Please refer screen shot to understand situation. Here white color indicates frame of CGPath and green colour, that is our drawn CGPath. At the bottom of CGPath you can see white gradient colour which is not distributed equally in CGPath.
The start and end points of a linear gradient are specified in points relative to the whole size of the layer, with (0,0) at the top left and (1,1) at the bottom right.
Therefore, to make a linear gradient at an angle, you simply need to set the start and end points appropriately. For example, If you used (0,0) and (1,1) as the start and end points, the gradient would run from the top left to the bottom right, at a 45 degree angle.
Working out the specific start and end points for your needs is therefore just a matter of trigonometry.

Cocoa CoreGraphics: How to fill multiple shapes with a gradient

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.

Best way to display rounded corner image with sprite

I need to display image with rounded corner with sprite. What is the best way to do this.
I explained how to do it in your other post ...
How to clip the texture in rounded shape
If you mean of smoothing the corners of the image you're drawing, there is no way to do with the normal sprite interface (other than modifying the original image to be smoothed beforehand)
To do it you must work with shaders.

Resources