Helo Ken. Thanks for answer, I meant, I have some title string already, and I wish to be able to animate as if its being written at the moment, also I forgot to mention that this is for iOS.
Once again thanks for the reply. I will still check your code and see how maybe I can apply what I need. Maybe, and for sure I need to get the points of the path to be done first somehow and then animate the creating of the path. i dunno. G. On Thu, Jun 23, 2011 at 12:34 PM, Ken Tozier <kentoz...@comcast.net> wrote: > If you're "writing" with the mouse the following might help. It isn't done, > still needs some sort of check in the drawRect method to know when you've > drawn all the segments and you;ll need to adjust x/y values to the view > you're drawing in, but it will get you started. > > - (void) mouseDown:(NSEvent *) inEvent > { > // allocate a mutable data to store event points and times > dragPoints = [[NSMutableData alloc] init]; > > // save fetch time and location of click and store in dragPoints > NSTimeInterval timestamp = [inEvent timestamp]; > NSPoint clickPoint = [inEvent locationInWindow]; > > [dragPoints appendBytes: ×tamp length: sizeof(NSTimeInterval)]; > [dragPoints appendBytes: &dragPoint length: sizeof(NSPoint)]; > } > > - (void) mouseDragged:(NSEvent *) inEvent > { > NSTimeInterval timestamp = [inEvent timestamp]; > NSPoint dragPoint = [inEvent locationInWindow]; > > // write interval and point to dragPoints mutable data object > [dragPoints appendBytes: ×tamp length: sizeof(NSTimeInterval)]; > [dragPoints appendBytes: &dragPoint length: sizeof(NSPoint)]; > } > > - (void) mouseUp:(NSEvent *) inEvent > { > // save the recording, either in memory or to a file > [dragPoints writeToFile: @"/path/to/some/file.bin"]; > > [dragPoints release]; > } > > > // In your draw method, you could fetch a timestamp/NSPoint pair from the > recording like so > > - (void) drawRect:(NSRect) inRect > { > CGContextRef context = [[NSGraphicsContext > currentContext] graphicsPort]; > > // some instance variable indicating where you are in the recording > int frameOffset = > currentIncrement * (sizeof(NSTimeInterval) + sizeof(NSPoint)); > NSTimeInterval time = > *(NSTimeInterval*)[dragPoints bytes] + frameOffset; > NSPoint point = > *(NSPoint*)[dragPoints bytes] + frameOffset + sizeof(NSTimeInterval); > > // draw line > CGContextAddLineToPoint(context, point.x, point.y); > > // create a new NSTimer with the delay from "time" variable > [NSTimer scheduledTimerWithTimeInterval: time > target: self > selector: @selector(dearRect:) > userInfo: nil > repeats: NO]; > > // increment placeholder > currentIncrement++; > } > > On Jun 23, 2011, at 5:21 AM, Gustavo Adolfo Pizano wrote: > >> Hello all. >> >> Im wondering if animating handwriting is somehow possible to do, I >> have been looking but I find only how to do it in flash. >> >> Can somebody give me some headlights in the right direction so I can >> start digging into? >> >> Thanks a lot. >> >> Gustavo >> _______________________________________________ >> >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >> >> Please do not post admin requests or moderator comments to the list. >> Contact the moderators at cocoa-dev-admins(at)lists.apple.com >> >> Help/Unsubscribe/Update your Subscription: >> http://lists.apple.com/mailman/options/cocoa-dev/kentozier%40comcast.net >> >> This email sent to kentoz...@comcast.net > > _______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > http://lists.apple.com/mailman/options/cocoa-dev/gustavxcodepicora%40gmail.com > > This email sent to gustavxcodepic...@gmail.com > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com