Reputation: 1
I need to create such a picture in Processing:
(https://i.sstatic.net/ihJc4.png)
Unfortunatelly I have got problem beacause my letters overlap and I got something like this:
(https://i.sstatic.net/9o6HI.png)
There is my code:
void setup() {
size(1000, 1000);
background(0, 70, 100);
}
void monogram (int x, int y) {
int los=int(random(0, 255));
stroke(0, 185, 255, los);
strokeWeight(5);
// U //
noFill();
arc(x + 25, y + 60, 20, 20, 0, PI);
line(x + 15, y + 20, x + 15, y + 57);
line(x + 35, y + 20, x + 35, y + 57);
// VV //
noFill();
beginShape();
vertex(x + 35, y + 20);
vertex(x + 55, y + 70);
vertex(x + 75, y + 20);
endShape();
// V //
noFill();
beginShape();
vertex(x + 55, y + 20);
vertex(x + 75, y + 70);
vertex(x + 95, y + 20);
endShape();
}
void draw() {
for (int y = 0; y < height / 50; y++) {
for (int x = 0; x < width / 70; x++) {
int los2 = int(random(0, 4));
pushMatrix();
if (los2 == 1) {
scale(-1, 1);
translate(-width, 0);
} else if (los2 == 2) {
scale(1, -1);
translate(0, -height);
} else if (los2 == 3) {
scale(-1, -1);
translate(-100 , -height);
}
monogram(-15+80 * x, -18+50 * y);
popMatrix();
}
}
noLoop();
}
do you know what am I doing bad?
Upvotes: 0
Views: 48
Reputation: 2713
I would recommend using a standard grid run once in setup() and not using draw(). The following source code creates a 13x12 monogram grid. You can experiment with the width and height settings of each monogram as well as the horizontal and vertical gaps if you want to tweak this demo:
void monogram (int x, int y) {
int los=int(random(0, 255));
stroke(0, 185, 255, los);
strokeWeight(5);
// U //
noFill();
arc(x + 25, y + 60, 20, 20, 0, PI);
line(x + 15, y + 20, x + 15, y + 57);
line(x + 35, y + 20, x + 35, y + 57);
// VV //
noFill();
beginShape();
vertex(x + 35, y + 20);
vertex(x + 55, y + 70);
vertex(x + 75, y + 20);
endShape();
// V //
noFill();
beginShape();
vertex(x + 55, y + 20);
vertex(x + 75, y + 70);
vertex(x + 95, y + 20);
endShape();
}
void monogramGrid(int l, int t, int w, int h, int hg, int vg) {
for (int k = 0; k < 13; k++) {
for (int j = 0; j < 12; j++) {
int x = l + j*(w+vg);
int y = t + k*(h+hg);
monogram(x,y);
}
}
}
void setup() {
size(1000, 800);
background(0, 70, 100);
monogramGrid(0, 0, 80, 60, 0, 0);
}
void draw() {
}
Upvotes: 0