Help us understand the problem. What is going on with this article?

openFrameworksでジェネラティブ系の静止画像を描画する

More than 5 years have passed since last update.

openFrameworksでフレームごとにランダムな値をつかって描画するプログラムを書くと、静止画を作れなくて困ります。
一度配列に値をいれてしまって毎回その配列から読み出す、とかも考えられますが、さくっと書くには面倒です。draw関数内に一回だけ実行するようにしたとしても、すぐ消えてしまいます。

以下のように書けば静止画の描画を何度も好きなタイミングで行えます。
これでグラフィックデザインでもopenFrameworksが大活躍!

ofApp.h
class ofApp : public ofBaseApp{
     public
         void draw_once();
         bool once;
}
ofApp.cpp
void ofApp::setup(){
     once = true;
     // フレーム更新時に前のフレームで描画したものを消さない
     ofSetBackgroundAuto(false); 
}

void ofApp::draw(){
     if(once){
         draw_once();
         once = false;
     }
}
void ofApp::draw_once(){
     // ここに描画するプログラムを書く
}
void ofApp::keyPressed(int key){
    once = true;
}
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away