Created
May 21, 2012 19:19
-
-
Save companje/2764075 to your computer and use it in GitHub Desktop.
HSB Cylindrical Color Wheel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "testApp.h" | |
//-------------------------------------------------------------- | |
void testApp::setup() { | |
ofBackground(0); | |
ofSetFrameRate(30); | |
glEnable(GL_DEPTH_TEST); | |
steps = 120; | |
step = TWO_PI/steps; | |
//top & bottom | |
for (int j=0; j<2; j++) { | |
//create vertices and set colors | |
mesh.addColor(j*255); | |
mesh.addVertex(ofVec3f(0,0,j)); | |
for (float i=0; i<steps; i++) { | |
mesh.addColor(ofColor::fromHsb(i/steps*255,255,j*255)); | |
mesh.addVertex(ofVec3f(sin(i/steps*TWO_PI),cos(i/steps*TWO_PI),j)); | |
} | |
//top & bottom triangles | |
for (int k=0,a,b,c; k<steps; k++) { | |
a = j*steps+j; | |
b = j*steps+j+k+1; | |
c = j*steps+j+k+2; | |
if (c>a+steps) c -= steps; | |
mesh.addTriangle(a,b,c); | |
} | |
} | |
//side | |
for (float i=1,a,b; i<=steps; i++) { | |
mesh.addTriangle(i,i+1,i+steps+2); | |
mesh.addTriangle(i,i+steps+1,i+steps+2); | |
} | |
} | |
//-------------------------------------------------------------- | |
void testApp::draw(){ | |
camera.begin(); | |
ofScale(125,125,125); | |
mesh.drawFaces(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "ofMain.h" | |
class testApp : public ofBaseApp{ | |
public: | |
void setup(); | |
void draw(); | |
ofEasyCam camera; | |
float step,steps; | |
ofMesh mesh; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment