How to use transformations to create a stripe pattern

Hello I am new to processing and one of my assigments is to create patterns within processing using push and pop matrix. I decided to try and create somthing simialr to this

however i’ve been stuck on figuering out how to use transformations to achieve this pattern. I’ve been playing around with for loops and using the vector line() to try and at least get something similare to the stripe pattern which has worked but the main requierment of the assigment is to use transformations to create the pattern.

Hi! Welcome to the forum! Do you want to share your code so we can suggest something?

here is my code its not much. when you run it, it just shows a row of lines

void setup() {
  size(640,640);
  background ( 137, 207, 240);
}

void draw() {

  stroke(255);
  for(int lineX = 1; lineX <= 640; lineX += 10){
    line(lineX, 0, lineX, height);
  }
}

don’t worry, it’s good that at least you have something to start with!

so right now you draw line at lineX. For the assignment, I guess you have to use translate. First thing is to break line(lineX, 0, lineX, height); into two operations using translate and line :slight_smile:

2 Likes

http://learningprocessing.com

// Exercise 6-6: Rewrite Example 6-9 using a for loop.

void setup() {
  size(255, 255);
}
void draw() {
  background(0);
  // A for loop!
  for (int i = 0; i < width; i+= 10) {
    noStroke();
    float distance = abs(mouseX - i); // The distance between the current rectangle and the mouse is equal to the absolute value of the difference between i and mouseX.
    fill(distance); // That distance is used to fill the color of a rectangle at horizontal location i.
    rect(i, 0, 10, height);
  }
}

now as @micuat said you need translate

1 Like

Thanks i think i kinda understand what i have to do : )

1 Like