[GENERATOR]

 

Widmanstätten Pattern Generator

Generative Processing sketch I wrote in an attempt to create my own Widmanstätten patterns. Uses the Geomerative Library by Richard Marxer.

 

// BACK

// Brandon A. Dalmer 2019
// Widmanstätten Pattern Generator

import geomerative.*;

//import processing.svg.*; // save as .svg

 

//////////////changes////////
int density = 200;
int max_thickness = 15;
int wobble = 8;
int numColors = 3;
/////////////////////////////

 

color[] colors = {  // random b/w tones
color((int)random(255)),
color((int)random(255)),
color((int)random(255)),
color((int)random(255)),
color((int)random(255)),
color((int)random(255))};

 

void setup() {
  size(1296, 1728); 
  noLoop();
  noSmooth();
  background(colors[(int)random(numColors)]);
 

//beginRecord(SVG, "widmanstatten-#####.svg"); // save as .svg

 

  RG.init(this);
  RCommand.setSegmentLength(25);
  RCommand.setSegmentator(RCommand.UNIFORMLENGTH);
}

void draw(){
  for(int f = 0; f<density; f++){
    strokeWeight(random(max_thickness));
    stroke(colors[(int)random(numColors)]);

    RShape line = RShape.createLine(random(-100, width+100), random(-100, height+100), random(-100, width+100), random(-100, height+100));
    RPolygon lineOutline = line.toPolygon();
    
    for(int i = 0; i < lineOutline.contours[0].points.length; i++){
      RPoint curPoint = lineOutline.contours[0].points[i];
      curPoint.x += random(-wobble, wobble);
      curPoint.y += random(-wobble, wobble);  
    } 

 

  lineOutline.draw(); 
  }

 

  //endRecord(); // save as .svg
}

void mousePressed() {
  background(colors[(int)random(numColors)]);
  redraw();
}

© 2019 - Brandon A. Dalmer - brandon.dalmer@gmail.com - Canada

  • Black Instagram Icon
  • Black YouTube Icon
  • Black Vimeo Icon