Xcode how to make a curve? - core-graphics

Im making an iPhone app, and I'm wondering how to make a curve if i e.g. got 3 points
(3,2)
(4,3)
(5,4)
how can i make a curve?

APIs like CGPathAddCurveToPoint, CGContextAddCurveToPoint, CGContextAddArc, CGPathAddArc, etc. would be a start if you are using CoreGraphics.

Related

Dynamically resize imageview with animation in cocoa mac application in objective c

I am having a cocoa application for mac in objective c.
I am slightly new to mac application.
In my app, I want to implement growing imageview animation like shown below in the images.
As seen from the screenshots, when my window loads, I have some data to feel as it increases its value.
From 0 to the maximum value.
It should show like its rising from 0 to the values that I have specified.
I have seen lots of circular animations but didn't get much idea from that.
please give me suggestions on this.
Please ignore if mistakes as I am new to mac development.
Thanks in advance.
You should create mask and apply it to NSImageView layer object using the only image (one for 100%).
Read following article and don't be afraid it's about iOS-development, CoreAnimation is available in Cocoa too.

iOS - Want to animate sin x graph

Very excited for my first post on SO!
I would like to create an animation like this in xcode
I am not having much luck with what CABasicAnimation has to offer.
Feels like I may need one of those fancy physics engines...(?)
How would one properly begin do this?
Thanks!
I would probably use NSBezierPath to create such an animation. I would create a path which I extended along the sine curve on each iteration, and stroke the path appropriately. If you give us more details about what you're attempting to do, we can give you more details about how to do it.
Exactly what you want.TFAnimation allows you to use customize timingFunction by set a closure to timeFunction of TFBasicAnimation.
The demo in github is exactly a Sin animation.It use a CAAnimationGroup combined linear CABasicAnimation in position x and TFBasicAnimation of Sin timeFunction in position y.

How to move the sprite(vehicles ) on slope image in cocos2d

I m developing one game in cocos2d but i have one doubt, in this game i have one background and above that i want to add one slope image and i want to move the sprite(vehicles) on that slope randomly just like this game i m giving the link of one game, please suggest me how i can implement just like this video, I also want to make the game just like this.
http://www.youtube.com/watch?v=yMJFRd3bBhw
Thanks in advance,
One option is using a path and make the sprites follow that path, define that path for each terrain. Another option is using a physics engine, you can do that using the engine itself (i think).

Floating pictures screensaver on Mac OS X

I'm just learning to use XCode and program in Objective-C (my plan is to write a an app we need for my business since I can't find one that does what I need). It's going well and as an exercise I've been playing with database apps and screensavers.
I'm trying to write a screensaver that all it does is to show 3 or 4 pictures randomly floating on the screen. Similar to the out of the box pictures screensaver that comes with Mac OS X.
I've played with the code in http://cocoadevcentral.com/articles/000088.php and while very informative I still don't know how to add those 3 or 4 pictures and make them move.
Anyone out there can point me to sample code? Or a project that I can use as reference?
Again, this is just self learning.
Thank you!
This will probably be your first port of call.
My approach to this was to create a Quartz Composition using Quartz composer. I found this easier than figuring out how to draw and animate everything by hand.
You can display a quartz composition inside a ScreensaverView by using the QCView class. This setup worked well for me.

draw a square matrix

I want to make a game where I need a square shaped matrix with 6 row and six columns.
How to do that?
Here is an iPhone compatible version of Apple's Geek Game Board sample code:
https://bitbucket.org/snej/geekgameboard/.
The original version can be found here (Mac only):
http://developer.apple.com/library/mac/#samplecode/GeekGameBoard/Introduction/Intro.html
It's using Core Animation and provides reusable classes for your problem.