クラス
-
クラス-応用11-回答
Thursday, October 29, 2026 in クラス-応用11
Categories:
問題 クラス-応用11 の回答ページです. 回答例 Button btnRed, btnGreen, btnBlue; color bg; // 現在の背景色 void setup() { size(500, 300); noStroke(); bg = color(240); // Button(左上のx, 左上のy, 幅, 高さ, 色) btnRed = new Button( 50, 200, 120, 60, color(230, 60, 60)); btnGreen = new …
-
クラス-基礎8-回答
Thursday, October 29, 2026 in クラス-基礎8
Categories:
問題 クラス-基礎8 の回答ページです. 回答例 Circle base, body, head; // Circle型の変数を3つ用意する void setup() { size(400, 400); noStroke(); // 下の雪玉 base = new Circle(); base.x = 200; base.y = 290; base.d = 160; // 真ん中の雪玉 body = new Circle(); body.x = 200; body.y = 170; body.d …
-
クラス-基礎11-回答
Thursday, October 29, 2026 in クラス-基礎11
Categories:
問題 クラス-基礎11 の回答ページです. 回答例 Tree tree1, tree2, tree3; // Tree型の変数を3つ用意する void setup() { size(400, 400); noStroke(); // 奥の木(左) tree1 = new Tree(); tree1.x = 110; tree1.y = 300; // 奥の木(右) tree2 = new Tree(); tree2.x = 290; tree2.y = 300; // 手前の木 tree3 = …
-
回答
Friday, October 23, 2026 in クラス-応用5
Categories:
問題 クラス-応用5 の回答ページです. 回答例 int n = 100; // 円の数 PVector[] location = new PVector[n]; // 位置のベクトルの配列 PVector[] velocity = new PVector[n]; // 速度のベクトルの配列 color[] col = new color[n]; // 塗りの色の配列 float[] diameter = new float[n]; // 円の大きさ(直径)の配列 void setup() { …
-
回答
Friday, October 23, 2026 in クラス-応用4
Categories:
問題 PVector-応用1 の回答ページです. 回答例 int n = 100; // 円の数 PVector[] positions = new PVector[n]; // 各円の位置 PVector[] velocities = new PVector[n]; // 各円の速度 float[] d = new float[n]; // 各円の直径 void setup() { size(500, 500); noStroke(); for (int i = 0; i < n; …
-
回答
Friday, October 23, 2026 in クラス-基礎6
Categories:
問題 PVector-基礎1 の回答ページです. 回答例 1. PVector を使わない場合 float posX, posY, spX, spY; // 円の位置,速度 int d; // 円の直径 void setup() { size(500, 500); noStroke(); // 円の直径をランダムに設定(5~30ピクセル) d = int(random(5, 31)); // 円全体がキャンバス内に収まる範囲で,初期位置をランダムに設定 posX = random(d / …
-
回答
Friday, October 23, 2026 in クラス-発展1
Categories:
問題 PVector-発展1 の回答ページです. 回答例 PVector position; // ボールの位置 PVector velocity; // ボールの速度 PVector gravity; // 重力加速度 float d = 40; // ボールの直径 void setup() { size(500, 500); noStroke(); position = new PVector(100, 50); velocity = new PVector(2, 0); gravity = …
-
回答
Wednesday, October 21, 2026 in クラス-応用3
Categories:
問題 クラス-応用3 の回答ページです. 回答例 PImage img; void setup() { size(500, 500); img = loadImage("flower.png"); img.resize(500, 500); // 画面サイズと合わせる image(img, 0, 0); img.loadPixels(); noStroke(); for(int y=0; y<height; y+=20){ for(int x=0; x<width; …
-
回答
Wednesday, October 21, 2026 in クラス-応用2
Categories:
問題 クラス-応用2 の回答ページです. 回答例 PImage img; void setup() { size(500, 500); img = loadImage("flower.png"); img.resize(500, 500); // 画面サイズと合わせる image(img, 0, 0); img.loadPixels(); noStroke(); for(int y=0; y<height; y+=20){ for(int x=0; x<width; …