[work 25] Chaos – invariant curve –
![[work 25] Chaos – invariant curve –](https://i0.wp.com/tsukuru.hayato-works.com/wp-content/uploads/2019/04/outFrameImg0900.png?fit=1280%2C720&ssl=1)
Movie
Source code
about
カオス(不変曲線の絡み)
file
- 上部にあるファイル名が表示されているボタンを押すと、表示されるファイルが切り替わります
- 別ウィンドウ表示したい時や行番号などが無いRawMode表示したい時は、コード内右上のボタンを押してください(ボタンはマウスオーバーすると表示されます)
#include "ofMain.h"
#include "ofApp.h"
//================================
int main( ){
// 4K:4096x2160
// 2K:2048x1080
// FullHD:1920x1080
// HD:1440x1080
// HD720p:1280x720
// DVD:720x480
// setup the GL context
ofSetupOpenGL(1280,720, OF_WINDOW);
// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
// pass in width and height too:
ofRunApp( new ofApp());
}
#pragma once
#include "ofMain.h"
#include "Attractor.hpp"
class ofApp : public ofBaseApp{
public:
ofApp();
~ofApp();
void setup();
void update();
void draw();
void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y);
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void mouseEntered(int x, int y);
void mouseExited(int x, int y);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
private:
Attractor a;
};
#include "ofApp.h"
ofApp::ofApp(){
}
ofApp::~ofApp(){
}
//--------------------------------------------------------------
void ofApp::setup(){
double fps = 30;
ofSetFrameRate(fps);
ofBackground(0);
ofSetBackgroundAuto(true);
a.setup();
}
//--------------------------------------------------------------
void ofApp::update(){
int max = (int)ofRandom(10,100);
for (int i = 0; i < max; i++) {
a.update();
}
}
//--------------------------------------------------------------
void ofApp::draw(){
a.display();
}
#ifndef Attractor_hpp
#define Attractor_hpp
#include <stdio.h>
#include "ofMain.h"
#include "myColorLib.hpp"
class Attractor {
public:
Attractor();
~Attractor();
void setup();
void update();
void display();
private:
ofVec2f calc(ofVec2f p);
ofVec2f point;
ofFbo fb;
float scale;
};
#endif /* Attractor_hpp */
#include "Attractor.hpp"
Attractor::Attractor()
{
}
Attractor::~Attractor()
{
}
void Attractor::setup()
{
point = ofVec2f(0.1, 0);
fb.allocate(ofGetWidth(), ofGetHeight());
scale = 30;
}
void Attractor::update()
{
ofMesh mesh;
ofVec2f prePoint = point;
ofVec2f p;
ofColor c;
c.setHsb(ofRandom(c.limit()), 255, 255);
fb.begin();
point = calc(prePoint);
p = point * scale;
ofPushMatrix();
ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2);
ofSetColor(c);
ofDrawCircle(p.x, p.y, 1);
ofPopMatrix();
prePoint = point;
fb.end();
}
void Attractor::display()
{
fb.draw(0, 0);
}
ofVec2f Attractor::calc(ofVec2f p)
{
ofVec2f out;
out.x = p.y + 0.55 * p.x + 4.0 * atan(p.x) / (1.0 + p.x * p.x);
out.y = -p.x;
return out;
}
Link to the reference page
ソースコードで使用したAPIの中から要点になりそうなものをいくつか選んでリストアップしました。
| category | API/Lib |
| openframeworks | ofFbo |
Development environment
- openframeworks 0.10.1
- c++
- macOS
- Xcode