Cellular Automata
This example shows how to use C4 to generate Cellular Automata, and is packed with tricks you should learn:
- Updating interface labels
- Generating binary sets of CA rules (using recursion)
- Working with Pixels
- Generating Arrays of repeated values
- Creating Images based on Pixel data and CA rules
- Setting visible image contents with generated image data
- Working with bytes using
&+
- Exporting images to an app’s documents directory
- Introduces the use of
guard
, a handy statement for keeping things safe
Grabbing Images from iTunes
This example has an export()
function that saves individual images to the app’s documents directory.
To access this directory you need to add the following setting to your app’s main Info.plist
file:
Application supports iTunes file sharing: YES
Here’s what that should look like:
Next, you go into iTunes and do this:
- Select your device
- Choose Apps
- Scroll down the apps page to the File Sharing section
- Select your app
- The generated images should be in the right-hand list view
Example