#### Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

# .....

edited May 2017 in General

Sorry to ask but i have a question....i'm a little bit new to processing and doing a project for school but what i need to do is do a pattern function in processing, can anyone help, it would really mean alot

• What kind of pattern? What have you tried? Do you have any resources to share like pics or links?

Kf

• ``````void pattern() {
}
``````

...

This is a function called pattern. It doesn't do anything. Did you want it to do something? What have you tried to get it to do already? Post your current code. If you have none, attempt to write some (or even just the steps you hope to take) (or even a blank sketch that does nothing) and post that.

Also post some idea of what you expect it to do.

• what i kinda want is that you have a random object just repeating itself all over the screen then when you click on the mouse it changes either with size or just changes to a different object

• something like this

Partial demo below.

Kf

``````//Instructions: Move mouse on sketch to change size
//              Click on sketch to change shape

final int stepx=100;
final int stepy=stepx;
final int maxSize=stepx;

final int kSquares=0;
final int kCircles=1;
final int kEllipses=2;

int figureType=kSquares;
int sx, sy;

void setup() {
size(400, 600);
rectMode(CENTER);
ellipseMode(CENTER);  //Default btw
}

void draw() {
background(0);
fill(0, 255, 0);

for (int i=stepx; i<width; i+=stepx) {
for (int j=stepy; j<height; j+=stepx) {
if (figureType==kSquares) {
sx=(int)map(mouseX, 0, width, 0, maxSize);
sy=sx;
rect(i, j, sx, sy);
}
if (figureType==kCircles) {
sx=(int)map(mouseX, 0, width, 0, maxSize);
sy=sx;
ellipse(i, j, sx, sy);
}
if (figureType==kEllipses) {
sx=(int)map(mouseX, 0, width, 0, maxSize);
sy=sx;
ellipse(i, j, sx, sy/2.0);
}
}
}
}

void mouseReleased(){
figureType=(figureType+1)%3;
}
``````
• grids. search for grids.

two nested for loops, rows and columns.

ellipse(), rect()

• thanks a lot