Hello all,
I have started processing this morning even though I have a programming background.
I am trying to do a very simple thing a square in a square
This code is basically doing what I want.
centerx = 250
centery = 250
noStroke();
// draw a (blue) rectangle which center is at centerx centery
w = 50;
h = 50;
tlx = centerx - w/2;
tly = centery - h/2;
fill('blue');
rect(tlx, tly, w, h, 10, 10, 10, 10);
// draw a second rectangle
w *= 0.75;
h *= 0.75;
tlx = centerx - w/2;
tly = centery - h/2;
noFill();
stroke('white');
strokeWeight(3);
rect(tlx, tly, w, h, 8, 8, 8, 8);
but the round corner are not easy to scale so I decided to try an other approach and scale my rect.
I was expecting to see the second square in the middle of the other.
After banging my head on the wall I decided to ask for help … What am I missing here?
What would be the best way to repeat the same ensemble of shapes on a regular grid pattern ?
Thanks
noStroke();
// draw a (blue) rectangle
w = 200;
h = 200;
fill('blue');
rect(0, 0, w, h, 10, 10, 10, 10);
// from now on - no Fill
noFill();
// draw a second smaller rectangle
// so let's assume s in ]0, 1[
s = 0.75;
stroke('white');
strokeWeight(3);
// w - s*s is the x-difference length between both rect
tx = (1-s)*w/2;
ty = (1-s)*h/2;
scale(s);
translate(tx, ty);
rect(0, 0, w, h, 10, 10, 10, 10);