Input needed: functions wishlist

Map walking functions.

This lets you walk through the pixel map outside of a render call and could be used to make a pattern 2D/3D aware yet still only export render or pre-process pixels.

  • mapPixels(fn) - walk through the pixels with pixel map coordinates. fn is invoked with 4 arguments: (index, x, y, z) though you can specify fewer. If no pixel map is installed, x will be the same as index/pixelCount, and y and z will be 0. For 2D pixel maps z would be 0.

And/or perhaps:

  • map2DPixels(fn) - walk through the 2D pixel map, if installed (if not, nothing happens). fn is invoked with 3 arguments: (index, x, y).
  • map3DPixels(fn) - walk through the 3D pixel map, if installed (if not, nothing happens). fn is invoked with 4 arguments: (index, x, y, z).

Oh look a poll!

Vote for an API to walk a pixel map outside of render
  • mapPixels(fn) one size fits all
  • map2DPixels(fn) / map3DPixels(fn) an API for every dimension
  • :woman_shrugging:t2:why not both?

0 voters

Pixel Map Coordinate Transformation

The idea here is that the pixel map can be transformed before coordinates are given to render2D/3D and mapPixels and perhaps render/render1D x parameter as well. This will help reduce common coordinate transformations that have to be done in pattern code. A set of transformations can be applied globally on the mapper tab. Perhaps per pattern as well as a setting like controls. This allows you to center the coordinate space around 0, apply a non-square aspect ratio, or scale + translate the map to a segment of the overall world coordinate space for multiple PB rendering cooperation without code.

In addition to global transforms, the pattern has access to an API to apply pattern specific transformations as well. It would make things like GlowFlow much simpler and faster, and allow for cool effects with less code. Rotate, zoom, pan around with ease and speed in 2D or 3D. Scale and offset even 1D would be cool.

  • resetTransform() - resets coordinate transformations back to default or global transformation state. I might also need an applyTransforms() due to the non-commutative nature of matrix composition, but I’ll cross that bridge when I get to it :slight_smile:

For API, it’s tempting to have functions for 2D and for 3D, though for a hybrid compatible pattern working with the individual axes might reduce overall code footprint.

  • translateX(dx) - move on the X axis. Works on 1D and up
  • translateY(dy) - move on the Y axis. Works on 2D and up
  • translateZ(dz) - move on the Z axis. 3D only
  • scaleX(x) - scale the X axis. Works on 1D and up
  • scaleY(y) - scale the Y axis. Works on 2D and up
  • scaleZ(z) - scale the Z axis. 3D only

This kind of gets unintuitive with rotation. There isn’t much point to rotate 1D right? Rotation in 2D transforms both the X and Y (on the Z axis). Would it be weird to see rotateZ() in 2D patterns so perhaps rotate() would be more natural for 2D.

  • rotate(a) aka rotateZ(a) - rotate along the Z axis. Works on 2D and up
  • rotateX(a) - rotate along the X axis. Works in 3D only
  • rotateY(a) - rotate along the Y axis. Works in 3D only
2 Likes