![](https://watataku-artist-katsuyaku.com/wp-content/uploads/2024/03/watataku-hukidashi-light-blue.png)
今回の記事の目的はProcessingの「createImage()
」を理解し、自分なりに使ってみること。
この記事を書いた人
![](https://watataku-artist-katsuyaku.com/wp-content/uploads/2024/03/watataku-user-profile-illustrationi-light-blue.png)
![](https://watataku-artist-katsuyaku.com/wp-content/uploads/2024/03/watataku-user-profile-illustrationi-light-blue.png)
- クリエイティブコーディングで制作した作品と、上達のためにやったこと・学習過程を発信
- コンセプトは「クリエイティブコーディング1万時間の歩き方」
- 2024年にProcessingの構文のアウトプットを終え、2025年から作品制作開始(クリエイティブコーディングで作成した作品集)
目次
【Processing】createImage()について
createImage()について
- createImageは英語で「画像を作る」という意味
createImage()
は、コンピュータープログラムを使って新しい画像を作るための命令です。この命令を使うことで、プログラム内で画像を描いたり操作したりできます
【Processing】createImage()の使い方【画像とコード】
![](https://watataku-artist-katsuyaku.com/wp-content/uploads/2024/11/how-to-use-createimage-in-processing1.png)
![](https://watataku-artist-katsuyaku.com/wp-content/uploads/2024/11/how-to-use-createimage-in-processing1.png)
size(400, 400); // ウィンドウのサイズを設定
PImage img;
img = createImage(400, 400, RGB);
img.loadPixels();
for (int y = 0; y < 400; y += 10) { // ドットの間隔を10ピクセルに設定
for (int x = 0; x < 400; x += 10) {
int c = color(random(255), random(255), random(255)); // ランダムな色を生成
for (int dy = 0; dy < 10; dy++) { // ドットの高さを10ピクセルに設定
for (int dx = 0; dx < 10; dx++) { // ドットの幅を10ピクセルに設定
img.pixels[(x + dx) + (y + dy) * img.width] = c;
}
}
}
}
img.updatePixels();
image(img, 0, 0, width, height); // ウィンドウ全体に画像を表示
【Processing】createImage()を使ってみた感想
createImage()
で作成したものは画像として扱われると分かった。
応用したい表現である。
![](https://watataku-artist-katsuyaku.com/wp-content/uploads/2024/03/watataku-hukidashi-light-blue.png)
![](https://watataku-artist-katsuyaku.com/wp-content/uploads/2024/03/watataku-hukidashi-light-blue.png)
![](https://watataku-artist-katsuyaku.com/wp-content/uploads/2024/03/watataku-hukidashi-light-blue.png)
それでは今日もレッツワクワクコーディング。