Last active
December 25, 2015 03:49
-
-
Save trentbrooks/6913157 to your computer and use it in GitHub Desktop.
draw a rainbow ribbon (uses MeshUtils.h)
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
deque<ofVec3f> mousePts; | |
void testApp::drawRibbonRainbow() { | |
mousePts.push_back(ofVec3f(ofGetMouseX(), ofGetMouseY(), 0)); | |
ofPolyline polyPoints; | |
for(int i = 0; i < mousePts.size(); i++) { | |
polyPoints.addVertex(mousePts[i]); | |
} | |
ofPolyline smooth = polyPoints.getSmoothed(8); | |
float ribbonWidth = 6; | |
float strokeSize = ribbonWidth * 4; | |
// uses force to determine ribbon width | |
ofMesh followMeshC = MeshUtils::getSplitMeshWithForceFromPath(smooth,strokeSize - (ribbonWidth/2), false, 1); | |
ofMesh followMeshB = MeshUtils::getSplitMeshWithForceFromPath(smooth,strokeSize - (ribbonWidth/2), true, 1); | |
ofMesh followMesh = MeshUtils::getMeshWithForceFromPath(smooth,strokeSize * .33 - (ribbonWidth/2), .5); | |
// force doesn't affect ribbon width | |
//ofMesh followMeshC = MeshUtils::getSplitMeshFromPath(smooth,strokeSize - (ribbonWidth/2), false); | |
//ofMesh followMeshB = MeshUtils::getSplitMeshFromPath(smooth,strokeSize * .66 - (ribbonWidth/2), false); | |
//ofMesh followMesh = MeshUtils::getSplitMeshFromPath(smooth,strokeSize * .33 - (ribbonWidth/2), false); | |
glLineWidth(ribbonWidth); | |
ofSetColor(0); | |
followMeshC.drawWireframe(); | |
ofSetColor(0,255,255); | |
followMeshC.drawFaces(); | |
ofSetColor(0); | |
followMeshB.drawWireframe(); | |
ofSetColor(255,0,255); | |
followMeshB.drawFaces(); | |
ofSetColor(0); | |
followMesh.drawWireframe(); | |
ofSetColor(255,255,0); | |
followMesh.drawFaces(); | |
while(doubleMousePts.size() > 200) { | |
doubleMousePts.pop_front(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment