Open as new workspace
Experimenting with Grids, multicolor by Ryan

Experimenting with Grids, multicolor

View source Pathogen · 45 lines
define ViewBox(0, 0, 8000, 4800);

define default PathLayer('background') ${
  fill: Color('#fafafa');
  stroke-width: 0.2;
}

let field = Grid(320, 200, { xDim: 20, yDim: 8, outOfBounds: 'wrap' }) {|g|
  g.fill {|row, col, center|
    return calc(sin(row * 2.8 / g.rows) + cos(col * 7.7 / g.cols));
  };
};

let colorCount = 240;
let colors = Color.palette(oklch(0.6695 0.2483 330.1),
                           oklch(0.8142 0.1571 72.9),
                           colorCount);
let drawingLayerSet = colors.map {|color, index|
  return PathLayer(`drawing-layer-${index}`) ${
    stroke-width: 0.2;
    stroke: color.darken(0.2).alpha(0.48);
    fill: color.alpha(0.625);
  };
};

let itemLength = 480;
for (drawingLayer in drawingLayerSet) {
  let x = randomRange(200, 6000);
  let y = randomRange(200, 2800);
  let start = Point(x, y);
  let next = start;
  for (k in 1..itemLength) {
    let angle = field.sampleBilinear(start.y, start.x);
    next = start.polarTranslate(angle, 3.6);
    drawingLayer.apply {
      let diameter = calc(k * 1.05);
      if (k > calc(itemLength / 2)) {
        diameter = calc((itemLength - k) * 1.04);
      }
      circle(start.x, start.y, diameter);
    }
    start = next;
  }
}