Skip to content

Instantly share code, notes, and snippets.

@gatana
Last active April 18, 2016 18:31
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/8321f8c1ba20845b716a9a47f60bb821 to your computer and use it in GitHub Desktop.
Save gatana/8321f8c1ba20845b716a9a47f60bb821 to your computer and use it in GitHub Desktop.
Eating a Rainbow Donut by the East River during Blood Moon
//
// Circle.cpp
// Perspective_Landscape
//
// Created by Ana Sofia Remis on 4/18/16.
//
//
#include "Circle.hpp"
#include "ofMain.h"
Circle::Circle() {
diam=100;
velX= ofRandom(-3, 3);
velY=ofRandom(-4, 2);
}
void Circle:: setup(float mouseX, float mouseY) {
xPos= mouseX;
yPos=mouseY;
r= ofRandom(0-255);
g= ofRandom (0-255);
b= ofRandom (0-255);
alpha= ofRandom(0,255);
}
void Circle:: update(){
xPos= xPos+ velX;
yPos=yPos+velY;
}
void Circle:: draw() {
ofSetColor( r,g, b, alpha);
ofFill();
ofDrawCircle(xPos, yPos, diam);
}
//
// Circle.hpp
// Perspective_Landscape
//
// Created by Ana Sofia Remis on 4/18/16.
//
//
#ifndef Circle_hpp
#define Circle_hpp
#include <stdio.h>
#endif /* Circle_hpp */
class Circle{
public:
//variables
int xPos, yPos;
int r, g, b, alpha;
int diam;
int velX, velY;
//constructor
Circle();
//methods
void setup(float mouseX,float mouseY);
void update();
void draw();
//draw/inscribe rectangle
float aspect(float ww, float hh) { // return the aspect ration of the rectangle
// return(max(hh/ww,ww/hh));
}
};
#pragma once
#include "circle.hpp"
#include "ofMain.h"
#include "Rectangle.hpp"
class ofApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
// ofSoundPlayer;
ofSoundPlayer backgroundmusic;
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);
ofImage gmg;
float counter;
bool bSmooth;
int subCut=2;
Circle la;
Circle dida;
//la and dida are OBJECTS of our class alien
vector<Circle> circle;
Rectangle myRectangle;
float pct;
float amp; //amplitude
float period;
float circleX, circleY;
// float pct;
float r;
};
//Blood Moon over the East River
//Graphics primitives movement > spiraling circles, lines running
//geometry changes > Growing orange orb,
//color, applied various hues of blue, bliding sun neons.
//serial port usage // debugging
//gradients/// color change
//text,
//sound! waves play to relax the viewer gazing lazily at the spiral
//collision>> spiral hits boundaries of window, circle hits boundaries and recedes,
//--------------------------------------------------------------
void ofApp::setup(){
ofSetBackgroundAuto(false);
backgroundmusic.loadSound("Waves.mp3");
backgroundmusic.setLoop(true);
backgroundmusic.play();
circleX = ofGetWidth()/2;
circleY = ofGetHeight()/2;
amp = 10;
period = 0;
pct= 0;
//zeno
myRectangle.pos.x =10;
myRectangle.pos.y =10;
counter = 0;
bSmooth = false;
gmg.load("gmg.jpg");
ofSetFrameRate(30);
}
//--------------------------------------------------------------
void ofApp::update(){
{ //ofBackground(255);
//counter along with sin will make the radius of the ball keep changing
counter = counter + 0.0033f;
for(int i=0; i<circle.size(); i++){
circle[i].update(); }
//if we want something to move we must increase it
//making the pct number smaller will slow the sq down (try .01)
pct +=0.01;
if(pct >1){
pct =0;
}
//we now have a variable we can pass to interpolate
//myRectangle.interpolate(pct);
myRectangle.zeno(1000, 10);
//spiraling circle
r+=0.3;
circleX = ofGetWidth()/2 + sin(ofGetElapsedTimef()) * r;
circleY = ofGetHeight()/2 + cos(ofGetElapsedTimef()) * r;
}
}
//--------------------------------------------------------------
void ofApp::draw(){
// ofBackground (false);
// ofNoFill();
gmg.draw (0,0);
gmg.draw (40,0);
gmg.draw(80,0);
gmg.draw( 120, 0);
gmg.draw (180,0);
gmg.draw (200,0);
gmg.draw (240,0);
gmg.draw(280,0);
gmg.draw( 320, 0);
gmg.draw (380,0);
gmg.draw (400,0);
gmg.draw (420,0);
gmg.draw(480,0);
gmg.draw( 520, 0);
gmg.draw (580,0);
gmg.draw(680,0);
gmg.draw( 620, 0);
gmg.draw (780,0);
gmg.draw(880,0);
gmg.draw( 720, 0);
gmg.draw (980,0);
myRectangle.draw();
// int w = gmg.getWidth();
// int h = gmg.getHeight();
// float diameter = 10;
//
// //little circle grid
// ofSetColor(2, 210, 200);
// for(int y = 1; y < h; y++) {
// for(int x = 2; x < w; x++) {
// ofColor cur = gmg.getColor(x, y);
// float size = 1 - (cur.getBrightness() / 1005);
// ofDrawCircle(x * diameter, 50 + y * diameter, 1 + size * diameter / 2);
// }
// }
//
subCut=int(ofRandom(5,10));
// ofRect(0,0,ofGetWidth(), ofGetHeight());
{
//orange changing circle details
//ofSetColor(200,130, 0,79);
ofSetColor(abs(sin(ofGetElapsedTimef()/3))*255, abs(cos(ofGetElapsedTimef()/2))*255, abs(cos(ofGetElapsedTimef()/4))*255, 255);
float radius = 50 + 100 * sin(counter);
ofFill(); // draw filled shapes
//draws the changing size circle
ofDrawCircle((ofGetWidth()/2),(ofGetWindowHeight()/2),radius);
// }
ofSetColor(40, 20,80);
// ofDrawCircle(ofGetHeight()*2, ofGetWidth()/2, ofRandom(30-200));
//draws rectangle in a random spot between various ranges
ofDrawRectangle(ofRandom(0,1050),ofRandom(450,1050),ofRandom(1,105),ofRandom(25,35));
}
//spiraling circle
{
ofSetColor(80,79, 200, 165);
ofFill();
ofDrawCircle(circleX, circleY, 5);
//img can be moved above or below relative parts in the draw loop to go in front/back
}
// ofBackgroundGradient((78, 255, 500), (153, 100, 89));
}
//--------------------------------------------------------------
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){
ofSetColor (250, 70, 100);
ofDrawBitmapString ("East River", 70, 70) ;
}
//--------------------------------------------------------------
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){
}
//
// Rectangle.cpp
// Perspective_Landscape
//
// Created by Ana Sofia Remis on 4/18/16.
//
//
#include "Rectangle.hpp"
//methods
//constructor always takes the same name as the class
Rectangle::Rectangle(){
//ofPoint has x y and z so by doing dot notation you only access the x file
posA.x=100;
posA.y=10;
//point b is (1000,10);
posB.x=100;
posB.y = 10;
catchUpSpeed =.03;
}
//calculates the points
void Rectangle:: interpolate (float myPct){
// //linear interpolation
// pos.x=(1-myPct)*posA.x +myPct*posB.x;
// pos.y= (1-myPct)*posA.y+ myPct*posB.y;
//using exponenets/powers
pct= powf(myPct,2); //myPct^2 = myPct*myPct
pos.x = (1-pct)*posA.x+pct*posB.x;
pos.y= (1-pct)*posA.y+ pct*posB.y;
cout << "pos.x" << pos.x <<endl;
cout << "pos.y" << pos.y <<endl;
}
void Rectangle:: zeno(float catchX, float catchY) {
pos.x= catchUpSpeed*catchX + (1-catchUpSpeed)*pos.x;
pos.y=catchUpSpeed*catchY + (1-catchUpSpeed)*pos.y;
cout << "pos.x" << pos.x <<endl;
cout << "pos.y" << pos.y <<endl;
}
void Rectangle:: draw() {
//ofDrawRectangle (pos.x, pos.y, 100, 10);
ofDrawRectangle (pos.y, pos.x, 100, 10);
ofDrawRectangle (pos.y +50, pos.x, 100, 10);
ofDrawRectangle (pos.y +150, pos.x, 100, 10);
ofDrawRectangle (pos.y +200, pos.x, 100, 10);
ofDrawRectangle (pos.y +250, pos.x, 100, 10);
//ofDrawRectangle (pos.y +300, pos.x, 100, 10);
ofDrawRectangle (pos.y +350, pos.x, 100, 10);
ofDrawRectangle (pos.y +400, pos.x, 100, 10);
ofDrawRectangle (pos.y +450, pos.x, 100, 10);
ofDrawRectangle (pos.y +500, pos.x, 100, 10);
//ofDrawRectangle (pos.y +550, pos.x, 100, 10);
ofDrawRectangle (pos.y +600, pos.x, 100, 10);
ofDrawRectangle (pos.y +650, pos.x, 100, 10);
ofDrawRectangle (pos.y +700, pos.x, 100, 10);
ofDrawRectangle (pos.y +750, pos.x, 100, 10);
//ofDrawRectangle (pos.y +800, pos.x, 100, 10);
ofDrawRectangle (pos.y +850, pos.x, 100, 10);
ofDrawRectangle (pos.y +900, pos.x, 100, 10);
ofDrawRectangle (pos.y +950, pos.x, 100, 10);
// for(int i=0; i < (ofGetWindowWidth()/2))
// { pos.y = i++;
// }
}
//
// Rectangle.hpp
// Perspective_Landscape
//
// Created by Ana Sofia Remis on 4/18/16.
//
//
#ifndef Rectangle_hpp
#define Rectangle_hpp
#include <stdio.h>
#endif /* Rectangle_hpp */
#include "ofMain.h"
//creates rectangle
class Rectangle{
public:
//variables / properties
ofPoint posA; //point A
ofPoint posB; //point B
float catchUpSpeed; //for zeno techqniue
float pct; //percentage
ofPoint pos; //output point
//constructor where everything is set up for class, named same as class but put into function form
Rectangle();
//methods
void interpolate (float myPct); //calculates the points
void draw();
void zeno(float catchX, float catchY);
//
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment