This repository was archived by the owner on Mar 12, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathofApp.cpp
More file actions
77 lines (57 loc) · 1.9 KB
/
Copy pathofApp.cpp
File metadata and controls
77 lines (57 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
python.init();
python.executeScript("mytest.py");
ofxPythonObject klass = python.getObject("myApp");
if(klass)
python_program = klass();
if(python_program)
drawmethod = python_program.attr("draw");
}
//--------------------------------------------------------------
void ofApp::update(){
if(python_program)
python_program.method("update");
}
//--------------------------------------------------------------
void ofApp::draw(){
if(drawmethod)
drawmethod();
}
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
python.executeString("myApp.color = [random.randint(0,255) for _ in range(3)]");
if(python_program)
{
ofxPythonObject x = python.evalString("random.randint(100,200)");
ofLog() << x.repr();
python_program.attr("x") = x;
python_program.attr("y") = python_program.attr("x");
python_program.attr("d") = ofxPythonObject::fromInt(x.asInt()/4);
}
}
//--------------------------------------------------------------
void ofApp::keyReleased(int key){
}
//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){
}