Last active
December 27, 2015 10:39
-
-
Save liamstask/7312750 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
void P_1_1_2_01App::setup() | |
{ | |
savePDF = false; | |
segmentCount = 360; | |
radius = 300; | |
ofSetWindowShape(800, 800); | |
} | |
void P_1_1_2_01App::draw() | |
{ | |
if (savePDF) { | |
ofBeginSaveScreenAsPDF("screenshot-" + ofGetTimestampString() + ".pdf", false); | |
} | |
int width = ofGetWindowWidth(); | |
int height = ofGetWindowHeight(); | |
float angleStep = 360 / segmentCount; | |
ofMesh mesh; | |
mesh.setMode(OF_PRIMITIVE_TRIANGLE_FAN); | |
mesh.addVertex(ofVec3f(width / 2, height / 2)); | |
for (float angle = 0; angle <= 360; angle += angleStep) { | |
float vx = width/2 + cos(ofDegToRad(angle)) * radius; | |
float vy = height/2 + sin(ofDegToRad(angle)) * radius; | |
mesh.addVertex(ofVec3f(vx, vy)); | |
float a = ofMap(angle, 0, 360, 0, 255); | |
float mx = ofMap(mouseX, 0, width, 0, 255); | |
float my = ofMap(mouseY, 0, height, 0, 255); | |
mesh.addColor(ofColor::fromHsb(a, mx, my)); | |
} | |
// mesh.draw(); | |
mesh.drawWireframe(); | |
if (savePDF) { | |
savePDF = false; | |
ofEndSaveScreenAsPDF(); | |
} | |
} |
This file contains hidden or 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
boolean savePDF = false; | |
int segmentCount = 360; | |
int radius = 300; | |
void setup(){ | |
size(800, 800); | |
} | |
void draw(){ | |
if (savePDF) beginRecord(PDF, timestamp()+".pdf"); | |
noStroke(); | |
colorMode(HSB, 360, width, height); | |
background(360); | |
float angleStep = 360/segmentCount; | |
beginShape(TRIANGLE_FAN); | |
vertex(width/2, height/2); | |
for (float angle=0; angle<=360; angle+=angleStep){ | |
float vx = width/2 + cos(radians(angle))*radius; | |
float vy = height/2 + sin(radians(angle))*radius; | |
vertex(vx, vy); | |
fill(angle, mouseX, mouseY); | |
} | |
endShape(); | |
if (savePDF) { | |
savePDF = false; | |
endRecord(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment