LoginSignup
0
0

More than 1 year has passed since last update.

Processingでシンプルなものを作ってみた(第0001弾)

Last updated at Posted at 2022-12-02

ーーー シンプルな信号を描画してみた ーーー

小さい頃、ピコを使って信号の絵を描いていたことを思い出し、
Processingでやってみた。

工夫したところ
・ウィンドウサイズに応じて対応する
・図形描画に関しては自作関数を作成してその中にコードを書いた

(1) ウィンドウサイズ:640x480[px]
スクリーンショット 2022-12-02 12.35.32.png

(2) ウィンドウサイズ:160x120[px]
スクリーンショット 2022-12-02 12.35.46.png

image.pde
int sizeH = 480;
int sizeW = sizeH * 4/3;

void settings()
{
  size(sizeW, sizeH);
}

void setup()
{
  background(255);
  noStroke();
}

void draw()
{
  translate(width / 4, height / 8);
  trafficLight();
}

void trafficLight()
{
  fill(0, 128, 255);
  rect(0, 0, height * 5/8, height * 5/24);
  
  fill(0, 192, 0);
  translate(height * 5/48, height * 5/48);
  circle(0, 0, height * 1/6);
  
  fill(255, 255, 0);
  translate(height * 5/24, 0);
  circle(0, 0, height * 1/6);
  
  fill(255, 0, 0);
  translate(height * 5/24, 0);
  circle(0, 0, height * 1/6);
  
  fill(0, 128, 255);
  translate(-height * 25/48, height * 5/48);
  rect(0, 0, height * 1/48, height * 5/8);
  
  fill(0, 128, 255);
  translate(0, 0);
  rect(0, 0, -height * 5/24, height * 5/12);
  
  fill(255, 0, 0);
  translate(0, 0);
  rect(-height * 1/48, height * 1/48, -height * 1/6, height * 1/6);
  
  fill(0, 192, 0);
  translate(0, height * 5/24);
  rect(-height * 1/48, height * 1/48,-height * 1/6, height * 1/6);
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0