#pragma once
#include "ofMain.h"
class ofApp : public ofBaseApp{
public:
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 windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
ofVec2f pos;
ofVec2f size;
bool positionIn;
bool mouseInside;
};
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
ofRectangle test;
pos = ofVec2f( 300, 300 );
size = ofVec2f( 200, 200 );
mouseInside = false;
}
//--------------------------------------------------------------
void ofApp::update(){
}
//--------------------------------------------------------------
void ofApp::draw(){
if (positionIn && !mouseInside) {
ofSetColor(255,0,0);
mouseInside = true;
cout << "bang Remain" << endl;
} else if (!positionIn && mouseInside){
mouseInside = false;
ofSetColor(0,0,255);
}
ofRect(pos, size.x, size.y);
}
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
}
//--------------------------------------------------------------
void ofApp::keyReleased(int key){
}
//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){
if (((x>pos.x)&&(x<pos.x+size.x))&&((y>pos.y)&&(y<pos.y+size.y))) {
positionIn = true;
} else {
positionIn = false;
}
}
//--------------------------------------------------------------
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){
}