So I need to repeat text 40 times, I figured out how to do a line a certain amount of times, but using the same process for text is not working, ive tried messing around with different code but I am stuck.
Any help would be great.
I just need to repeat the word “text” 40 times in the program.
Here is my current code:
void setup() {
size(640, 360);
textFont(createFont("Georgia", 24));
}
void draw() {
background(102);
textAlign(RIGHT);
drawType(width * 0.10);
}
void drawType(float x) {
fill(0);
float y = 35;
int spacing = 50;
int endLine = 640;
while (x <= endLine){
text("text", x, y, 50, 50);
x = x + y + spacing;
}
}
I’m using the language Processing, (processing.org), which is a type of JAVA.
Just thought i would be clear with my comment:
try
There may be built in functions to do this in a better way, but this would be a simple way to solve your problem.
This method though is in-efficient as String operations are costly in Java because they are immutable.
The above example would print the same string 40 times in a single line(depending upon the length of the line).
If the horizontal length of the line is not sufficient, either increase the line size or decrease the spacing or decrease the number of times you are repeating the string.