我正在嘗試在處理中獲得橢圓的螺旋形。我無法理解如何遍歷單詞中的每個點(使用幾何庫提取)以確保每個點都是每個螺旋的開始。目前它或者形成一個螺旋或者translate()
函數(註釋掉)將橢圓遍及整個地方。從點列表中製作一個螺旋
這裏是我的代碼:
import geomerative.*;
//Leaf myLeaf;
float pointCount;
int freq = 1;
float phi = 1;
RFont font;
RShape grp;
RPoint[] points;
String TextTyped = "wipe";
float r = 0;
float theta = 0;
float angle;
float y;
void setup(){
RG.init(this);
font = new RFont("/Users/sebastianzeki/rp_samples/samples/external_library/java_processing/geomerative/data/FreeSans.ttf",200,RFont.LEFT);
size(800,600);
smooth();
background(255);
}
void draw(){
stroke(0);
strokeWeight(2);
noFill();
RGroup textGrouped;
// When extracting the dots, the entered characters do not have to be processed individually.
// The entire text textTyped can be grouped. Then the getPoints() function provides a list
// of dots comprising the outline lines of the entire text
textGrouped = font.toGroup (TextTyped);
textGrouped = textGrouped.toPolygonGroup();
RPoint[] thePoints = textGrouped.getPoints();
stroke (0, 255, 255, 64);
strokeWeight (1);
//This draws the word outline in blue circles which is fine
for (int i = 0; i < thePoints.length; i++) {
ellipse(thePoints[i].x+100, thePoints[i].y+200, 3, 3);
}
//This is the part that I am trying to get to draw spirals from the word points
for (int i = 0; i < thePoints.length; i++) {
translate(thePoints[i].x,thePoints[i].y);
float x = r * cos(theta);
float y = r * sin(theta);
r +=0.1;
theta += 0.01;
ellipse(x, y, 5, 50);
}
}
今後請儘量提供[MCVE],而不是發佈您的整個草圖。硬編碼的一組點可以很好地顯示你的問題,所以不需要發佈所有額外的代碼。這讓我們很難幫助你。 –