Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "testApp.h"
- //--------------------------------------------------------------
- void testApp::setup(){
- file.open("hand_in_4.txt");
- if(file.is_open){
- do{
- file >> g_type >> image_name >> x >> y >> w >> h;
- if(g_type == "image"){
- interview.loadImage(image_name);
- interview.resize(w, h);
- data = new unsigned char [w*h*3];
- image_texture.allocate(w, h, GL_RGB);
- data = interview.getPixels();
- image_texture.loadData(data, w, h, GL_RGB);
- }
- if(g_type == "triangle"){
- ofTriangle(x1, y1, x2, y2, x3, y3);
- }
- if(g_type == "rect"){
- ofSetColor(255, 0, 0);
- ofNoFill();
- ofSetLineWidth(5);
- ofRect(x1, y1, x2, y2);
- }
- if(g_type == "circle"){
- ofSetColor(165, 189, 25);
- ofFill();
- ofSetCircleResolution(100);
- ofCircle(x1, y1, rad);
- }
- if(g_type == "rainbow"){
- ofSetLineWidth(w);
- ofSetColor(255, 0, 0);
- ofLine(x1, y1, x2, y2);
- ofSetColor(0,255,0);
- ofLine(x1, y1+10, x2, y2+20);
- ofSetColor(165, 189, 25);
- ofLine(x1, y1+20, x2, y2+40);
- ofSetColor(255, 0, 0);
- ofLine(x1, y1+30, x2, y2+60);
- ofSetColor(255, 0, 0);
- ofLine(x1, y1+40, x2, y2+80);
- ofSetColor(255, 0, 0);
- ofLine(x1, y1+50, x2, y2+100);
- }
- if(g_type == "box"){
- ofSetColor(255, 0, 0);
- ofNoFill();
- ofBox(x1, y1, z, size);
- }
- if(g_type == "sphere"){
- ofNoFill();
- ofSetLineWidth(1);
- ofSphere(x1,y1,z,rad);
- }
- }while(! file.eof());
- file.close();
- }
- }
- //--------------------------------------------------------------
- void testApp::update(){
- }
- /*
- //--------------------------------------------------------------
- void testApp::draw_triangle(int x1, int y1, int x2, int y2, int x3, int y3){
- ofSetLineWidth(3);
- ifstream file("hand_in_4.txt");
- do{
- file >> g_type >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
- if(g_type == "triangle"){
- ofTriangle(x1, y1, x2, y2, x3, y3);
- }
- }while(! file.eof());
- file.close();
- }
- //--------------------------------------------------------------
- void testApp::draw_rect(int x1, int y1, int x2, int y2){
- ifstream file("hand_in_4.txt");
- do{
- file >> g_type >> x1 >> y1 >> x2 >> y2;
- if(g_type == "rect"){
- ofSetColor(255, 0, 0);
- ofNoFill();
- ofSetLineWidth(5);
- //ofRotateY(45);
- ofRect(x1, y1, x2, y2);
- }
- }while(! file.eof());
- file.close();
- }
- //-------------------------------------------------------------
- void testApp::draw_circle(int x1, int y1, int rad){
- ifstream file("hand_in_4.txt");
- do{
- file >> g_type >> x1 >> y1 >> rad;
- if(g_type == "circle"){
- ofSetColor(165, 189, 25);
- ofFill();
- ofSetCircleResolution(100);
- ofCircle(x1, y1, rad);
- }
- }while(! file.eof());
- file.close();
- }
- //-------------------------------------------------------------
- void testApp::draw_rainbow(int x1, int y1, int x2, int y2, int w){
- ifstream file("hand_in_4.txt");
- do{
- file >> g_type >> x1 >> y1 >> x2 >> y2;
- if(g_type == "rainbow"){
- ofSetLineWidth(w);
- ofSetColor(255, 0, 0);
- ofLine(x1, y1, x2, y2);
- ofSetColor(0,255,0);
- ofLine(x1, y1+10, x2, y2+20);
- ofSetColor(165, 189, 25);
- ofLine(x1, y1+20, x2, y2+40);
- ofSetColor(255, 0, 0);
- ofLine(x1, y1+30, x2, y2+60);
- ofSetColor(255, 0, 0);
- ofLine(x1, y1+40, x2, y2+80);
- ofSetColor(255, 0, 0);
- ofLine(x1, y1+50, x2, y2+100);
- }
- }while(! file.eof());
- file.close();
- }
- //----------------------------------------------------
- void testApp::draw_box(int x1, int y1, int z, int size){
- ifstream file("hand_in_4.txt");
- do{
- file >> g_type >> x1 >> y1 >> z >> size;
- if(g_type == "box"){
- ofSetColor(255, 0, 0);
- ofNoFill();
- ofBox(x1, y1, z, size);
- }
- }while(! file.eof());
- file.close();
- }
- //----------------------------------------------------
- void testApp::draw_sphere(int x1, int y1, int z, int rad){
- ifstream file("hand_in_4.txt");
- do{
- file >> g_type >> x1 >> y1 >> z >> rad;
- if(g_type == "sphere"){
- ofNoFill();
- ofSetLineWidth(1);
- ofSphere(x1,y1,z,rad);
- }
- }while(! file.eof());
- file.close();
- }
- */
- //--------------------------------------------------------------
- void testApp::draw(){
- ofBackground(0);
- image_texture.draw(x, y, w, h);
- ofTriangle(x1, y1, x2, y2, x3, y3);
- ofRect(x1, y1, x2, y2);
- ofCircle(x1, y1, rad);
- ofLine(x1, y1, x2, y2, w);
- ofBox(x1, y1, z, size);
- ofSphere(x1, y1, z, rad);}
- //--------------------------------------------------------------
- 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){
- }
- //--------------------------------------------------------------
- void testApp::mousePressed(int x, int y, int button){
- }
- //--------------------------------------------------------------
- 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){
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement