Changing the corresponding lines and pressing Ctrl+T in the Processing editor to auto format the code (handy tip!), I get an error at line 10 saying that there’s a missing curly bracket.
In fact you forgot to close the draw() function block. (in general when you open a bracket, you need to close it)
This is the corrected code :
void setup() {
size(900, 900);
background(255);
}
void draw() {
for (int x = 0; x < height; x = x+90) {
for (int y = 0; y < width; y = y+90) {
shapeX(x, y, 90, 90, random(255));
}
}
}
void shapeX(float x, float y, float z, float a, float c) {
beginShape();
noStroke();
fill(c);
ellipse(x, y, z+40, a+40);
translate(-58, -58);
noStroke();
fill(c);
rect(x, y, z+25, a+25);
endShape(CLOSE);
}
I don’t think that it’s the result that you want but this is a starting point
Thanks and you are right, this is not the result i am looking for XD.
if you can and if you want.
please help me with this code.
what I want to do is to fill the sketch area with shapeX(with i made within the code) in checker box manner
I suppose that you don’t want to animate your sketch based on your description so you can use noLoop() at the end of the draw function to break the loop. We want to only draw once.
Also you are misleading with the usage of beginShape() / endShape(), they are used when you want to draw a shape using custom points (not a rectangle or an ellipse since those shapes already have their own pre defined functions)
Using translate() will move the whole coordinate system, in this case you rather want to display your rect with an offset of -58.
When using fill() or noStroke(), it’s like a state machine. Unless you call again fill() with another color, it’s going to stay the same. So you can call them once before drawing your shapes
When your pattern is working properly, you can see that the last column and row are not drawn. Can you find what to change in order to display the whole pattern correctly?
Also try to put spaces in your code as it increases readability
Try to change your code to make it work and then I can post the full solution!