summaryrefslogtreecommitdiff
path: root/drawing/src
diff options
context:
space:
mode:
authorTim Redfern <tim@getdrop.com>2018-02-02 01:47:51 +0000
committerTim Redfern <tim@getdrop.com>2018-02-02 01:47:51 +0000
commit7c50a03c5857310aa383b1ba89a18792c96724b1 (patch)
tree97727831c97af5c06b39064dfdba60d61f7c7ae3 /drawing/src
parent2b6c19dd192b07fe5980f667e26015da51c3106d (diff)
lots
Diffstat (limited to 'drawing/src')
-rw-r--r--drawing/src/ofApp.cpp91
-rw-r--r--drawing/src/ofApp.h1
2 files changed, 46 insertions, 46 deletions
diff --git a/drawing/src/ofApp.cpp b/drawing/src/ofApp.cpp
index f84f0b0..7c7e784 100644
--- a/drawing/src/ofApp.cpp
+++ b/drawing/src/ofApp.cpp
@@ -2,14 +2,14 @@
#include "glew.h"
vector<std::string> cmdnames={"moveTo","lineTo","curveTo","bezierTo","quadBezierTo","arc","arcNegative","close"};
+float simplify_factor=0.2f;
//--------------------------------------------------------------
void ofApp::setup(){
ofxSVG svg;
- svg.load("lorenzo.svg");
+ svg.load("circles.svg");
imagepaths= svg.getPaths();
- float simplify_factor=0.2f;
std::stringstream strm;
@@ -39,7 +39,9 @@ void ofApp::setup(){
vector <ofPolyline> outlines= path.getOutline();
for (auto& outline:outlines){
+ outline.simplify(simplify_factor);
mask.push_back(outline);
+ masksegmenters.push_back(lineSegmenter(outline));
}
/*
vector<ofPath::Command> cmds=paths[i].getCommands();
@@ -86,7 +88,7 @@ void ofApp::setup(){
dirIdx = -1;
- laser.set_pts(30000);
+ laser.set_pts(40000);
laser.set_intensity(40);
warpframe[0]=glm::vec2(0,0);
@@ -266,18 +268,20 @@ void ofApp::draw(){
vector <ofPolyline> lasershapes;
switch (mode){
- case 2:{
- for (auto shape=segmenters.begin();shape!=segmenters.end();shape++){
+ case 0:{
+ //just draw the mask
+ for (auto shape=masksegmenters.begin();shape!=masksegmenters.end();shape++){
lasershapes.push_back(shape->getPoly());
}
break;
}
- case 0:{
- int s=((int)(ofGetElapsedTimef()*10))%segmenters.size();
- lasershapes.push_back(segmenters[s].getPoly());
+ case 1:{
+ //just draw 1 mask shape
+ int s=((int)(ofGetElapsedTimef()*10))%masksegmenters.size();
+ lasershapes.push_back(masksegmenters[s].getPoly());
break;
}
- case 1:{
+ case 2:{
for (auto shape=segmenters.begin();shape!=segmenters.end();shape++){
auto segments=shape->getSegments(numsegments,coverage,phase);
@@ -289,7 +293,8 @@ void ofApp::draw(){
break;
}
- case 11:{
+ case 3:{
+ //clip the shape with the mask (intersction)
vector <ofPolyline> shapes;
for (auto shape=segmenters.begin();shape!=segmenters.end();shape++){
auto segments=shape->getSegments(numsegments,coverage,phase);
@@ -301,13 +306,12 @@ void ofApp::draw(){
vector<ofPolyline> clipped = clipper.getClippedLines(ClipperLib::ctIntersection);
for (auto& clip: clipped)
{
- clip.draw();
- segmentsdrawn++;
- pointsdrawn+=clip.size();
+ lasershapes.push_back(colourPolyline(clip));
}
break;
}
- case 12:{
+ case 4:{
+ //clip the shape with the mask (difference)
vector <ofPolyline> shapes;
for (auto shape=segmenters.begin();shape!=segmenters.end();shape++){
auto segments=shape->getSegments(numsegments,coverage,phase);
@@ -319,13 +323,13 @@ void ofApp::draw(){
vector<ofPolyline> clipped = clipper.getClippedLines(ClipperLib::ctDifference);
for (auto& clip: clipped)
{
- clip.draw();
- segmentsdrawn++;
- pointsdrawn+=clip.size();
+ clip.simplify(simplify_factor);
+ lasershapes.push_back(colourPolyline(clip));
}
break;
}
- case 3:{
+ case 5:{
+ //translate it
vector <ofPolyline> shapes;
ofMatrix4x4 rm = ofMatrix4x4::newIdentityMatrix();
rm.translate(-600,-450,0);
@@ -338,23 +342,20 @@ void ofApp::draw(){
vector<ofPolyline> clipped = clipper.getClippedLines(ClipperLib::ctIntersection);
for (auto& clip: clipped)
{
- clip.draw();
- segmentsdrawn++;
- pointsdrawn+=clip.size();
+ clip.simplify(simplify_factor);
+ lasershapes.push_back(colourPolyline(clip));
}
break;
}
- case 4:{
+ case 6:{
vector<ofPolyline> clipped = clipper.getOffsets(maskpaths,((sin(ofGetElapsedTimef())+1)*5)+1,true);
for (auto& clip: clipped)
{
- clip.draw();
- segmentsdrawn++;
- pointsdrawn+=clip.size();
+ lasershapes.push_back(colourPolyline(clip));
}
break;
}
- case 5:{
+ case 7:{
//the N only fucks up when the other shapes are drawn!
vector<ofPolyline> clipped;
for (auto & maskpath:maskpaths){
@@ -368,10 +369,8 @@ void ofApp::draw(){
for (auto& clip: simplified)
{
-
- clip.draw();
- segmentsdrawn++;
- pointsdrawn+=clip.size();
+ clip.simplify(simplify_factor);
+ lasershapes.push_back(colourPolyline(clip));
}
/*
@@ -398,7 +397,7 @@ void ofApp::draw(){
*/
break;
}
- case 6:{
+ case 8:{
vector <ofPolyline> shapes;
for (auto& shape: mask)
@@ -413,15 +412,14 @@ void ofApp::draw(){
for (auto& clip: simplified)
{
- clip.draw();
- segmentsdrawn++;
- pointsdrawn+=clip.size();
+ clip.simplify(simplify_factor);
+ lasershapes.push_back(colourPolyline(clip));
}
break;
}
- case 7: {
+ case 9: {
ofPoint scale;
if(dir.isValidIndex(dirIdx)){
//client.update();
@@ -480,18 +478,14 @@ void ofApp::draw(){
ofColor c=colorImg.getPixels().getColor(point.x,point.y);
shape.addVertex(p,c);
}
- shapes.push_back(shape);
- segmentsdrawn++;
- pointsdrawn+=shape.size();
- shape.draw();
+ shape.simplify(simplify_factor);
+ lasershapes.push_back(shape);
}
break;
}
- case 8:{
+ case 10:{
int w=ofRandom(1000);
- segmenters[w%segmenters.size()].draw();
- segmentsdrawn=1;
- pointsdrawn+=segmenters[w%segmenters.size()].size();
+ lasershapes.push_back(colourPolyline(masksegmenters[w%masksegmenters.size()].getPoly(),ofColor(ofRandom(255),ofRandom(255),ofRandom(255))));
break;
}
}
@@ -528,7 +522,7 @@ void ofApp::draw(){
warpedshapes.push_back(polyLineTransform(s,warp));
}
- int num = laser.draw(warpedshapes);
+ int num = laser.draw(warpedshapes,ofColor(125,0,255));
for (auto& shape:lasershapes){
shape.draw();
@@ -543,7 +537,7 @@ void ofApp::draw(){
ofSetWindowTitle(ofToString(ofGetFrameRate(), 2)+" fps laser error ");
}
- //mainOutputSyphonServer.publishScreen();
+ mainOutputSyphonServer.publishScreen();
}
@@ -584,7 +578,12 @@ void ofApp::keyReleased(int key){
break;
}
case 'p':{
- mode=(mode+1)%9;
+ mode=(mode+1)%11;
+ break;
+ }
+ case 'q':{
+ mode=(mode-1);
+ if (mode<0) mode=10;
break;
}
case '-':{
diff --git a/drawing/src/ofApp.h b/drawing/src/ofApp.h
index 3cf9de8..d0e3a16 100644
--- a/drawing/src/ofApp.h
+++ b/drawing/src/ofApp.h
@@ -36,6 +36,7 @@ class ofApp : public ofBaseApp{
void gotMessage(ofMessage msg);
vector <lineSegmenter> segmenters;
+ vector <lineSegmenter> masksegmenters;
vector <ofPolyline> mask;
int numsegments;