-
Notifications
You must be signed in to change notification settings - Fork 0
/
testApp.cpp
88 lines (64 loc) · 2.32 KB
/
testApp.cpp
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
78
79
80
81
82
83
84
85
86
87
88
#include "testApp.h"
bool _compare_min_x(ofPoint const &p1, ofPoint const &p2) { return p1.x < p2.x; }
bool _compare_min_y(ofPoint const &p1, ofPoint const &p2) { return p1.y < p2.y; }
//--------------------------------------------------------------
void testApp::setup(){
ofBackground(225,255,255);
ofNoFill();
//ofEnableAlphaBlending ();
}
//--------------------------------------------------------------
void testApp::update(){
}
//--------------------------------------------------------------
void testApp::draw(){
ofSetColor(255,0,0);
ofBeginShape();
int size = this->points.size();
for (int i = 0; i < size; ++i) {
ofPoint p = points[i];
ofVertex(p.x, p.y);
}
ofEndShape();
ofSetColor(0,0,0);
float min_x=0, min_y=0, max_x=0, max_y=0;
if(points.size()>1) {
min_x = (*std::min_element(points.begin(), points.end(), &_compare_min_x)).x;
min_y = (*std::min_element(points.begin(), points.end(), &_compare_min_y)).y;
max_x = (*std::max_element(points.begin(), points.end(), &_compare_min_x)).x;
max_y = (*std::max_element(points.begin(), points.end(), &_compare_min_y)).y;
ofEllipse(min_x, min_y, 5,5);
ofEllipse(max_x, max_y, 5,5);
ofDrawBitmapString("min_x, min_y", min_x-45, min_y-8);
ofDrawBitmapString("max_x, max_y", max_x-45, max_y+8);
}
}
//--------------------------------------------------------------
void testApp::keyPressed(int key){
}
//--------------------------------------------------------------
void testApp::keyReleased(int key){
}
//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
this->points.push_back(ofPoint(x,y));
}
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
this->points.clear();
}
//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void testApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo dragInfo){
}