Open as new workspace
Experiments in random variable offsets by Ryan

Experiments in random variable offsets

View source Pathogen · 64 lines
define ViewBox(0, 0, 880, 200);
define default PathLayer('base') ${ fill: #fff; };
rect(0, 0, 880, 200);

let mainPLFillColor = oklch(0.9792 0.1035 107.6 / 0.1);
let shadowColor = oklch(0.6573 0.2590 356.8 / 0.32);
let baseMainStyles = ${
  fill: mainPLFillColor;
  stroke: mainPLFillColor.darken(64%).alpha(50%);
  stroke-width: 0.1;
  filter: drop-shadow(4px 4px 4px shadowColor);
};
let mainPathLayer = PathLayer('main-path-layer') << baseMainStyles;
let glyphLayerStyles = ${
  fill: oklch(0.3397 0.0641 77.6 / 0.84);
  stroke: #667a;
  stroke-width: 0.1;
};

let fontFamily = 'Noto Sans';
@font fontFamily;
let glyphFontColor = oklch(0.3302 0.0678 109.6);
let fontStyles = ${
  fill: glyphFontColor.alpha(40%);
  font-family: fontFamily;
  font-size: 32;
  font-weight: 400;
  stroke: glyphFontColor.alpha(92%);
  stroke-width: 0.25;
};

let layerCounter = 1;
let glyphs = PathBlock.fromGlyph('pathogen.studio', fontStyles);
// let glyphs = PathBlock.fromGlyph('Joaquin.Kuykendall', fontStyles);
for ([glyph, gIndex] in glyphs) {
  for ([contour, cIndex] in glyph.contours.map() {|con|
    return con.fillet(1.6);
  }) {
    let leftOffset = calc(126.5 + gIndex * 48);

    for (offsetBase in 1..20) {
      let offsetBase = calc(offsetBase * 1.5 + 5);
      let halo = contour.variableOffset() {|vo, cpb|
        let timeMax = 9;
        for (time in 1..timeMax) {
          let offset = randomRange(calc(offsetBase - 2), calc(offsetBase + 2));
          vo.stop(calc(time / timeMax), offset, CurveContinuity.G2);
        }
      };
      let pl = PathLayer(`pl-${layerCounter}`) << baseMainStyles;
      layerCounter = layerCounter + 1;
      pl.apply {
        halo.drawTo(leftOffset, 101);
        z
      }
    }

    let glyphLayer = PathLayer(`gl-${layerCounter}`) << glyphLayerStyles;
    glyphLayer.apply {
      contour.fillet(1.6).drawTo(leftOffset, 102);
    }
  }
}