GridFlow 0.7.3 - index of this page:

       

Objects for making grids and breaking them down

Objects for Computing

Objects for Coordinate Transforms

Objects for Reporting

Objects for Color Conversion

Objects for Miscellaneous Picture Processing

Special Objects

jMax emulation



Objects for making grids and breaking them down

  class @import

[@import {240 320 3}]





This object allows you to import non-grid jMax data, such as integers and lists of integers. This object also reframes/resyncs integers and grids so that multiple grids may be joined together, or single grids may be split.


method init (list(+integer)|symbol(per_message) dims, numbertype numbertype)

inlet 0 method int () begins a new grid if there is no current grid. puts that integer in the current grid. ends the grid if it is full. the constructed grid is not stored: it is streamed. the stream is buffered, so the output is in packets of about a thousand numbers.

inlet 0 method list () just like a sequence of ints sent one after another, except in a single message.

inlet 0 method symbol () considered as a list of ascii characters.

inlet 0 method reset () aborts the current grid if there is one.

inlet 0 method grid (grid(dims...) grid) this is the equivalent of filtering this grid through an @export object and sending the resulting integers to this @import object, except that it's over 10 times faster.

inlet 1 method grid (grid(rank) grid) this grid is a dimension list that replaces the one specified in the constructor.

inlet 1 method per_message () sets the per-message option described above.

outlet 0 method grid (grid grid) the grid produced from incoming integers and/or grids.

  class @export

[@export]





this object is the opposite of @import.


method init () this object is not configurable because there isn't anything that could possibly be configured here.

inlet 0 method grid (grid(dims...) grid) transforms this grid into a sequence of integer messages.

outlet 0 method int () elements of the incoming grid.

  class @export_list

[@export_list]





this object is another opposite of @import, which puts all of its values in a jMax list.


method init () this object is not configurable because there isn't anything that could possibly be configured here.

inlet 0 method grid (grid(dims...) grid) transforms this grid into a single message containing a list of integers.

outlet 0 method list () elements of the incoming grid.

  class @export_symbol







this object is another opposite of @import, which puts all of its values in a jMax list.


method init () this object is not configurable because there isn't anything that could possibly be configured here.

inlet 0 method grid (grid(dims...) grid) transforms this grid into a single message containing a list of integers.

outlet 0 method list () elements of the incoming grid.

  class @two

[@two]





holds two values, defaulting to (0,0). each time one is changed (by sending an integer in that inlet), a Dim(2) grid of those values is sent through the outlet.


method init () no arguments.

inlet 0 method int ()

inlet 0 method bang () resend the grid without change

inlet 1 method int ()

outlet 0 method grid (grid(2) grid)

  class @three

[@three]





holds three values, defaulting to (0,0,0). each time one is changed (by sending an integer in that inlet), a Dim(3) grid of those values is sent through the outlet.


method init () no arguments.

inlet 0 method int ()

inlet 0 method bang () resend the grid without change

inlet 1 method int ()

inlet 2 method int ()

outlet 0 method grid (grid(3) grid)

  class @four

[@four]





holds four values, defaulting to (0,0,0,0). each time one is changed (by sending an integer in that inlet), a Dim(4) grid of those values is sent through the outlet.


method init () no arguments.

inlet 0 method int ()

inlet 0 method bang () resend the grid without change

inlet 1 method int ()

inlet 2 method int ()

inlet 3 method int ()

outlet 0 method grid (grid(4) grid)

  class @for

[@for 0 320 1]





when given scalar bounds, works like a regular [for] object plugged to a [@import] tuned for a Dim(size) where size is the number of values produced by a bang to that [for].

when given vector bounds, will work like any number of [for] objects producing all possible combinations of their values in the proper order. This replaces the old [@identity_transform] object.


method init (integer from, integer to, integer step)

inlet 0 method grid (grid(index) grid) replaces the "from" value and produces output.

inlet 1 method grid (grid(index) grid) replaces the "to" value.

inlet 2 method grid (grid(index_steps) grid) replaces the "step" value.

outlet 0 method grid (grid(size) grid) where size is floor((to-from+1)/step) [for scalar bounds]

outlet 0 method grid (grid(*size,dimension) grid) where *size is floor((to-from+1)/step) [for vector bounds]

 

Objects for Computing

  class @

[@ +]





This object outputs a grid by computing "in parallel" a same operation on each left-hand element with its corresponding right-hand element. This is a massively parallel version of jMax's builtin arithmetic operators. In case you wonder, it's only parallel in the sense that all those computations are independent; there's no guarantee about how many of them will actually be computed at once.


method init (symbol operator, integer|grid value) the operator is one picked in the table of the 30 two-input operators. the value (optional, zero by default) becomes the initial value of the right inlet. it may be a grid.

inlet 0 method grid (grid(dims...) grid) on each element of this grid, perform the operation together with the corresponding element of inlet 1. in the table of operators (at the top of this document) elements of inlet 0 are called "A" and elements of inlet 1 are called "B". the resulting grid is the same size as the one in inlet 0.

inlet 1 method grid (grid(dims...) grid) any grid, preferably shaped like the one that will be put in the left inlet, or like a subpart of it (the contents will be redim'ed on the fly to fit the grid of inlet-0, but the stored grid will not be modified itself)

inlet 1 method int () stores a single int in the right inlet; the same int will be applied in all computations; this is like sending a Dim(1) or Dim() grid with that number in it.

outlet 0 method grid (grid grid)

  class @!

[@!]





This object computes a grid by computing "in parallel" a same operation on each element of the grid.


method init (symbol operator) the operator is one picked in the table of the 3 one-input operators.

inlet 0 method grid (grid grid)

outlet 0 method grid (grid grid)

  class @complex_sq







this object computes the square of complex numbers. If seeing imaginary as Y and real as X, then this operation squares the distance of a point from origin and doubles the angle between it and the +X half-axis clockwise. (fun, eh?)

used on an indexmap, this makes each thing appear twice, spanning half of the original angle.


inlet 0 method grid (grid(dims... {imaginary real}) grid)

outlet 0 method grid (grid(dims... {imaginary real}) grid)

  class @fold

[@fold +]





  • 1 : [@fold +] computes totals
  • 2 : [@fold inv+] is an alternated sum (+/-)
  • 3 : [@fold * 1] can compute the size of a grid using its dimension list
  • 4 : [@fold & 1] can mean "for all"
  • 5 : [@fold | 0] can mean "there exists (at least one)"
  • 6 : [@fold ^ 0] can mean "there exists an odd number of..."
  • 7 : [@fold ^ 1] can mean "there exists an even number of...".


method init (symbol operator, integer base, grid right_hand) the base value is optional and defaults to 0. the operator is one from the table of two-input operators.

inlet 0 method grid (grid(dims..., last) grid) replaces every Dim(last) subgrid by the result of a cascade on that subgrid. Doing that with base value 0 and operation + on grid "2 3 5 7" will compute ((((0+2)+3)+5)+7) find the total "17". produces a Dim(dims) grid.

inlet 1 method int () changes the base value to use.

  class @scan







[@scan +] computes subtotals; this can be used, for example, to convert a regular probability distribution into a cumulative one.


method init (symbol operator, integer base) the base value is optional and defaults to 0. the operator is one from the table of two-input operators.

inlet 0 method grid (grid(dims..., last) grid) replaces every Dim(last) subgrid by all the results of cascading the operator on that subgrid, producing a Dim(dims,last) grid. For example, with base value 0 and operation + on grid "2 3 5 7" will compute 0+2=2, 2+3=5, 5+5=10, 10+7=17, and give the subtotals "2 5 10 17".

inlet 1 method int () changes the base value to use.

  class @outer

[@outer +]






method init (symbol operator, grid value) the operator must be picked from the table of two-input operators. the grid is optional and corresponds to inlet 1.

inlet 0 method grid (grid(anyA...) grid)
produces a grid of size Dim(anyA..., anyB...), where numbers are the results of the operation on every element of A and every element of B. the resulting array can be very big. Don't try this on two pictures (the result will have 6 dimensions)
inlet 1 method grid (grid(anyB...) grid)
stores the specified grid, to be used when inlet 0 is activated.

When given a grid of Dim(3) and a grid of Dim(5) [@outer] will produce a grid of Dim(3,5) with the selected two-input operation applied on each of the possible pairs combinations between numbers from the left grid and the ones from the right. for example : (10,20,30) [@outer +] (1,2,3) will give : ((11,12,13),(21,22,23),(31,32,33))


  class @inner,@inner2

[@inner * + 0]





think of this one as a special combination of [@outer], [@] and [@fold]. this is one of the most complex operations. It is very useful for performing linear transforms like rotations, scalings, shearings, and some kinds of color remappings. A linear transform is done by something called matrix multiplication, which happens to be [@inner * + 0]. @inner also does dot product and other funny operations.

@inner2 is a variant on @inner; used to be called @inner (GF-0.4.1 and before); the right-hand "matrix" is transposed upon reception (the last dimension is swapped with the rest of the dimensions, so that the last becomes first and the others stay in order)


method init (symbol op_para, symbol op_fold, integer base, grid right_hand) op_para and op_fold are two operators picked from the table of two-input operators. the base value has to be specified (has no default value yet).

inlet 0 method grid (grid(anyA..., lastA) grid) Splits the Dim(anyA...,lastA) left-hand grid into Dim(anyA...) pieces of Dim(lastA) size. Splits the Dim(firstB,anyB...) right-hand grid into Dim(anyB...) pieces of Dim(firstB) size. On every piece pair, does [@] using the specified op_para operation, followed by a [@fold] using the specified op_fold operator and base value. creates a Dim(anyA...,anyB...) grid by assembling all the results together. (note: lastA must be equal to firstB.)

inlet 1 method int () changes the base value to that.

inlet 2 method grid (grid(anyB..., lastB) grid) changes the right-hand side grid to that.

  class @inner2

[@inner2 * + 0]






  class @join








method init (which_dim) Which_dim is the number of the dimension by which the join will occur. For N-dimensional grids, the dimensions are numbered from 0 to N-1. In addition, negative numbers from -N to -1 may be used, to which N will be added.

inlet 0 method grid (grid grid) The left grid and right grid must have the same number of elements in all dimensions except the one specified. The result will have the same number of elements in all dimensions except the one specified, which will be the sum of the two corresponding one.

For example, joining a RGB picture Dim[y,x,3] and a greyscale picture Dim[y,x,1] on dimension 2 (or -1) could make a RGBA picture Dim[y,x,4] in which the greyscale image becomes the opacity channel.



inlet 1 method grid (grid grid)

  class @finished








inlet 0 method grid (grid grid) any grid
a bang is emitted every time a grid transmission ends.
  class @cast








method init (numbertype numbertype)

inlet 0 method grid (grid grid) any grid

outlet 0 method grid (grid grid) a grid of the same shape containing all the same values after type conversion. note that while casting to a smaller type, values that are overflowing will be truncated.

  class @ravel








inlet 0 method grid (grid grid) any grid

outlet 0 method grid (grid grid) like @redim but always produce a 1-D grid with the same total number of elements.

  class @grade








inlet 0 method grid (grid grid) any grid

outlet 0 method grid (grid grid)

splits a Dim[A...,B] grid into Dim[B] vectors, producing new Dim[B] vectors that each contain numbers from 0 to B-1 indicating the ordering of the values. The result is a Dim[A...,B] grid.

for example, connecting a [@grade] to a [@outer ignore {0}] to a [@store] object, storing a single vector into [@store], and sending the same vector to [@grade], will sort the values of the vector. however for higher-dimensional grids, what should go between [@store] and [@grade] to achieve the same result would be more complex.

you may achieve different kinds of sorting by applying various filters before [@grade]. the possibilities are unlimited.

if you plug [@grade] directly into another [@grade], you will get the inverse arrangement, which allows to take the sorted values and make them unsorted in the original way. note that this is really not the same as just listing the values backwards.



  class perspective








method init (integer depth)

inlet 0 method grid (grid grid) any grid

outlet 0 method grid (grid grid)

transforms a Dim[A...,B] grid into a Dim[A...,B-1] grid. There is a projection plane perpendicular to the last axis and whose position is given by the "depth" parameter. Each vector's length is adjusted so that it lies onto that plane. Then the last dimension of each vector is dropped.

useful for converting from 3-D geometry to 2-D geometry. Also useful for converting homogeneous 3-D into regular 3-D, as homogeneous 3-D is really just regular 4-D...(!)



 

Objects for Coordinate Transforms

  class @redim

[@redim {2}]






method init (list(+integer) dims) a list specifying a grid shape that the numbers will fit into. (same as with @import)

inlet 0 method grid (grid(dims...) grid) the elements of this grid are serialized. if the resulting grid must be larger, the sequence is repeated as much as necessary. if the resulting grid must be smaller, the sequence is truncated. then the elements are deserialized to form the resulting grid.

inlet 1 method grid (grid(rank) grid) this grid is a dimension list that replaces the one specified in the constructor. (same as with @import)

outlet 0 method grid (grid grid) redimensioned grid potentially containing repeating data.

example: with a 240 320 RGB image, @redim 120 640 3 will visually separate the even lines (left) from the odd lines (right). contrary to this, @redim 640 120 3 will split every line and put its left half on a even line and the right half on the following odd line. @redim 480 320 3 will repeat the input image twice in the output image. @redim 240 50 3 will only keep the 50 top lines.


  class @store

[@store]





A @store object can store exactly one grid, using the right inlet. You fetch it back, or selected subparts thereof, using the left inlet.


method init (grid contents)

inlet 0 method bang () the stored grid is fully sent to the outlet.

inlet 0 method grid (grid(dims..., indices) grid) in this grid, the last dimension refers to subparts of the stored grid. sending a Dim(200,200,2) on a @store that holds a Dim(240,320,3) will cause the @store to handle the incoming grid as a Dim(200,200) of Dim(2)'s, where each Dim(2) represents a position in a Dim(240,320) of Dim(3)'s. therefore the resulting grid will be a Dim(200,200) of Dim(3) which is a Dim(200,200,3). in practice this example would be used for generating a 200*200 RGB picture from a 200*200 XY map and a 240*320 RGB picture. this object can be logically used in the same way for many purposes including color palettes, tables of probabilities, tables of statistics, whole animations, etc.

inlet 1 method grid (grid(dims...) grid)
grids as stored, as indexed, or as assembled from multiple indexings.
  class @scale_to

[@scale_to]






method init (size)

inlet 0 method grid (grid grid) a 3-channel picture to be scaled.

inlet 1 method int () a {height width} pair.

outlet 0 method grid (grid grid) a scaled 3-channel picture.

  class @scale_by

[@scale_by]






method init (grid dim() or dim(2) factor) factor is optional (default is 2). if it's a single value, then that factor is to be used for both rows and columns.

inlet 0 method grid (grid(y x {r g b}) grid) identical to @scale_to with arguments that are exactly twice those of the incoming grid. It is several times faster.

inlet 1 method grid (grid(1 or 2) grid) sets factor

outlet 0 method grid (grid((factor*y) (factor*x) {r g b}) grid)

  class @downscale_by








method init (+integer factor, optional symbol(smoothly) how) factor is optional (default is 2). if it's a single value, then that factor is to be used for both rows and columns.

inlet 0 method grid (grid(y x {r g b}) grid) Scales down picture by specified amount.

inlet 1 method grid (grid(1 or 2) grid) sets factor

outlet 0 method grid (grid((factor/y) (factor/x) {r g b}) grid)

  class @spread

[@spread]





typically you plug a @for into this object, and you plug this object into the left side of a @store. it will scatter pixels around, giving an "unpolished glass" effect.

if you put a picture in it, however, it will add noise. The resulting values may be out of range, so you may need to clip them using min/max.


method init (factor)

inlet 0 method grid (grid grid) a coordinate map.

inlet 1 method int () a spread factor.

outlet 0 method grid (grid grid) a coordinate map.

@spread scatters the pixels in an image. Not all original pixels will appear, and some may get duplicated (triplicated, etc) randomly. Some wrap-around effect will occur close to the edges.

Sending an integer to inlet 1 sets the amount of spreading in maximum number of pixels + 1. even values translate the whole image by half a pixel due to rounding.


  class @rotate







performs rotations on indexmaps and polygons and such.


method init (0...35999 angle)

inlet 0 method grid (grid(anyA 2) grid)

inlet 1 method int () rotation angle; 0...36000

outlet 0 method grid (grid(anyA 2) grid)

  class @remap_image







if you chain indexmap (coordinate) transformations from outlet 1 to inlet 1, then sending an image in inlet 0 will emit its deformation out of outlet 0.


 

Objects for Reporting

  class @dim

[@dim]





Returns list of dimensions as a grid. Given a grid sized like Dim(240,320,4), @dim will return a grid like Dim(3), whose values are 240, 320, 4.


method init () no arguments.

inlet 0 method grid (grid(dims...) grid) ignores any data contained within. sends a grid dim(length of dims) containing dims.

outlet 0 method grid (grid(rank) grid) the list of dimensions of the incoming grid.

  class @type







gives a symbol representing the numeric type of the grid received.


outlet 0 method <numeric type symbol> ()

  class @print








method init ()

inlet 0 method grid (grid(dims...) grid) prints the dimensions of the grid. prints all the grid data if there are 2 dimensions or less.

  class rubyprint







This is only for testing the translation from PD/jMax to Ruby.
method init ()

inlet 0 method <any> () prints the message to the console.

  class printargs







This is only for testing the translation from PD/jMax to Ruby.
method init (any...) prints everything.

 

Objects for Color Conversion

  class @apply_colormap_channelwise







This object is useful for color correction. For each pixel it takes it apart, looks up each part separately in the colormap, and constructs a new pixel from that. You may also color-correct colormaps themselves.

Only works for things that have 3 channels.

Note: if you just need to apply a palette on an indexed-color picture, you don't need this. Just use @store instead.


inlet 0 method grid (grid(rows columns channels) grid) picture

inlet 1 method grid (grid(intensities channels) grid) colormap ("palette")

outlet 0 method grid (grid(rows columns channels) grid) picture

  class @rgb_to_greyscale








inlet 0 method grid (grid(rows columns {red green blue}) grid)

outlet 0 method grid (grid(rows columns {white}) grid)

  class @greyscale_to_rgb








inlet 0 method grid (grid(rows columns {white}) grid)

outlet 0 method grid (grid(rows columns {red green blue}) grid)

 

Objects for Miscellaneous Picture Processing

  class @convolve

[@convolve * + 0]





this is the object for blurring, sharpening, finding edges, embossing, cellular automata, and many other uses.


method init (symbol op_para, symbol op_fold, integer base, grid right_hand)

inlet 0 method grid (grid(rows columns rest...) grid) splits the incoming grid into dim(rest...) parts. for each of those parts at (y,x), a rectangle of such parts, centered around (y,x), is combined with the convolution grid like a [@] of operation op_para. Then each such result is folded like [@fold] of operation op_fold and specified base. the results are assembled into a grid that is sent to the outlet. near the borders of the grid, coordinates wrap around. this means the whole grid has to be received before production of the next grid starts.

inlet 1 method grid (grid(rows2 columns2) grid) this is the convolution grid and it gets stored in the object. if rows2 and/or columns2 are odd numbers, then the centre of convolution is the middle of the convolution grid. if they are even numbers, then the chosen centre will be slightly more to the left and/or to the top, because the actual middle is between cells of the grid.

outlet 0 method grid (grid(rows columns rest...) grid)

  class @contrast

[@contrast]






method init (iwhiteness, contrast)

inlet 0 method grid (grid(rows columns channels) grid) produces a grid like the incoming grid but with different constrast.

@contrast adjusts the intensity in an image. resulting values outside 0-255 are automatically clipped.


inlet 1 method int () this is the secondary contrast (inverse whiteness). it makes the incoming black correspond to a certain fraction between output black and the master contrast value. no effect is 256. default value is 256.

inlet 2 method int () this is the master contrast. it makes the incoming white correspond to a certain fraction between output black and output white. no effect is 256. default value is 256.

outlet  method grid (grid(rows columns channels) grid)

  class @posterize

[@posterize]





@posterize reduces the number of possible intensities in an image; it rounds the color values.The effect is mostly apparent with a low number of levels.


method init (levels)

inlet 0 method grid (grid(rows columns channels) grid) produces a posterized picture from the input picture.

inlet 1 method int () this is the number of possible levels per channel. the levels are equally spaced, with the lowest at 0 and the highest at 255. the minimum number of levels is 2, and the default value is 2.

example: simulate the 216-color "web" palette using 6 levels. simulate a 15-bit display using 32 levels.


  class @solarize







makes medium intensities brightest; formerly brightest colours become darkest; formerly darkest stays darkest. This filter is linear: it's like a 200% contrast except that overflows are mirrored instead of clipped or wrapped.


inlet 0 method grid (grid(rows columns channels) grid)

outlet 0 method grid (grid(rows columns channels) grid)

  class @checkers








inlet 0 method grid (grid(y x {y x}) grid) result from a [@for {0 0} {height width} {1 1}]

outlet 0 method grid (grid(y x {r g b}) grid) checkered pattern of 50%/75% greys in 8x8 squares

  class @layer








inlet 0 method grid (grid(y x {r g b a}) grid) a picture that has an opacity channel. will be used as foreground.

inlet 1 method grid (grid(y x {r g b}) grid) a picture that has NO opacity channel. will be used as background.

outlet 0 method grid (grid(y x {r g b}) grid) a picture that has NO opacity channel. the opacity channel of the foreground is used as a weighting of how much of either picture is seen in the result.

  class @draw_polygon








method init (symbol operator, grid(channels) color, grid(vertices,{y x}) vertices)

inlet 0 method grid (grid(y x channels) grid) picture on which the polygon will be superimposed.

inlet 1 method grid (grid(channels) grid) color of each pixel

inlet 2 method grid (grid(vertices {y x}) grid) vertices of the polygon.

outlet 0 method grid (grid(y x channels) grid) modified picture. note: starting with 0.7.2, drawing a 1-by-1 square really generates a 1-by-1 square, and so on. This is because the right-hand border of a polygon is excluded, whereas it was included before, leading to slightly-wider-than-expected polygons.

 

Special Objects

  class rtmetro







this is like jMax's builtin metro object. metro ensures that there is at least a given delay between bangs. rtmetro ensures that on average there is a given delay between bangs: it will compensate too long delays by shorter delays. of course this won't work if the system cannot keep up with the amount of work.

WARNING: this class does not work as advertised.


method init ()

method init geiger ()

  class pingpong







send a value in inlet 1 first. if successive increasing values are sent in inlet 0, then output values will be successive increasing until they reach the right inlet value and then decrease to zero. the formula is stateless and so same inputs give always same output.
  class @global

[@global]





objects of this class do nothing by themselves and are just an access point to features that don't belong to any object in particular.


method profiler_reset () resets all the time counters.

method profiler_dump () displays the time counters in decreasing order, with the names of the classes those objects are in. this is an experimental feature. like most statistics, it could be vaguely relied upon if only you knew to which extent it is unreliable. more on this in a future section called "profiling".

  class fps








method init (symbol(real|user|system|cpu) clocktype, symbol(detailed) detailed)

method init detailed ()

inlet 0 method bang () Times at which bangs are received are stored until a large enough sample of those is accumulated. Large enough is defined to be whenever the timespan exceeds one second. Then a report is made through the outlet.

inlet 0 method (else) () messages other than bangs are ignored.

outlet 0 method float () non-detailed mode only. this is the messages-per-second rating.

outlet 0 method list(float,6) () detailed mode only. this is: messages-per-second, followed by five values of milliseconds-per-message: minimum, median, maximum, average, standard deviation. (the average happens to be simply 1000 divided by the messages-per-second, but it is convenient to have it anyway)

 

jMax emulation

those classes emulate jMax functionality, for use within PureData and Ruby.

  class fork







Every incoming message is sent to inlet 1 and then sent to inlet 0 as well. Messages remain completely unaltered. Contrast with PureData's "t a a" objects, which have the same purpose but transform bangs into zeros and such.


inlet 0 method <any> ()

  class jmax_udpsend







Sends messages (but not grids nor dspsignals) via UDP (which does not involve a connection, and may lose packets in case of network overload or noise or etc)
method init (host host, integer port)

inlet 0 method <any> ()

  class jmax_udpreceive







Counterpart of jmax_udpsend


method init (integer port)

outlet 0 method <any> ()

outlet 1 method list (protocol_name, sender_port, sender_host, sender_ip_address)

 

GridFlow 0.7.3 Documentation
by Mathieu Bouchard matju@artengine.ca and
Alexandre Castonguay acastonguay@artengine.ca