I have no clue to continue my code_any idea?

edited April 2015 in Questions about Code

Hello,

I have just started to explore the extensive nature of coding. I would like to make one of my ideas real that would be a generative logo. It's a really simple system but still I'm struggling to countinue the coding process since I have no enough knowledge of it. :(

So, here is the code finished so far:

void setup() {
  size(400, 400);
  background(255);
  frameRate(2);

}

void draw() {
  noLoop();

  int[] kord = new int[5];
  kord[0] = 80;
  kord[1] = 140;
  kord[2] = 200;
  kord[3] = 260;
  kord[4] = 320;

  background(255);
  fill(0);
  rectMode(CENTER);
  rect(kord[int(random(5))], kord[int(random(5))], 60, 30);
  rect(kord[int(random(5))], kord[int(random(5))], 60, 30);
  rect(kord[int(random(5))], kord[int(random(5))], 60, 30);
  rect(kord[int(random(5))], kord[int(random(5))], 60, 30);
  rect(kord[int(random(5))], kord[int(random(5))], 60, 30);
  rect(kord[int(random(5))], kord[int(random(5))], 60, 30);
  rect(kord[int(random(5))], kord[int(random(5))], 60, 30);
  rect(kord[int(random(5))], kord[int(random(5))], 60, 30);
  rect(kord[int(random(5))], kord[int(random(5))], 60, 30);
  rect(kord[int(random(5))], kord[int(random(5))], 60, 30);
  rect(kord[int(random(5))], kord[int(random(5))], 60, 30);
  rect(kord[int(random(5))], kord[int(random(5))], 60, 30);
  rect(kord[int(random(5))], kord[int(random(5))], 60, 30);
  rect(kord[int(random(5))], kord[int(random(5))], 60, 30);
  rect(kord[int(random(5))], kord[int(random(5))], 60, 30);
  rect(kord[int(random(5))], kord[int(random(5))], 60, 30);
  rect(kord[int(random(5))], kord[int(random(5))], 60, 30);
  rect(kord[int(random(5))], kord[int(random(5))], 60, 30);
  rect(kord[int(random(5))], kord[int(random(5))], 60, 30);
  rect(kord[int(random(5))], kord[int(random(5))], 60, 30);
  rect(kord[int(random(5))], kord[int(random(5))], 60, 30);
  rect(kord[int(random(5))], kord[int(random(5))], 60, 30);
  rect(kord[int(random(5))], kord[int(random(5))], 60, 30);
  rect(kord[int(random(5))], kord[int(random(5))], 60, 30);
  rect(kord[int(random(5))], kord[int(random(5))], 60, 30);
}


void mousePressed() {
  redraw() ;
}

*Probably it could be much easier and shorter(?). My aim is that when I click on the "logo"only one of the black rectangels disappeares vertically in a row. I don't know what should be done to fix this problem. Besides, I would like the title below to match to the lenght of bottommost black line of the logo. It means that the spacing between the letters changes according to the lenght of the aforementioned line. Could you, please, advise how and where to start to solve this issue?

Your kindly help would be very appretiated!

P.S.: the attached photos illustrate the aforementioned situation and problem_the first one reflects only the frame of the system.

PREZ_04_Page_04 PREZ_04_Page_05 PREZ_04_Page_07

_a desperate beginner of coding!

Answers

  • Answer ✓

    Probably it could be much easier and shorter(?).

    You betcha! Loops for the help... : :ar!

    // forum.processing.org/two/discussion/10176/i-have-no-clue-to-continue-my-code-any-idea
    
    static final int SIZE = 5, QTY = 25, OFFSET = 80, STEP = 60, W = 60, H = 30;
    static final int[] KORDS = new int[SIZE];
    
    static {
      for (int i = 0; i != SIZE; KORDS[i] = STEP*i++ + OFFSET);
    }
    
    void setup() {
      size(400, 400, JAVA2D);
      smooth(4);
      noLoop();
      frameRate(2);
    
      rectMode(CENTER);
      fill(0);
      noStroke();
    }
    
    void mousePressed() {
      redraw();
    }
    
    void keyTyped() {
      redraw();
    }
    
    void draw() {
      background(-1);
    
      for (int i = 0; i++ != QTY
        ; rect(KORDS[(int) random(SIZE)], KORDS[(int) random(SIZE)], W, H));
    }
    
  • Thanks! :) I'm still fighting haha ... but Rome wasn't built in a day :D

Sign In or Register to comment.