Uses the arc() function to generate a pie chart from the data stored in an array.
C4
There are many math functions that are common between both projects. This example also shows that using C4’s map function is almost identical.
Array2D
The effect of the Array 2D example shows how to create a fading grid of points. This example shows you how to create the same effect, even though the C4 version doesn’t actually use arrays.
Demonstrates the syntax for creating a two-dimensional (2D) array. Values in a 2D array are accessed through two index values. 2D arrays are useful for storing images. In this example, each dot is colored in relation to its distance from the center of the image.
C4
Instead of points, we create Circle shapes that are 1pt in diameter.
MouseFunctions
There is no mouse in C4, but there are gesture recognizers. This example shows how you can add a long press gesture recognizer to an object to achieve a similar effect to mousePressed, mouseDragged and mouseReleased.
To achieve a similar effect in C4 requires a lot less code because iOS handles the gesture for you. Simply let the system track touch positions for you.
Storing Input
I really like the aesthetic of how the circles fade away as you move your mouse around the screen. In C4, there are no draw loops and we cannot rely on frame-based updating. However, we can create animations that give us the same effect!
Move the mouse across the screen to change the position of the circles. The positions of the mouse are recorded into an array and played back every frame. Between each frame, the newest value are added to the end of each array and the oldest value is deleted.
C4
Here you’ll see how we create an animation for every circle which, upon completion, removes that circle from the canvas.
Continuous Lines
Drawing a line in Processing is dead-easy. In C4, there’s a bit more complexity because a line is actually a Shape object. The major difference is that in C4 you end up with an object whose properties can be animated, copied, manipulated and styled rather than a bitmap.
Here you’ll see things are slightly more cumbersome because you have to create a shape object. But, it’s not that much more code and you can do a lot with the shape object.
Pattern
Tracking the speed of mouse movement requires you to store the previous position and do a little displacement calculation. In C4, the gesture recognizer handles that kind of thing for you.
A line segment is pushed and pulled by the cursor.
C4
You’ll see here that the Vector class has many functions that are identical to Processing. The difference between these two examples is that we don’t have calls to pushMatrix() and popMatrix(). Instead, we position the circle (which has the line embedded as a subview).
###Want to Contribute?
We’d love to have a bigger list of comparisons to other open-source projects. If you’ve created some comparison examples let us know and we can publish them here with you as the author.