chickadee » macaw » array-for-each

array-for-each proc array ...procedure

Calls proc once for each color in the given array(s). If the arrays are different sizes, iterates over the overlapping area (i.e. the smallest width and smallest height).

The iteration proceeds in row-major order. proc is called with the x coordinate, y coordinate, and the corresponding color from each given array. Modifying the color will modify the array data. The color's parent will be automatically set to the array, so that the array will not be garbage collected while the color is using its memory.

The arrays can be different types. The color types passed to proc depend on the given array types (e.g. if the first array is an hsl-array, the first color argument to proc will be an hsl color). If all the arrays are the same type, or if there is only one array, it is more efficient to use the type-specific procedures such as rgb-array-for-each and hsl-array-for-each.

(array-for-each
  (lambda (x y rgb8_1 hsl_2)
    (rgb8-lerp! rgb8_1 hsl_2 (/ x 100.0)))
  rgb8-array_1 hsl-array_2)