Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Duncan C

macrumors 6502a
Original poster
Jan 21, 2008
853
0
Northern Virginia
I just posted a new demo project called RandomBlobs to github.

It creates a couple of different kinds of random, smoothly curved, non self-intersecting shapes.

It starts out creating a UIBezierPath that is an irregular 8-sided polygon.

It then uses a modified version of a "Catmull-Rom" curve generating recipe I got from Erica Sadun's "The Core iOS 6 Developer's Cookbook" to turn the polygon into a smoothly curved shape.

It installs the CGPath from the resulting UIBezierPath into a CAShapeLayer, which draws the path.

Since all the resulting CGPaths have the same number and type of control points, it was trivial to make the program animate the shape changes, so when you click the "Change shape" button in the app, the shape morphs before your eyes.

Download the project from github and give it a look.
 
Must say I love Core Animation too. I really wish more of my work required it.

Personal preference, the blob, deffo!

Thanks for that, it was fun!
 
Must say I love Core Animation too. I really wish more of my work required it.

Personal preference, the blob, deffo!

Thanks for that, it was fun!

They're both blobs. You mean the circle-based blobs? The first version used 8 control points for both circle-based blobs and the square-based blobs. I've since updated it to allow a variable number of control points for the circle-based blobs, up to 40, which makes for a much more... "blobbish" shapes.

There's fodder for several tutorials in that app. Using CAKeyframeAnimation; shifting your view up for the keyboard; using the new UIView keyframe animation, etc.
 
I meant the non-circle based blob :
The more blobby one
That is just visual personal preference though.
Having both is super helpful for learning though.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.