Skip to content

Instantly share code, notes, and snippets.

@gatana
Created March 26, 2016 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gatana/5d27bf096e07c7f6d147 to your computer and use it in GitHub Desktop.
Save gatana/5d27bf096e07c7f6d147 to your computer and use it in GitHub Desktop.
//
// Forma.cpp
// midterm
//
// Created by Ana Sofia Remis on 3/26/16.
//
//
#include "Forma.hpp"
void Forma::formata(float diameter, float circumference, float angle, float size, float maxSize){
ofNoFill();
ofDrawEllipse(0, 0, diameter, size);
ofRotate(angle);
ofDrawEllipse(0, 0, circumference, size);
diameter = circumference*size;
if(diameter < maxSize){
ofPushMatrix();
ofRotate(angle);
formata(diameter, circumference, angle, size, maxSize);
ofPopMatrix();
}
//
// Forma.hpp
// midterm
//
// Created by Ana Sofia Remis on 3/26/16.
//
//
#ifndef Forma_hpp
#define Forma_hpp
#include "ofMain.h"
#include <stdio.h>
#endif /* Forma_hpp */
class Forma{
public:
float diameter, circumference, angle, size, maxSize;
void formata (float diameter, float circumference, float angle, float size, float maxSize);
};
#include "ofMain.h"
#include "ofApp.h"
//========================================================================
int main( ){
ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context
// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
// pass in width and height too:
ofRunApp(new ofApp());
}
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
ofBackground(0);
ofSetBackgroundAuto(false);
lady.circumference = 50;
lady.diameter = 500;
lady.angle = 2;
lady.size = 1.05;
lady.maxSize = 1200;
Gui.setup();
Gui.add(circumference.setup("circumference", 50, 10, 800));
Gui.add(diameter.setup("diameter", 500, 10, 800));
Gui.add(angle.setup("angle", 5, 1, 20));
Gui.add(size.setup("size",1.1, 1.01, 1.5 ));
Gui.add(maxSize.setup("maxSize", 1200, 500, 2500));
}
//--------------------------------------------------------------
void ofApp::update(){
lady.circumference = circumference;
lady.diameter = diameter;
lady.angle = angle;
lady.size = size;
lady.maxSize = maxSize;
}
//--------------------------------------------------------------
void ofApp::draw(){
ofSetColor(0, 0, 0, 90);
ofFill();
Gui.draw();
ofDrawRectangle(0, 0, ofGetWidth(), ofGetHeight());
// ofTranslate(ofGetWidth()/2, ofGetHeight()/2);
// ofSetColor(abs(sin(ofGetElapsedTimef()/3))*255, abs(cos(ofGetElapsedTimef()/2))*255, abs(cos(ofGetElapsedTimef()/4))*255, 255);
lady.formata (circumference, diameter, angle, size, maxSize);
}
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
}
//--------------------------------------------------------------
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::mouseEntered(int x, int y){
}
//--------------------------------------------------------------
void ofApp::mouseExited(int x, int y){
}
//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){
}
#pragma once
#include "ofMain.h"
#include "Forma.hpp"
#include "ofxGui.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 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);
Forma lady;
ofxPanel Gui;
ofxFloatSlider diameter;
ofxFloatSlider circumference;
ofxFloatSlider angle;
ofxFloatSlider size;
ofxFloatSlider maxSize;
//ofxFloatSlider speed;
//ofxFloatSlider clarity;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment