summaryrefslogtreecommitdiff
path: root/menuApp/src
diff options
context:
space:
mode:
authortim <tim@eclectronics.org>2017-03-25 01:11:08 +0000
committertim <tim@eclectronics.org>2017-03-25 01:11:08 +0000
commit74be885fc585d3865116e353ac13de94a5d688c7 (patch)
tree78ca003504a4faa283c377387ccfa23901b2600b /menuApp/src
parentc3682e9873a4e9a5518f2734373b12e3b6d11e45 (diff)
add ec2
Diffstat (limited to 'menuApp/src')
-rw-r--r--menuApp/src/ofApp.cpp109
-rw-r--r--menuApp/src/ofApp.h4
2 files changed, 18 insertions, 95 deletions
diff --git a/menuApp/src/ofApp.cpp b/menuApp/src/ofApp.cpp
index b1da2ff..d65e7e2 100644
--- a/menuApp/src/ofApp.cpp
+++ b/menuApp/src/ofApp.cpp
@@ -14,6 +14,7 @@ void ofApp::loadimages(){
{
for ( int i = 0; i < min(IMAGE_SLOTS,(int)instagram.getImageURL().size()); i++)
{
+ //if (instagram.getImageURL()!=)
getImages.loadFromURL(images[i], instagram.getImageURL()[i]);
ofLog(OF_LOG_NOTICE) << instagram.getImageURL()[i];
//images[i].load("images/"+ofToString(i)+".jpg");
@@ -35,31 +36,12 @@ void ofApp::loadimages(){
void ofApp::setup(){
- ofTrueTypeFont::setGlobalDpi(180);
-
- type14.load("American Typewriter Regular.ttf", 14*FACTOR, true, true);
- type14.setLineHeight(18.0f*FACTOR);
- type14.setLetterSpacing(1.037*FACTOR);
-
- /*
- bikers.load("images/bikers.jpg");
- gears.load("images/gears.gif");
- tdf.load("images/tdf_1972_poster.jpg");
-
- tdfSmall.load("images/tdf_1972_poster.jpg");
- tdfSmall.resize(tdfSmall.getWidth() / 4, tdfSmall.getHeight() / 4);
- tdfSmall.setImageType(OF_IMAGE_GRAYSCALE);
-
- transparency.load("images/transparency.png");
- bikeIcon.load("images/bike_icon.png");
- bikeIcon.setImageType(OF_IMAGE_GRAYSCALE);
- */
-
+ ofTrueTypeFont::setGlobalDpi(150);
+ myText.init("American Typewriter Regular.ttf", 14*FACTOR, 'i');
background.load("images/background1080.png");
overlay.load("images/overlay1080.png");
- //overlay.setImageType(OF_IMAGE_GRAYSCALE);
instagram.setup(hangdaitoken,"self");
instagram.setCertFileLocation(ofToDataPath("ca-bundle.crt",false));
@@ -78,6 +60,7 @@ void ofApp::setup(){
*/
//load
+ ofSetFrameRate(5);
}
//--------------------------------------------------------------
@@ -88,23 +71,13 @@ void ofApp::update(){
//--------------------------------------------------------------
void ofApp::draw(){
- ofSetColor(255);
+ ofSetColor(255,255,255);
ofPushMatrix(); //Store the coordinate system nexessary for some reason
background.draw(0,0,ofGetWidth(),ofGetHeight());
ofPopMatrix(); //Restore the coordinate system
- //ofLog(OF_LOG_NOTICE,"background is %fx%f",background.getWidth(),background.getHeight());
-/*
- int rowinitialoffset=40;
- int colinitialoffset=60;
- int rowoffset=520;
- int imgsize=480;
- int coloffset=603;
- int col=0;
- int row=0;
- int rows=2;
-*/
+
int colinitialoffset=40;
int rowinitialoffset=60;
int coloffset=520;
@@ -113,9 +86,11 @@ ofPopMatrix(); //Restore the coordinate system
int col=0;
int row=0;
int cols=2;
- int textcolinset=40;
+ int textcolinset=20;
int textrowinset=50;
+
+ //some kind of rendering bug with textsuite means it has to go last or everything is dim
if (!images.empty()) {
for (int i = 0; i < images.size(); i++) {
@@ -126,21 +101,11 @@ ofPopMatrix(); //Restore the coordinate system
int imgy=(rowinitialoffset+(row*rowoffset))*FACTOR;
images[i].draw(imgx,imgy,imgsize*FACTOR,imgsize*FACTOR);
std::string caption=instagram.getImageCaption()[i];
- int captionend = caption.find("#");
- if (captionend == std::string::npos){
- captionend=caption.size();
- }
- float width=type14.stringWidth(caption.substr(0,captionend));
- ofLog(OF_LOG_NOTICE) << caption.substr(0,captionend) << " <<<<:width: " << width;
+ myText.setText(caption);
+ myText.wrapTextX(imgsize*FACTOR);
+ myText.setColor(255,255,255,255);
+ myText.drawCenter(imgx+((imgsize*FACTOR)/2),imgy+((imgsize+textcolinset)*FACTOR),2);
- vector<std::string> captions = ofSplitString(caption.substr(0,captionend), " ");
-
- if (width<imgsize){
- captions.push_back(caption.substr(0,captionend));
- }
-
-
- type14.drawString(caption.substr(0,captionend),imgx+(textrowinset*FACTOR), imgy+((imgsize+textcolinset)*FACTOR));
}
col++;
if (col==cols){
@@ -150,56 +115,10 @@ ofPopMatrix(); //Restore the coordinate system
}
}
- ofEnableAlphaBlending();
+ ofEnableAlphaBlending();
overlay.draw(0,0,ofGetWidth(),ofGetHeight());
ofDisableAlphaBlending();
-
- //captions[i]=getImageCaption()[i];
-/*
- bikers.draw(0, 0);
- gears.draw(600, 0);
- tdf.draw(600, 300);
-
- ofSetColor(220, 50, 50);
- tdfSmall.draw(200, 300);
-
- ofSetColor(255);
- ofEnableAlphaBlending();
- float wave = sin(ofGetElapsedTimef());
- transparency.draw(500 + (wave * 100), 20);
- ofDisableAlphaBlending();
-
- // getting the ofColors from an image,
- // using the brightness to draw circles
- int w = bikeIcon.getWidth();
- int h = bikeIcon.getHeight();
- float diameter = 10;
- ofSetColor(255, 0, 0);
- for(int y = 0; y < h; y++) {
- for(int x = 0; x < w; x++) {
- ofColor cur = bikeIcon.getColor(x, y);
- float size = 1 - (cur.getBrightness() / 255);
- ofDrawCircle(x * diameter, 500 + y * diameter, 1 + size * diameter / 2);
- }
- }
-
- // same as above, but this time
- // use the raw data directly with getPixels()
- ofPixels & pixels = bikeIcon.getPixels();
- ofSetColor(0, 0, 255);
- for(int y = 0; y < h; y++) {
- for(int x = 0; x < w; x++) {
- int index = y * w + x;
- unsigned char cur = pixels[index];
- float size = 1 - ((float) cur / 255);
- ofDrawCircle(200 + x * diameter, 500 + y * diameter, 1 + size * diameter / 2);
- }
- }
-
- ofSetColor(255);
- bikeIcon.draw(190, 490, 20, 20);
- */
}
//--------------------------------------------------------------
diff --git a/menuApp/src/ofApp.h b/menuApp/src/ofApp.h
index ceafb00..21d84de 100644
--- a/menuApp/src/ofApp.h
+++ b/menuApp/src/ofApp.h
@@ -3,6 +3,7 @@
#include "ofMain.h"
#include "ofxInstagram.h"
#include "ofxThreadedImageLoader.h"
+#include "ofxTextSuite.h"
#define IMAGE_SLOTS 5
#define FACTOR 0.9
@@ -38,5 +39,8 @@ class ofApp : public ofBaseApp{
ofTrueTypeFont type14;
//ofImage images[5];
+
+ ofxTextBlock myText;
+ TextBlockAlignment alignment; //constants for controlling state
};