Home > 1a > | ノート > 1a-07 画像や文字を使う

1a-07 画像や文字を使う

  • Posted by: masa
  • 2009年6月 1日 14:40
  • 1a | ノート

教科書 p.82〜p.87

  • 画像を使う
  • 文字を使う

PImage / image 画像を使う

準備

photo.jpg 08-02

08-03 08-04

  1. 上の写真(photo.jpg)をデスクトップにドラッグ
  2. メニューの「File > Save As」で「書類 > Processing」にsketchを保存
  3. Processingのエディタに画像ファイルをドラッグする

画像を表示する

08-17

size(500,500);

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

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

表示位置を調整する

08-05

size(500,500);

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

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

表示サイズを調整する

08-06

size(500,500);

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

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

色を調整する

08-07

size(500,500);

colorMode(HSB,100);
background(99);

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

//黄色を付ける
tint(20,99,99);

image(photo1,0,0);

複数の画像を配置する

bus.png

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

08-08

size(500,500);

colorMode(HSB,100);
background(99);

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

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

練習

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

08-09

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

08-10

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

08-11

PFont / textFont / text 文字を描く

準備

08-12 08-13

フォントデータを生成しておく

文字を描く

08-14

size(500,200);

PFont myFont=loadFont("HelveticaNeue-Bold-24.vlw");
textFont(myFont,24);

text("I Love Processing!",0,100);

文字に色を付ける

08-15

size(500,200);
colorMode(HSB,100);
background(99);

PFont myFont=loadFont("HelveticaNeue-Bold-24.vlw");
textFont(myFont,24);

fill(0,99,99);
text("I Love Processing!",0,100);

文字の揃え位置を設定する

08-16

size(500,200);
colorMode(HSB,100);
background(99);

PFont myFont=loadFont("HelveticaNeue-Bold-24.vlw");
textFont(myFont,24);

textAlign(CENTER);
fill(0,99,99);
text("I Love Processing!",width/2,height/2);

関連エントリー

Home > 1a > | ノート > 1a-07 画像や文字を使う

Search
Feeds
Textbook
  • Built with Processing [改訂版]
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)
  • Arduinoをはじめよう
  • ビジュアライジング・データ ―Processingによる情報視覚化手法
  • +GAINER―PHYSICAL COMPUTING WITH GAINER

Return to page top