Hey Jungs, es zeigt uns nicht das gewünschte Bild an. Was haben wir falsch gemacht?
danke und einen schönen sonntag noch
String textToDraw = “And through it all she offers me protection a lot of love and affection whether I‘m right or wrong and down the waterfall wherever it may take me I know that life won‘t break me when I come to call she won‘t forsake me I‘m loving angels instead”;
PImage bild;
PFont schrift;
void setup(){
size(1273, 900);
bild = loadImage(“flügel.jpg”);
schrift = loadFont(“Didot-Bold-20.vlw”);
textFont(schrift, 20);
noLoop();
}
void draw(){
background(255);
for (int y = 0; y < bild.height; y += textAscent()) {
for (int x = 0; x < bild.width; x++) {
// get the color at the current pixel
color c = bild.get(x, y);
// if the color is something else than a pure white
if (red(c) != 255 && green(c) != 255 && blue(c) != 255) {
// draw something at this position
fill(c);
text(textToDraw, x, y);
x += textWidth(textToDraw);
}
}
}
}

Antwort:
Hey, versucht mal diesen Code. An der Stele x += textWidth(textToDraw) wird immer die breite des kompletten Textes genommen. Das ist natürlich zu lang und breit. Versucht einmal, Textteile aus dem Text zu nehmen.
String textToDraw = “And through it all she offers me protection a lot of love and affection whether I‘m right or wrong and down the waterfall wherever it may take me I know that life won‘t break me when I come to call she won‘t forsake me I‘m loving angels instead”;
PImage bild;
PFont schrift;
void setup(){
size(1273, 900);
bild = loadImage(“flügel11.jpg”);
schrift = loadFont(“Serif-48.vlw”);
textFont(schrift, 20);
noLoop();
}
void draw(){
background(255);
// image(bild,0,0);
for (int y = 0; y < bild.height; y += textAscent()) {
for (int x = 0; x < bild.width; x++) {
// get the color at the current pixel
color c = bild.get(x, y);
// if the color is something else than a pure white
if (red(c) != 255 && green(c) != 255 && blue(c) != 255) {
// draw something at this position
fill(0);
text(“test”, x, y);
}
x += textWidth(“test”);
}
}
}