Commit 1d150ac5 authored by Dat Nguyen's avatar Dat Nguyen

src files part 2

parent 59537e35
File added
//
// Branch.cpp
// CreativeProg
//
// Created by Dat Nguyen on 01/02/2016.
//
//
#include <stdio.h>
#include "Branch.h"
void Branch::setup() {
theta = ofRandom(20.0, 30.0);
rotate = 36.00;
branchValue = 100;
}
void Branch::draw() {
//ofTranslate(ofVec3f(100,0,100));
ofFill();
ofSetColor(255, 255, 0);
branch(branchValue);
}
void Branch::keyPressed() {
}
float Branch::branch(float len) {
float strokeWeight = ofMap(len, 4, 120, 0.5, 40);
ofSetLineWidth((strokeWeight*.5));
ofLine(0,0,0,-len);
ofTranslate(0, -len, 0);
// shrink the length of each branch when it grows
len *= 0.72;
ofPushMatrix();
ofRotateY(rotate);
if (len > 2.4) {
ofFill();
ofSetColor(255, 255, 0);
ofPushMatrix();
ofRotate(theta+10);
branch(len);
ofPopMatrix();
ofPushMatrix();
ofRotate(-theta);
branch(len);
ofPopMatrix();
}
ofPopMatrix();
}
//
// Branch.h
// CreativeProg
//
// Created by Dat Nguyen on 01/02/2016.
//
//
#ifndef Branch_h
#define Branch_h
#include "ofMain.h"
class Branch {
public:
float branch(float len);
void setup();
void draw();
void keyPressed();
float theta, rotate;
bool mousePressed;
float branchValue;
};
#endif /* Branch_h */
//
// Ground.cpp
// CreativeProg
//
// Created by Dat Nguyen on 01/02/2016.
//
//
#include <stdio.h>
//
// Ground.h
// CreativeProg
//
// Created by Dat Nguyen on 01/02/2016.
//
//
#ifndef Ground_h
#define Ground_h
#endif /* Ground_h */
//
// Shapes.cpp
// CreativeProg
//
// Created by Dat Nguyen on 01/02/2016.
//
//
#include <stdio.h>
//
// Shapes.h
// CreativeProg
//
// Created by Dat Nguyen on 01/02/2016.
//
//
#ifndef Shapes_h
#define Shapes_h
#endif /* Shapes_h */
//
// Tree.cpp
// CreativeProg
//
// Created by Dat Nguyen on 01/02/2016.
//
//
#include <stdio.h>
//
// Tree.h
// CreativeProg
//
// Created by Dat Nguyen on 01/02/2016.
//
//
#ifndef Tree_h
#define Tree_h
#endif /* Tree_h */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment