ともろーの日記

Initializing . . .

Processing ではじめるプログラミング 4日目(いろいろなプログラムを書いてみる)

  1. Point(点)
  2. f:id:tomorrow63:20160417223933p:plain:w300
    point(50,50);
    

    point(x座標,y座標); と書きます。


  3. Line(線)
  4. f:id:tomorrow63:20160417224612p:plain:w300
    line(0,0,100,50);
    

    line(始点のx座標,始点のy座標,終点のx座標,終点のy座標); と書きます。


  5. Triangle(三角形)
  6. f:id:tomorrow63:20160417225338p:plain:w300
    triangle(10,10,40,20,30,50);
    

    頂点を点A,B,Cとすると triangle(点Aのx座標,点Aのy座標,点Bのx座標,点Bのy座標,点Cのx座標,点Cのy座標); と書きます。


  7. Quad(四角形)
  8. f:id:tomorrow63:20160417225833p:plain:w300
    quad(10,10,20,60,50,70,60,30);
    

    頂点を点A,B,C,Dとすると quad(点Aのx座標,点Aのy座標,点Bのx座標,点Bのy座標,点Cのx座標,点Cのy座標,点Dのx座標,点Dのy座標); と書きます。


  9. Rect(長方形)
  10. f:id:tomorrow63:20160417230320p:plain:w300
    rect(10,20,50,40);
    

    長方形の左上の頂点を基準点とします。 rect(基準点のx座標,基準点のy座標,長方形の幅,長方形の高さ); と書きます。


  11. Ellipse(だえん)
  12. f:id:tomorrow63:20160417230937p:plain:w300
    ellipse(50,50,40,60);
    

    円の中心を基準点とします。 ellipse(基準点のx座標,基準点のy座標,横の直径,縦の直径); と書きます。

これらは座標の値を自由に決めることができます。いろいろな形を作ってみましょう。

プログラムは上から順番に読み込まれます。すなわち、上に表示したいものは後に書くといいです。

f:id:tomorrow63:20160417231335p:plain

ellipse(50,50,50,60);
point(40,40);
point(60,40);
line(40,60,60,60);

このようなこともできます。