simple grid triangle

edited December 2016 in How To...

Hey there, I'm very new here - so I please please need your help.

I just want to create a simple grid out of triangles or diamonds on a size of 138 x 224 mm triangle(30, 75, 58, 20, 86, 75);

here's an example how it may look like: http://up.picr.de/27866212vt.jpg http://up.picr.de/27866267dt.jpg

I'm looking forward to any help!!!

Tagged:

Answers

  • Giggle.

    void setup(){
      size(400,400);
    }
    
    void draw(){
      background(255);
      stroke(0);
      rombus();
      translate(75,0);
      submor();
    }
    
    void rombus() {
      line(0, 55, 25, 0);
      line(25, 0, 75, 0);
      line(75, 0, 50, 55);
      line(50, 55, 0, 55);
    }
    
    void submor() {
      line(0, 0, 25, 55);
      line(25, 55, 75, 55);
      line(75, 55, 50, 0);
      line(50, 0, 0, 0);
    }
    
    void bloop(int bleep){
      if( bleep %2 == 0 ){
        rombus();
      } else {
        submor();
      }
    }
    
  • Woot.

    void setup() {
      size(800, 600);
    }
    
    void draw() {
      background(255);
      stroke(0);
      for ( int i=0; i<10; i++) {
        for ( int j=0; j<10; j++) {
          pushMatrix();
          translate(75*i, 55*j);
          bloop(i+j);
          popMatrix();
        }
      }
    }
    
    void rombus() {
      line(0, 55, 25, 0);
      line(25, 0, 75, 0);
      line(75, 0, 50, 55);
      line(50, 55, 0, 55);
    }
    
    void submor() {
      line(0, 0, 25, 55);
      line(25, 55, 75, 55);
      line(75, 55, 50, 0);
      line(50, 0, 0, 0);
    }
    
    void bloop(int bleep) {
      if ( bleep %2 == 0 ) {
        rombus();
      } else {
        submor();
      }
    }
    
  • Oh wow, this was so fast! Thank you so so much, TfGuy44! You made my day (night)!!!

  • GAH!

    void setup() {
      size(800, 600);
      smooth();
      strokeWeight(3);
    }
    
    void draw() {
      background(0,0,random(64,196));
      stroke(0);
      translate(width/2,height/2);
      rotate(map(millis()%5000,0,5000,0,TWO_PI));
      translate(-width/2, -height/2);
      float s = .7 + abs(sin(map(millis()%7000,0,7000,0,TWO_PI)));
      scale(s, random(s-.1, s+0.1));
      for ( int i=-20; i<20; i++) {
        for ( int j=-20; j<20; j++) {
          pushMatrix();
          translate(random(74,76)*i, random(54,56)*j);
          stroke(map(millis()%13000,0,13000,0,255));
          bloop(i+j);
          popMatrix();
        }
      }
    }
    
    void rombus() {
      fill(0,random(64,196),0);
      beginShape(QUAD);
        vertex(0,55);
        vertex(25,0);
        vertex(75,0);
        vertex(50,55);
        endShape();
    
      //line(0, 55, 25, 0);
      //line(25, 0, 75, 0);
      //line(75, 0, 50, 55);
      //line(50, 55, 0, 55);
    }
    
    void submor() {
        fill(random(64,196),0,0);
      beginShape(QUAD);
        vertex(0,0);
        vertex(25,55);
        vertex(75,55);
        vertex(50,0);
        endShape();
      //line(0, 0, 25, 55);
      //line(25, 55, 75, 55);
      //line(75, 55, 50, 0);
      //line(50, 0, 0, 0);
    }
    
    void bloop(int bleep) {
      if ( bleep %2 == 0 ) {
        rombus();
      } else {
        submor();
      }
    }
    
  • Nice psychedelic remix.

    @jennyfer, a common approach to this kind of problem is to figure out what a single unit is, draw that unit, then build up the pattern by looping over the units.

    An interesting recent discussion of a related example was how to create a surface out of these kinds of alternating triangles instead:

Sign In or Register to comment.