2016-04-07 6 views
1

処理中に楕円形の渦巻線が単語の外に広がるようにしようとしています。私は、各点が各らせんの始点であることを確認するために、単語の各点を繰り返し処理する方法(ジオメトリライブラリを使用して抽出する)を理解するのに問題があります。現時点では、どちらか一方のスパイラルを形成するか、または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); 
     } 



} 
+1

[MCVE]の代わりにあなたの全体のスケッチを掲示するのを提供してみてください。

このような何かを。ハードコードされたポイントのセットは問題を示すためにうまくいきました。そのため、その余分なコードをすべて投稿する必要はありません。それだけで、私たちがあなたを助けることが難しくなります。 –

答えて

1

は、ループのために、このを見てみましょう:

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); 
} 

ここでは、ポイントのそれぞれをループして、描画していますその時点で単一の楕円。私はあなたがしようとしていることは、その時点でらせんを描くことだと思います。したがって、単一の楕円を描くのではなく、螺旋を作成する2番目のforループを入力する必要があります。将来的には

for (int i = 0; i < thePoints.length; i++) { 

    //move to the point 
    translate(thePoints[i].x,thePoints[i].y); 

    //reset your spiral variables 
    float r = 0; 
    float theta = 0; 

    //draw 100 points in a spiral 
    for (int i = 0; i < 100; i++) { 
      float x = r * cos(theta); 
      float y = r * sin(theta); 
      r += 1; 
      theta += 0.1; 
      ellipse(x, y, 5, 5); 
    } 
} 
+0

Ihmm。空白の画面が表示されます。私はintの代わりに –

+0

私は(float x1 = 0; x1 <500; x1 ++)しようとしていた私は 'スタックを与えた既に宣言されていたとしてインナーループのintを削除する必要があった「絵が、ポイントから楕円の無いスパイラル:( –

+0

あなたが唯一 'r'と'このループ内theta'変数を使用するので、あなたのスケッチの上でそれらを宣言する必要はありません@SebastianZeki。私の例では、動作しますが、 –

関連する問題