我有一個問題,我需要讓我從外部文件「不」相互重疊的話。我有超過50個單詞,它們在運行時具有隨機文本大小和位置,但它們重疊。如何確保字符串不會在java處理中彼此重疊?
如何讓他們「不」相互重疊?結果可能看起來像一個詞雲。
,如果你認爲我的代碼,將有助於他們在這裏
String [] words;
int index = 0;
void setup()
{
size (500,500);
background (255);
String [] lines = loadStrings ("alice_just_text.txt");
String entireplay = join(lines, " "); //splits it by line
words = splitTokens (entireplay, ",.?!:-;:()03 "); //splits it by word
for (int i = 0; i < 50; i++) {
float x = random(width);
float y = random(height);
int index = int(random(words.length));
textSize (random(60)); //random font size
fill (0);
textAlign (CENTER);
text (words[index], x, y, width/2, height/2);
println(words[index]);
index++ ;
}
}
@KenWhite謝謝!我不知道如何編輯一篇文章,因爲我是stockoverflow中的新成員......儘管謝謝你:)我現在將編輯它並刪除我不需要的評論 –
你會發現一個[edit]鏈接權利在問題左下角的標籤下方。 :-) –
@KenWhite哦,我的!找到了!非常感謝! –