I want to use PencilKit to draw perfectly shaped shapes. What should I do? - ios

Using Apple's own photo album, when editing photos, I used the Apple Pencil to draw blurred red paths, keeping and then creating perfect circles.
I looked at the API for PencilKit and found that Apple does not provide one. But I want to implement drawing in my application and keep creating the perfect shape. How do I do that?

Shape recognition is a private API. Only Apple's app can use it. My suggestion would be: Check last stroke in the canvasViewDrawingDidChange(), then check with your algorithmen which shape it is, then create a beautiful PKStroke and replace the last stroke.

Related

Text in Cocos3d

I am developing an iPhone application that uses Cocos3d to draw shapes and images. Now I want to draw some text. Can anyone please guide me on how to draw text using Cocos3d?
Thanks in advance!
If you want to embed text in the 3D scene (like add a sign on a wall within the 3D scene), you can use CC3BitmapLabelNode. The CC3DemoMashUp app includes an example of how to do this, in the addBitmapLabel method of CC3DemoMashUpScene. The example actually does more than you need, because it uses a specialized subclass of CC3BitmapLabelNode that wraps the text around a cylinder. But it will give you the idea of how to use CC3BitmapLabelNode.
If you want to add text as a 2D overlay as part of the user interface (like a button, menu, or message to the user), use the standard Cocos2D components for that. You can add these 2D components to your customized CC3Layer. See the CC3DemoMashUpLayer for an example of how to do this.

How to paint using brush with particular area...

I want to fill each and every part with different colours like circle with other colour and each leave with different colour and stick with different colours. I have bunch of colours. You can fidn similar apps like Toonia Color book on apple app store...
I am unable to get bounds of particular part in image.
I searched a whole day before writing this question. Every one is saying just look for flood fill and Quick Fill algorithms but i am not able to solve this problem.
In Toonia Colorbook this is done using vector graphics and masks. Every shape is described as a bezier curve that masks a drawing layer.
check out CAShapeLayer and CALayer for further details

UIImageView Annotation

I am trying to capture an Image from Camera show it on the UIImageView.
After that I have some buttons for e.g. "Paint Brush", "Eraser", "Undo", "Save".
Using Brush I want to mark some items on the image captured.
What is the best way to accomplish the annotation and then save the image.
I am not sure what should be used. Should I use touchesbegan/end etc.. or some other alternative.
Regards,
Nirav
U need to understand Bézier Path Basics.Search it on Google or Apple Documentation.
The UIBezierPath class is an Objective-C wrapper for the path-related features in the Core Graphics framework. You can use this class to define simple shapes, such as ovals and rectangles, as well as complex shapes that incorporate multiple straight and curved line segments.

iOS FloodFill : UIImage vs Core Graphics

I'm considering building an app that would make heavy use of a flood fill / paint bucket feature. The images I'd be coloring are simply like coloring book pages; white background, black borders. I'm debating which is better to use UIImage (by manipulating pixel data) or drawing the images with Core Graphics and changing the fill color on touch.
With UIImage, I'm unable to account for retina images properly; it destroys the image when I write the context into a new UIImage, but I can probably figure out. I open to tips though...
With CoreGraphics, I have no idea how to calculate which shape to fill when a user touches an area and then actually filling that area. I've looked but I have not turned up a successful search.
Overall, I believe the optimal solution is using CoreGraphics, since it'll be lighter overall and I won't have to keep several copies of the same image for different sizes.
Thoughts? Go easy on me! It's my first app and first SO question ;)
I'd suggest using Core Graphics.
Instead of images, define the shapes using CGPath or NSBezierPath, and use Core Graphics to stroke and/or fill the shapes. Filling shapes is then as easy as switching drawing mode from just stroking to stroking and filling.
Creating even more complex shapes is made much easier with the "PaintCode" app (which lets you draw and creates the path code for you).
As your first app, I would suggest something with a little less custom graphics fiddling, though.

Coloring Shapes in iOS app

We are building an iPad kids application in which a kid is requested to color different shapes with specific color. For example, consider an image with sky and trees , etc. all overlapping and a kid has selected a color for example "Blue" and then he taps the sky , the sky should turn to blue otherwise it should say "wrong color"
My questions are:
1- How to implement the coloring of the sky only with the selected color. We have implemented a Coco2d Floodfilling but it is too slow.
2- How to tie each part of the image with a specific right color. We suggested loading a fully colored image in a background layer and testing it at the tap .... BUT how to implement it.
Thanks
Are the shapes originally vectorial? If so, a solution would be to work directly with them as vectors, parsing them into CoreAnimation shapes.
You can give a try to SVGKit or get some inspiration from it. You'll get CAShapeLayers where you can change the fillColor property.
I believe that this way would be much more responsive (and the app size much more lighter) than doing tricks with images ;-)

Resources