summaryrefslogtreecommitdiff
path: root/gui/src/chainImage.cpp
diff options
context:
space:
mode:
authorTim Redfern <tim@getdrop.com>2017-12-17 16:14:27 +0000
committerTim Redfern <tim@getdrop.com>2017-12-17 16:14:27 +0000
commitb470c73bfc271c032f4df9a3fd1b9770cf627f00 (patch)
tree9f1a716eab400c7e329afcb7b428d50b19c48e61 /gui/src/chainImage.cpp
parent3418dd0859106791d5534c53b901c2be4ea6b4c4 (diff)
select images
Diffstat (limited to 'gui/src/chainImage.cpp')
-rw-r--r--gui/src/chainImage.cpp126
1 files changed, 121 insertions, 5 deletions
diff --git a/gui/src/chainImage.cpp b/gui/src/chainImage.cpp
index 7192fdc..61ea55d 100644
--- a/gui/src/chainImage.cpp
+++ b/gui/src/chainImage.cpp
@@ -1,8 +1,5 @@
#include "chainImage.h"
-#define min(a,b) ((a) < (b) ? (a) : (b))
-#define max(a,b) ((a) > (b) ? (a) : (b))
-
float distance(ofPoint p1,ofPoint p2){
return pow(pow(p1.x-p2.x,2)+pow(p1.y-p2.y,2),0.5);
}
@@ -155,7 +152,7 @@ int chainImage::updateOutput(float decayRatio){
ofPoint previous=getLinkPos()+(rotated_destination*getLinkScale()*(1.0f-BEZIER_IN));
path.bezierTo(
- getLinkPos().x*(1.0f+(BEZIER_OUT*linkScale)),getLinkPos().y*(1.0f+(BEZIER_OUT*linkScale)),
+ getLinkPos().x*(1.0f+(BEZIER_OUT*linkScale)),getLinkPos().y*(1.0f+(BEZIER_OUT*linkScale)) ,
previous.x,previous.y,
destination.x,destination.y);
@@ -220,7 +217,35 @@ float chainImage::getRotation(){
//linkRot is no longer seen
//return linkRot+(transition*link->linkRot); //linkRot+
- return getLinkRot()+rotationTimeline.getPointAtPercent(transition).y;
+ //return getLinkRot()+rotationTimeline.getPointAtPercent(transition).y;
+
+ //it doesn't seem that beziers are useful for this unless we can intersect a line
+/* vector<ofPolyline> rv;
+ rv.push_back(rotationTimeline);
+ ofxSweepLine Sweep= ofxSweepLine(rv);
+ ofPolyline line;
+ line.addVertex(transition,-1.0f);
+ line.addVertex(transition,357.0f);
+ vector<ofPolyline> lv;
+ lv.push_back(line);
+ vector<ofVec2f> result=Sweep.sweep(lv);
+
+ printf("ofxSweepLine: got %f intersections\n",result.size());
+
+ if (result.size()) {
+ return result[0].y;
+ }
+
+ ofxSweepLine crashes
+ */
+
+ float transitionInterpolated=pow(transition,ROTATION_EASE_POWER);
+
+ //printf("rotation: %f at point %f\n",transitionInterpolated,transition);
+
+
+ return getLinkRot()+(transitionInterpolated*link->getLinkRot());
+
};
ofPoint chainImage::getLinkPos(){
return linkPos+dragPos;
@@ -259,7 +284,98 @@ void chainImage::makeThumbnail(){
thumbnail.setAnchorPoint(thumbnail.getWidth()/2,thumbnail.getHeight()/2);
}
+/*
+void chainImage::drawRecursive(float fadeIn,bool additive,float intensity,float zoomMultiplier, float fadeStart, float fadeEnd){
+
+ //printf("Drawing chain transition: %f\n",transition);
+ //we are correctly geting to 1
+ //the transformw don't quite add up?
+ //we are drawing each image twice?
+
+ float thisAmount=max(0.0,min(1.0((transition-fadeStart)/(fadeEnd-fadeStart))))*intensity;
+
+ (0,1) , 0 = 0
+ (0,1) , 0.5 = 0.5
+ (0,1) , 1.0 = 1.0
+ (0.5,1) , 0 = 0.0
+ (0.5,1) , 0.5 = 0.0
+ (0.5,1) , 0.75 = 0.5
+ (0.5,1) , 1.0 = 1.0
+ (0,2) , 0 = 0
+ (0,2) , 1 = 0.5
+ (0,2) , = 0.5
+
+ glPushMatrix();
+
+ if (thisAmount>0){
+
+ if (additive){
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ ofSetColor(255,255,255,255*thisAmount);
+ }
+ else {
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ ofSetColor(255,255,255,255*intensity);
+ }
+
+ //ofDisableAlphaBlending();
+
+ setAnchorPoint(getWidth()/2,getHeight()/2);
+
+ draw(0,0,getWidth(),getHeight());
+ //the animated transform of the zoom is set before calling the first image
+
+ //add a scale factor to the outgoing image that builds up over the transition
+
+
+// glPushMatrix();
+// //if this is linear we see the jump from the unaccelerated phase
+// //float zoomFactor=((zoomMultiplier-1.0f)*transition)+1.0f;
+
+// //this is worse why?
+// float zoomFactor=pow(zoomMultiplier,1.0f+transition);
+
+// glScalef(zoomFactor,zoomFactor,zoomFactor);
+
+// //ofSetColor(colour);
+
+
+// glPopMatrix();
+
+
+ }
+
+ if (fadeEnd>1.0){
+
+ glTranslatef(getLinkPos().x,getLinkPos().y,0);
+
+ glRotatef(getLinkRot(),0,0,1);
+
+ glScalef(getLinkScale(),getLinkScale(),getLinkScale());
+
+ //ofEnableAlphaBlending();
+ glEnable(GL_BLEND);
+
+ ofSetColor(255,255,255,255*min(1.0,transition/fadeIn)*intensity);
+
+ //link->setAnchorPoint(link->getWidth()/2,link->getHeight()/2);
+
+ //ofSetColor(link->colour);
+ //link->draw(0,0,link->getWidth(),link->getHeight());
+
+ link->drawRecursive(fadeIn,additive,intensity,zoomMultiplier,fadeStart-1.0f,fadeEnd-1.0f);
+
+ glDisable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ }
+
+ glPopMatrix();
+}
+*/
void chainImage::drawChain(float fadeIn,bool additive,float intensity,float zoomMultiplier){
//printf("Drawing chain transition: %f\n",transition);