From 77ce73a9b57cf3deac08720b449886b71412ea2f Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Fri, 19 Aug 2022 13:33:06 +0100 Subject: text with mapping and moveable star emitter --- lasertext/src/ofApp.cpp | 164 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 155 insertions(+), 9 deletions(-) (limited to 'lasertext/src/ofApp.cpp') diff --git a/lasertext/src/ofApp.cpp b/lasertext/src/ofApp.cpp index 5e6865e..a4e076d 100644 --- a/lasertext/src/ofApp.cpp +++ b/lasertext/src/ofApp.cpp @@ -5,19 +5,33 @@ what do we want to store/control per letter? */ + + //-------------------------------------------------------------- void ofApp::setup(){ + outputWindowSize=ofPoint(ofGetWidth(),ofGetHeight()); + fonts.open("fonts/"); fonts.allowExt("svg"); fonts.listDir(); ofLogNotice()<<"found "< shapes = banner.getOutlines(0.08f*text_scale); //+(0.02f*sin(ofGetElapsedTimef()*.1f))); + ofMatrix4x4 warp =lineTransformer::getPerspectiveTransformMatrix(src,warpframe); + + vector shapes = banner.getOutlines(0.08f); //*text_scale); //+(0.02f*sin(ofGetElapsedTimef()*.1f))); + + ofMatrix4x4 rm = ofMatrix4x4::newIdentityMatrix(); + rm.translate(laser_pos_x,laser_pos_y,0); + rm.scale(laser_scale,laser_scale,laser_scale); + rm.translate(outputWindowSize.x/2,outputWindowSize.y/2,0); + + vector warpedOutput; + vector warpedScaledOutput; + + for (auto s:shapes){ + warpedOutput.push_back(lineTransformer::polyLineTransform(warp,s)); + } + + for (auto s:warpedOutput){ + warpedScaledOutput.push_back(lineTransformer::polyLineTransform(rm,s)); + } int num = 0; - if (laser_power) num=laser.draw(shapes); + if (laser_power&&shapes.size()) num=laser.draw(warpedScaledOutput); //banner.draw(); ofPushMatrix(); ofTranslate(ofGetWidth()/2,ofGetHeight()/2); //ofScale(0.05,-0.05,0.05); - for (auto& s: shapes) s.draw(); + for (auto& s: warpedOutput) s.draw(); ofPopMatrix(); + ofSetColor(255,255,255); + + vector starshapes=stars.getPoints(); + int numstars=0; + for (auto& s: starshapes) { + numstars+=s.size(); + s.draw(); + } + + num+=laser.draw(starshapes); + if (num>0){ - ofSetWindowTitle(ofToString(ofGetFrameRate(), 2)+" fps laser points: "+ofToString(num)); + ofSetWindowTitle(ofToString(ofGetFrameRate(), 2)+" fps laser points: "+ofToString(num)+", stars: "+ofToString(numstars)); } else { - ofSetWindowTitle(ofToString(ofGetFrameRate(), 2)+" fps laser power off "); + ofSetWindowTitle(ofToString(ofGetFrameRate(), 2)+" fps laser power off, stars: "+ofToString(numstars)); } + + + } @@ -99,6 +229,7 @@ void ofApp::keyPressed(ofKeyEventArgs &args){ //-------------------------------------------------------------- void ofApp::keyReleased(int key){ + /* if (key>=' '&&key<='~'){ banner.addGlyph(key); } @@ -120,7 +251,13 @@ void ofApp::keyReleased(int key){ break; } } - + */ + switch(key){ + case 's':{ + save_settings(); + break; + } + } } //-------------------------------------------------------------- @@ -130,14 +267,23 @@ void ofApp::mouseMoved(int x, int y ){ //-------------------------------------------------------------- void ofApp::mouseDragged(int x, int y, int button){ + if (select_warpframe>-1){ + warpframe[select_warpframe]=glm::vec2(x,y); + } } //-------------------------------------------------------------- void ofApp::mousePressed(int x, int y, int button){ + for (int i=0;i<4;i++){ + if (ofPoint(x,y).distance(warpframe[i])<25){ + select_warpframe=i; + } + } } //-------------------------------------------------------------- void ofApp::mouseReleased(int x, int y, int button){ + select_warpframe=-1; } //-------------------------------------------------------------- -- cgit v1.2.3