Home> 2010-a > a-07 画像を使う

このエントリーをはてなブックマークに追加

a-07 画像を使う

  • 2010年5月31日 14:40
  • 2010-a

PImage 変数で画像を扱う場合のデータ型, image() 画像を表示するための関数

ウェブ上の画像を表示する

logo

size(300, 100);

// PImage 型の変数 logo に画像データを読み込む
PImage logo = loadImage("http://k.yimg.jp/images/top/sp/logo.gif");

// 画像を表示
image(logo, 0, 0);

画像を表示する

この画像をデスクトップにダウンロードしてから、表示させる

dandelion.jpg

手順

  1. sketch(プログラム)を書く
  2. メニューの「File > Save As」で「書類 > Processing」にsketchを保存
  3. Processingのエディタに画像ファイルをドラッグ

08-17

size(500, 500);

// PImage型の変数photoに「dandelion.jpg」を読み込む
PImage photo = loadImage("dandelion.jpg");

// 画像を表示
image(photo, 0, 0);

表示位置を調整する

08-05

size(500, 500);

PImage photo = loadImage("dandelion.jpg");

image(photo, 50, 100); //画像の左上を(50,100)に指定

表示サイズを調整する

08-06

size(500, 500);

PImage photo = loadImage("dandelion.jpg");

image(photo, 50, 100, 300, 200);//画像の幅を300, 高さを200に指定

色を調整する

tint

size(500, 500);

colorMode(HSB);

PImage photo = loadImage("dandelion.jpg");

//黄色を付ける
tint(50, 255, 255);

image(photo, 0, 0);

複数の画像を配置する

bus.png

上の画像をデスクトップにドラッグして、Processingのエディタにドラッグしておく。

tint

size(500, 500);
background(255);

PImage photo1 = loadImage("dandelion.jpg");
PImage photo2 = loadImage("bus.png");

image(photo1, 0, 0);
image(photo2, 350, 250);

画像のサイズを調べて画面の中央に配置する

width-height

size(500, 500);
background(255);

PImage photo2 = loadImage("bus.png");

println(photo2.width); //画像の幅をコンソールに表示
println(photo2.height); //画像の高さをコンソールに表示

image(photo2, (width - photo2.width) / 2, (height - photo2.height) / 2);

練習

1. 写真をランダムな位置に配置する(10個)

08-09

2. 写真をランダムな位置に配置する(小さくして100個)

08-10

3. 写真をランダムな位置に配置する(サイズもランダムにして100個)

08-11

Index of all entries

Home> 2010-a > a-07 画像を使う

カテゴリ
アーカイブ
購読
Recommends
Processing: A Programming Handbook for Visual Designers and Artists Learning Processing: A Beginner's Guide to Programming Images, Animation, and Interaction (Morgan Kaufmann Series in Computer Graphics and Geometric Modeling) FORM+CODE -デザイン/アート/建築における、かたちとコード Form+Code in Design, Art, and Architecture (Design Briefs) Generative Gestaltung Generative Art Built with Processing[Ver. 1.x対応版] -デザイン/アートのためのプログラミング入門 Getting Started With Processing Arduinoをはじめよう ビジュアライジング・データ ―Processingによる情報視覚化手法 +GAINER―PHYSICAL COMPUTING WITH GAINER
Powerd By

Return to page top