Pearls on an Elastic String

Swipe across the screen and drag the string of pearls after you.

Source code in

  1. main.m
  2. Class SpringAppDelegate creates the view controller.
  3. Class ViewController creates the big black view and sets the text color of the status bar to white. The view controller contains a CADisplayLink which triggers a call to drawRect: 60 times per second.
  4. Class View creates the five Pearl objects.
  5. Class Pearl draws one circle and one line. Newton’s Second Law is F = ma. The F and a are boldface because they are vectors (CGPoints in our language). The m is italic because it is a scalar (a CGFloat in our language).

Create the project

SpringApDelegate.h imports ViewController.h. ViewController.h imports QuartzCore.h and View.h. View.h imports Pearl.h. Class Pearl has a property.

The same program, in HTML5

Pull down your browser’s View menu (Develop on Safari) and select View Source or Page Source.