Processing を使うためのメモ

シェルコマンドを実行する方法

例:kyokoさんにしゃべらせる。

try{
      Runtime.getRuntime().exec("say -v kyoko 温度を設定しました");
    }
    catch(java.io.IOException e){
      println(e);
    }

ちなみにJavaでは、以下のようにする。

public class SayTest {
  public static void main(String[] args) {
	try{
      		Runtime.getRuntime().exec("say -v kyoko 温度を設定しました");
	    }
    	catch(java.io.IOException e){
      		System.out.println(e);
   	 }	

  }	
}

1つのスケッチで2つのウィンドウを出す方法

http://forum.processing.org/topic/two-windows-one-sketch より。

PFrame f;
secondApplet s;

void setup() {
 size(320, 240);
 PFrame f = new PFrame();
}

void draw() {
  background(255,0,0);
   fill(255);
   rect(10,10,frameCount%100,10);
   s.background(0, 0, 255);
   s.fill(100);
   s.rect(10,20,frameCount%120,10);
   s.redraw();
}

public class PFrame extends Frame {
    public PFrame() {
        setBounds(100,100,400,300);
        s = new secondApplet();
        add(s);
        s.init();
        show();
    }
}

public class secondApplet extends PApplet {
    public void setup() {
        size(400, 300);
        noLoop();
    }

    public void draw() {
    }
}

こんな感じ。

http://is.ocha.ac.jp/~siio/gyazo/20120706173918.png


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2021-10-22 (金) 23:27:11