p5js 03-08 コメントと便利な機能

学習日

2026年6月17日

名前

堀内道

自分で作った図形(コードと画像)

✅ 練習問題 3-8-1

Ctrlキーを押しながらスラッシュキーを押すとできる。

✅ 練習問題 3-8-2

let price = 1000;
let taxRate = 0.1;
let tax = price * taxRate;
let totalPrice = price + tax;
print("税込価格は" + totalPrice + "円です");

📷 実行結果

let price = 1000;//税抜きの値段
let taxRate = 0.1;//税率
let tax = price * taxRate;//かかる税金
let totalPrice = price + tax;//合計の値段
print("税込価格は" + totalPrice + "円です");

✅ 練習問題 3-8-3

function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
if (mouseX < 200) {
fill(255, 0, 0);
} else {
fill(0, 0, 255);
}
ellipse(mouseX, mouseY, 50, 50);
}

📷 実行結果

function setup() {
 createCanvas(400, 400);
}

function draw() {
 background(220);
  if (mouseX < 200) {
    fill(255, 0, 0);
  } else {
    fill(0, 0, 255);
  }

  ellipse(mouseX, mouseY, 50, 50);
}

✅ 練習問題 3-8-4

circle(100, 100, 50);
circle(200, 100, 50);
circle(300, 100, 50);

📷 実行結果

rect(100, 100, 50);
rect(200, 100, 50);
rect(300, 100, 50);

✅ 練習問題 3-8-5

circle(100, 100, 50);
rect(200, 100, 50, 50);
ellipse(500, 100, 50, 50);

📷 実行結果

circle(100, 100, 30);
rect(200, 100, 30, 30);
ellipse(300, 100, 30, 30);

まとめ・感想

いつもインデントをするのを忘れてしまうので気を付けたい。

Ctrlキーを押しながらfを押すだけでその文字がある場所がわかる。

Ctrlキーを押しながらhを押すと変更したい文字を簡単に変更することができる。

Ctrlキーがマジで優秀すぎると思った。Ctrlfはプログラミング以外でも使うことなのでしっかりと覚えて日ごろから使っていきたい。

コメントする