Any idea about simulating the stroke in iOS Paint app? - ios

I'm working on an paint app for iOS platform.And I used CGContextAddQuadCurveToPoint to make the line more smooth. But I'm stuck in how to simulate the stroke.
Papers 53 is a really cool app. I just wanna simulate the stroke just like what 'Papers 53' does.
Any idea about changing the width of the line dynamically and smoothly during drawing?

I found an article about this stuff.
http://www.merowing.info/2012/04/drawing-smooth-lines-with-cocos2d-ios-inspired-by-paper/
This one is really reliable and I just used its algorithm to simulate smooth stroke by using Quartz2d successfully.

Related

Recreate Photoshop's "mixer brush tool" for painting iOS app

I'm attempting to create a painting app for iOS. One feature I hope to have is like Photoshop's "Mixer Brush Tool." In Photoshop you can adjust the wetness, mix and flow of the brush.
I looked at all the core image effects, even the distortion effects but did not see anything similar. Anyone know of any sample code that does this? If not, any direction to guide me through would be great. I'm stuck at the moment.

Apple's SpeedSketch example app is very laggy

I want to create an app which uses the Apple Pencil (or just a finger) to draw/sketch/write on a blank "sheet" on the iPad. Last WWDC there was a session which shows how the Apple Pencil should be used inside an app.
Here's a link to this session: https://developer.apple.com/videos/play/wwdc2016/220/
(You can download the example app there.)
When you start to draw something it works really great. But after a while, if you have drawn a lot, it gets really laggy and I don't know why. I want to use this code inside my app to be able to use the pencil, but I can't use it like that, because it get's really annoying when you want to draw something and it takes some time until the line is showing up.
There is the following comment in CGDrawingEngine.swift:
/**
Note: this is not a particularily efficient way to draw a great stroke path
with CoreGraphics. It is just a way to produce an interesting looking result.
For a real world example you would reuse and cache CGPaths and draw longer
paths instead of an aweful lot of tiny ones, etc. You would also respect the
draw rect to cull your draw requests. And you would use bezier paths to
interpolate between the points to get a smooother curve.
*/
It would be very nice if you could try to understand what's exactly happening and why it is very slow after some time and how to change the code according to Apple's comment on the drawing function.
(PS: I should mention that this example app is only running on iOS10 Beta with Swift 3.0)
EDIT: I'm testing this app on an iPad Pro (12.9") with iOS10 Beta 5.

How to achieve paint brush strokes in iOS

I am developing an iOS app that uses a paint brush to draw in a board. I have created a simple paint tool with which user can paint,but what I really need is a paint tool that draws with brush stroke. Is there anyway to achieve the same in native iOS app development?
Here is a sample image of the brush stroke I would like to create:
the fact is you'll have to go to GLPaint
https://developer.apple.com/library/ios/samplecode/GLPaint/Introduction/Intro.html
consider also https://github.com/rbuussyghin/glpaint
and https://stackoverflow.com/a/2045262/294884
this is not easy.
Indeed, it's a huge P.I.T.A. Surprisingly, nobody has a ready-made solution for this in iOS.
For 2019 ...
Surprisingly, as far as I know, there is STILL no ready-made solution for this. Strange thing!
For 2021 ...
Appears there are finally some libraries in Metal, example
https://github.com/Harley-xk/MaLiang

How to zoom a circular region with Cocos2d?

I am working on a Cocos2d project for iPad and iPhone, and now I need to develop something that looks too small for iPhone.
My first approach was to redesign it to make it possible to look bigger, but then I though that a region zoom effect would be great. The bad point is that I don't know how to do it... I really don't know what would be the correct/best approach to do it.
I have already checked out the Cocos2D CCLens3D build in effect, but it doesn't give me the results I want.
I would love to get the same result than when you long-press a textview/textfield on the UIKit:
Thanks in advance for your help!
If your still looking for a solution:
http://rombosblog.wordpress.com/2012/06/03/magnifierglassforcocos2d/
Uses CoreGraphics to render. Although this implementation works (requires some tweaking), I found that it lacked that Gaussian distribution effect I was looking for and was quite expensive if you updated the magnifying effect in a small interval.

Improving Drawing Performance (for Dudel application)

I needed to create a small drawing/paint application, so i turned to Beginning IPad Development for IPhone Developers: Mastering the IPad SDK By Jack Nutting, Dave Wooldridge, David Mark.
It's pretty nice. The architecture is strong. But, the drawing application (Dudel) is not very good in terms of performance. There are two main issues (for me, at the moment):
Most Important: The drawing slows down after a while. Reason: drawRect is being called, every time, for all the paths.
The drawing with Pencil tool isn't smooth. Reason: It's using addLineToPoint: instead of (may be) addQuadCurveToPoint:.
There's no Eraser control. But it's really not an issue, because we can choose white color for the painting go give an illusion of an eraser. But, if there's a better implementation for that, i'm interested to know.
Question:
Is there a solution out there that addresses these issues, and provide a simple but efficient drawing application?
Note: I need the Undo/Redo feature as well.
Let me try to answer your question one by one.
The drawing with Pencil tool isn't smooth. Reason: It's using addLineToPoint: instead of (may be) addQuadCurveToPoint:.
What you say is true.IOS device looks for touches in a defined interval. If you move your hand fast, it is very likely that you may end up losing few touch points . Hence connecting points using lines results in ugly spikes.
We can smooth the curve by curve fitting algorithms.However Some tweaks in the drawing can result in measurable improvement in quality. Here is an example for it.
Eraser control
If you know the background color you can use that as brush color to give an eraser feeling. if you do not know the background you can use
CGContextSetBlendMode(context, kCGBlendModeClear);
Undo/Redo
you can use NSUndoManager .

Resources