summaryrefslogtreecommitdiff
path: root/lasertext/src/ofApp.cpp
diff options
context:
space:
mode:
authorTim Redfern <tim@getdrop.com>2022-08-14 23:18:51 +0100
committerTim Redfern <tim@getdrop.com>2022-08-14 23:18:51 +0100
commit895389c009da308c4a1f01d0f17d8304ea12c915 (patch)
tree3bb5b8e90a55bbce68e04b705dd019f37b324302 /lasertext/src/ofApp.cpp
parent42f6a93907ccc11b1f8b4516d9c33524319a99cc (diff)
check in lasertest
Diffstat (limited to 'lasertext/src/ofApp.cpp')
-rw-r--r--lasertext/src/ofApp.cpp135
1 files changed, 135 insertions, 0 deletions
diff --git a/lasertext/src/ofApp.cpp b/lasertext/src/ofApp.cpp
new file mode 100644
index 0000000..b6f4061
--- /dev/null
+++ b/lasertext/src/ofApp.cpp
@@ -0,0 +1,135 @@
+#include "ofApp.h"
+#include "glew.h"
+
+/*
+what do we want to store/control per letter?
+*/
+
+
+int MAX_POINTS=40000;
+int LASER_INTENSITY=128;
+
+//--------------------------------------------------------------
+void ofApp::setup(){
+ fonts.open("fonts/");
+ fonts.allowExt("svg");
+ fonts.listDir();
+ ofLogNotice()<<"found "<<fonts.size()<<" fonts";
+
+ currentFont=0;
+ banner.loadFont("fonts/EMSPepita.svg"); //fonts.getPath(currentFont));
+ banner.init({"Everything","Is","Going","To","Be","Alright"});
+
+ laser.set_pts(MAX_POINTS);
+ laser.set_intensity(LASER_INTENSITY);
+}
+//--------------------------------------------------------------
+void ofApp::update(){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::draw(){
+ ofBackground(0,0,0);
+ ofSetColor(255,255,255);
+
+ vector<colourPolyline> shapes = banner.getOutlines();
+
+ int num = laser.draw(shapes);
+
+ //banner.draw();
+
+ ofPushMatrix();
+ ofTranslate(ofGetWidth()/2,ofGetHeight()/2);
+ //ofScale(0.05,-0.05,0.05);
+ for (auto& s: shapes) s.draw();
+ ofPopMatrix();
+
+ if (num>0){
+ ofSetWindowTitle(ofToString(ofGetFrameRate(), 2)+" fps laser points: "+ofToString(num));
+ }
+ else {
+ ofSetWindowTitle(ofToString(ofGetFrameRate(), 2)+" fps laser error ");
+ }
+
+}
+
+
+//--------------------------------------------------------------
+void ofApp::exit() {
+
+}
+
+
+
+//--------------------------------------------------------------
+void ofApp::keyPressed(ofKeyEventArgs &args){
+
+
+
+}
+
+
+
+//--------------------------------------------------------------
+void ofApp::keyReleased(int key){
+ if (key>=' '&&key<='~'){
+ banner.addGlyph(key,ofColor::fromHsb(ofRandom(255.0),225,255));
+ }
+ else if (key==OF_KEY_BACKSPACE||key==OF_KEY_DEL) { //DEL
+ banner.removeGlyph();
+ }
+ ofLog()<<banner.length()<<" "<<key<<" "<<banner.text();
+
+ switch(key){
+ case OF_KEY_UP:{
+ currentFont=(currentFont+1)%fonts.size();
+ banner.loadFont(fonts.getPath(currentFont));
+ break;
+ }
+ case OF_KEY_DOWN:{
+ currentFont--;
+ if (currentFont<0) currentFont=fonts.size()-1;
+ banner.loadFont(fonts.getPath(currentFont));
+ break;
+ }
+ }
+
+}
+
+//--------------------------------------------------------------
+void ofApp::mouseMoved(int x, int y ){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::mouseDragged(int x, int y, int button){
+}
+
+//--------------------------------------------------------------
+void ofApp::mousePressed(int x, int y, int button){
+}
+
+//--------------------------------------------------------------
+void ofApp::mouseReleased(int x, int y, int button){
+}
+
+//--------------------------------------------------------------
+void ofApp::mouseEntered(int x, int y){
+}
+
+//--------------------------------------------------------------
+void ofApp::mouseExited(int x, int y){
+}
+
+//--------------------------------------------------------------
+void ofApp::windowResized(int w, int h){
+}
+
+//--------------------------------------------------------------
+void ofApp::gotMessage(ofMessage msg){
+}
+
+//--------------------------------------------------------------
+void ofApp::dragEvent(ofDragInfo dragInfo){
+}