https://www.plethora-project.com/education/2017/5/31/processing-java-programming
関数(Function)・リファレンス一覧は https://processing.org/reference/ で参照できる。
variable 変数
value 値
function 関数
fill 塗りつぶしの色
stroke 線の色
ellipse 楕円、円
line 線
rect 四角形
triangle 三角形
point 点
int 整数
float 浮動小数点数型
radius 半径
以下ごちゃ混ぜサンプル。※processing.jsを使って書いてます。
// intro, value, variable, functions, for loops, conditional
// まとめて基本。
int x = 5;
int y = 1;
float z = 3.14;
void setup() {
size(600, 400);
//background(0);
}
void draw() {
background(255);
for (int i = 0; i < 20; i++) {
for (int e = 0; e < 20; e++) {
fill(0);
ellipse(i * 20, e * 20, 10, 10);
}
}
for (int a = 0; a < 20; a++) {
if (a < 10) {
fill(255, 0, 0);
} else if (a >= 10 && a < 15) {
fill(0, 0, 255);
} else {
fill(0);
}
ellipse(a * 20, 100, 15, 15);
}
x = x + y;
rect(x, 200, 50, 50);
drawRect();
drawEllipse(400, 300, 100);
drawEllipse(100, 200, 0);
drawEllipse(480, 100, 255);
line(mouseX, mouseY, width/2, height/2);
noFill();
ellipse(width/2, height/2, 20, 20);
}
void drawRect() {
rect(x, 300, 50, 50);
}
void drawEllipse(float x, float y, float c) {
fill(c, 0, 0);
ellipse(x, y, 75, 75);
}
