この記事を書いた人
![](https://watataku-artist-katsuyaku.com/wp-content/uploads/2024/03/watataku-user-profile-illustrationi-light-blue.png)
- クリエイティブコーディングで制作した作品と、上達のためにやったこと・学習過程を発信
- コンセプトは「クリエイティブコーディング1万時間の歩き方」
- 2024年にProcessingの構文のアウトプットを終え、2025年から作品制作開始(クリエイティブコーディングで作成した作品集)
目次
作品の画像とコード
![【作品No.29】画像の上に描く【Processing 2025年1月28日】](https://watataku-artist-katsuyaku.com/wp-content/uploads/2025/01/drawing-over-images-article-no-29-eye-catching-image.jpg)
PImage img;
ArrayList<PVector> points = new ArrayList<PVector>();
void setup() {
size(600, 600); // ウィンドウのサイズを設定
img = loadImage("main.jpg"); // 画像を読み込む
img.resize(600, 600); // 画像を600x600ピクセルにリサイズ
stroke(0); // 描画する線の色を黒に設定
}
void draw() {
background(255); // 背景を白に設定
image(img, 0, 0); // 画像をウィンドウに描画
for (PVector point : points) {
drawLissajous(point.x, point.y);
}
}
void mouseClicked() {
points.add(new PVector(mouseX, mouseY)); // ドラッグした位置情報を保存
}
void drawLissajous(float offsetX, float offsetY) {
int a = 5; // X方向の周波数
int b = 4; // Y方向の周波数
float delta = PI / 2; // 位相差
float scale = 50; // スケール(大きさ)調整
beginShape();
for (float t = 0; t < TWO_PI; t += 0.01) {
float x = scale * sin(a * t + delta) + offsetX;
float y = scale * sin(b * t) + offsetY;
vertex(x, y);
}
endShape(CLOSE);
}
作った感想
画像の上に描いたことがなかったので、作ってみました。
工夫すればもっと面白いことができそうです。
![](https://watataku-artist-katsuyaku.com/wp-content/uploads/2024/03/watataku-hukidashi-light-blue.png)
それでは今日もレッツワクワクコーディング。