High-performance computation requires precise and quite peculiar definitions of numbers and their representation.
Inside most programs, numbers are written down as strings of bits. A bit is either zero or one. Just like the decimal system uses units, tens, hundreds, the binary system uses units, twos, fours, eights, sixteens, and so on, doubling every time.
One notation, called integer allows for only integer values to be written (no fractions). when it is unsigned, no negative values may be written. when it is signed, one bit indicates whether the number is positive or negative. Integer storage is usually fixed-size, so you have bounds on the size of numbers, and if a result is too big it "wraps around", truncating the biggest bits.
Another notation, called floating point (or float) stores numbers using a fixed number of significant digits, and a scale factor that allows for huge numbers and tiny fractions at once. Note that 1/3 has periodic digits, but even 0.1 has periodic digits, in binary coding; so expect some slight roundings; the precision offered should be sufficient for most purposes. Make sure the errors of rounding don't accumulate, though.
This little program of mine prints 1/3 in base 2 (only digits after the period):
In GridFlow, there are six kinds of numbers:
In every grid-accepting inlet, a list may be sent instead; if
it consists only of integers, it will be converted to a
one-dimensional grid. Else it may contain a single "#" sign and
integers on both sides of it, where the ones to the left of it are
fed as arguments to an imaginary
In every grid-accepting inlet, an integer or float may also be sent; it will be converted to a zero-dimensional grid (a scalar).
a grid has an associated number type that defines what are the possible values for its elements (and how much space it takes). the default is int32.
a single-dimensional grid of 3 elements (a triplet) is called dim(3). a three-dimensional grid of 240 rows of 320 columns of triplets is called dim(240,320,3).
There is a sequence in which elements of a Grid are stored and transmitted. Dimension 0 is called "first" and dimension N-1 is called "last". They are called so because if you select a position in the first dimension of a grid, the selected part is of the same shape minus the first dimension; so in dim(240,320,3) if you select row 51 (or whichever valid row number), you get a dim(320,3). if you select a subpart two more times you get to a single number.
At each such level, elements are sent/stored in their numeric order,
and are numbered using natural numbers starting at 0. This ordering usually
does not matter, but sometimes it does. Most notably,
On the other hand, order of dimensions usually does matter; this is what distinguishes rows from columns and channels, for example. Most objects care about the distinction.
A grid with only 1 element in a given dimension is different from one lacking that dimension; it won't have the same meaning. You can use this property to your advantage sometimes.
Zero-dimensional grids exist. They are called dim(). They can only contain a single number.
This section is useful if you want to know what a picture is in terms of a grid.
A picture is a three-dimensional Grid:
Channels for the RGB color model are:
Because Grids are made of 32-bit integers, a three-channel picture uses 96 bpp (bits per pixel), and have to be downscaled to 24 bpp (or 16 bpp) for display. That huge amount of slack is there because when you create your own effects you often have intermediate results that need to be of higher precision than a normal picture. Especially, results of multiplications are big and should not overflow before you divide them back to normal; and similarly, you can have negative values all over, as long as you take care of them before they get to the display.
In the final conversion, high bits are just ignored. This means: black is
0, maximum is 255, and values wrap like with
In the following table, A is the value entered to the left, and B is the value entered to the right.
Angles are in hundredths of degrees. This means a full circle (two pi radians) is 36000. You convert from degrees to our angles by multiplying by 100. You convert from radians to our angles by multiplying by 18000/pi.
Hyperbolic functions (tanh) work with our angles too, so the same conversions apply.
In GridFlow you cannot send two grids in different inlets at the
same time. You have to use
In GridFlow 0.7.1 this is beginning to change.
(more to come)
Starting with version 0.6, GridFlow is Ruby-centric instead of jMax-centric. jMax support has been added back as a Bridge.
Bridges, for the most part, plug into the FObject class, which is the common root of most of GridFlow's classes. Under the current design, the bridge is compiled separately, and is directly loaded by the host software; then the bridge starts Ruby and makes it load the main GridFlow; then the bridge hooks with the main part.