marimonda – Molnar Recode

Assertions:

  • Patterns are applied through two cells, horizontally and diagonally.
  • Most patterns are parallel, but not all of them. Non-parallel patterns are followed by two blocks of curve stitches. This is the only “three-block” pattern.
  • Rows and columns have similar patterns.
  • Approximately 60 x 60 squares.
  • Distance between lines seems to be unique for each set of two cells (horizontally/vertically).
  • The slope between all lines is the same or vertically reflected, except in the few blocks with curve stitching.
  • In some patterns with two filled blocks, the centerline of the pattern is darker.
  • Not all blocks have a pattern.
  • The probability of a block having both a vertical and a horizontal pattern on it is low.
  • There is no block that is completely black.

My code:

import processing.svg.*;

void setup() {
  size(1200, 1200); 
  noLoop(); 
}

void draw() {
  background(255);
  beginRecord(SVG, "molnar.svg");

  stroke(0);
  //noStroke();
  noFill(); 

  int nCells = 60;
  rectMode(CENTER);
  float x1, x2, y1, y2, rwidth, rheight;
  rwidth = (width)/ (float)(nCells+2);
  rheight = rwidth; // Since it is square. 
  for (int row =0; row<nCells; row++) {
    for (int col =0; col<nCells; col = col + 2) { if (random(1.0) > 0.25){
        x1 = rwidth + row*rwidth;
        y1 = rheight + col*rheight;
        x2 = rwidth + x1;
        y2 = 2*rheight + y1;
        fillRect(x1,y1, x2,y2,false);
      }
    }
  }
  for (int row =0; row<nCells; row = row + 2) {
    for (int col =0; col<nCells; col++) { if (random(1.0) > 0.25){
        //fill(0,0,0,50);
        x1 = rwidth + row*rwidth;
        y1 = rheight + col*rheight;
        x2 = 2*rwidth + x1;
        y2 = rheight + y1;
        fillRect(x1,y1, x2,y2, true);
      }
    }
  }
   
  endRecord();
}
void fillRect(float x1, float y1, float x2,float y2, Boolean isHorizontal){
  int lineNum = int(random(2, 6)); 
   if (isHorizontal && random(1.0) < 0.05){
    x2 = x1 + (x2-x1)/2;
    float horDist = x2 - x1;
    for(int i = 1; i < lineNum - 1; i++){
      line(x2 - i*(x2-x1)/(lineNum-1), y1, x2 , y2 - i*(y2-y1)/(lineNum-1)); 
    }
    x1 = x1 + horDist;
    x2 = x2 + horDist;
    for(int i = 1; i < lineNum; i++){
      line(x1, y1 + (y2-y1)*i/(lineNum-1), x1 + (x2-x1)*i/(lineNum-1), y1);
    }
    for(int i = 1; i < lineNum; i++){
      line(x1 + (x2-x1)*i/(lineNum-1), y2, x2, y1 + (y2-y1)*i/(lineNum-1));
      }
    x1 = x1 + horDist;
    x2 = x2 + horDist;
    for(int i = 1; i < lineNum - 1; i++){ line(x1, y1 + i*(y2-y1)/(lineNum-1), x1 + i*(x2-x1)/(lineNum-1), y2); } return; } if (random(1.0) > 0.5){
    if (random(1.0) > 0.5){
    for(int i = 1; i < lineNum; i++){ // line(x1, y1 + i*(y2-y1)/(lineNum-1), x1 + i*(x2-x1)/(lineNum-1), y2); // curvy hatch line(x1, y1 + (y2-y1)*i/(lineNum-1), x1 + (x2-x1)*i/(lineNum-1), y1); } } if (random(1.0) > 0.5){
      for(int i = 1; i < lineNum; i++){ // line(x1, y1 + i*(y2-y1)/(lineNum-1), x1 + i*(x2-x1)/(lineNum-1), y2); // curvy hatch line(x1 + (x2-x1)*i/(lineNum-1), y2, x2, y1 + (y2-y1)*i/(lineNum-1)); } } }else{ if (random(1.0) > 0.5){
    for(int i = 0; i < lineNum -1; i++){ line(x1, y1 + (y2-y1)*i/(lineNum-1), x2 - (x2-x1)*i/(lineNum-1), y2); } } if (random(1.0) > 0.5){
      for(int i = 0 ; i < lineNum - 1; i++){
      line(x1 + (x2-x1)*i/(lineNum-1), y1, x2, y2 - (y2-y1)*i/(lineNum-1));
      }
    }
    
  }
  
}