1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
#pragma once
#include "ofMain.h"
#include "ofxJSON.h"
#include "ofxEasing.h"
#include "ofxGpuLutBlend.h"
#define min(a,b) ((a) < (b) ? (a) : (b))
#define max(a,b) ((a) > (b) ? (a) : (b))
#define THUMB_BORDER_RATIO 0.8
#define THUMB_SIZE 160
#define DEFAULT_FADEIN 1.0
#define BEZIER_OUT 0.25
#define BEZIER_IN 0.25
#define ROTATION_BEZIER_FRACTION 0.0
#define ROTATION_EASE_POWER 4.0
#define SWITCH_NONE 0
#define SWITCH_FORWARD 1
#define SWITCH_REVERSE 2
//#define GPU_ALGORITHM
//so annoying 1: menubar
//so annoying 2: dialogue stops screen
template <typename T> int sgn(T val) {
return (T(0) < val) - (val < T(0));
}
class chainImage : public ofImage{
public:
chainImage(){
link=NULL;
ofImage();
isLoaded=false;
colour=ofColor(255,255,255);
}
void init(ofPoint _linkPos,float _linkScale,float _linkRot);
void start(bool reverse=false);
bool tload(std::string _filename){
printf("tload : %s\n",_filename.c_str());
filename=_filename;
if (ofImage::load(filename)){
makeThumbnail();
//setImageType(OF_IMAGE_COLOR_ALPHA);
//could there be a way to load without committing the texture
//setUseTexture(false);
setAnchorPoint(getWidth()/2,getHeight()/2);
isLoaded=true;
return true;
}
else printf("could not load : %s\n",_filename.c_str());
return false;
}
void setAlpha(uint8_t a){
if (isAllocated()){
ofPixelsRef pixels = getPixels();
//uint8_t *im=(uint8_t *)&getPixels();
for (int i=0;i<getWidth()*getHeight();i++){
pixels[i]|=a;
}
}
}
void setAlpha(float a){
setAlpha((uint8_t)(a*255.0f));
}
int updateOutput(float decayRatio);
ofVec3f getTransform();
float getScale();
float getRotation();
ofPoint getLinkPos();
float getLinkRot();
float getLinkScale();
void updateRotationTimeline();
void drawChain(float fadeIn=DEFAULT_FADEIN,bool additive =false, float intensity=1.0f, float zoomMultiplier=1.0f,float startGamma=1.0f);
void gpu_drawChain(float fadeIn=DEFAULT_FADEIN,bool additive =false, float intensity=1.0f, float zoomMultiplier=1.0f);
void gpu_drawImage();
void drawRecursive(float fadeIn,bool additive,float intensity,float zoomMultiplier, float fadeStart, float fadeEnd);
ofImage thumbnail;
void makeThumbnail();
void setupTextures();
Json::Value toJson();
bool fromJson(Json::Value json);
ofPoint getPathPoint();
chainImage *link;
chainImage *linked;
ofPoint linkPos;
ofPoint dragPos;
float linkScale;
float dragScale;
float linkRot;
float dragRot;
ofColor colour;
std::string filename;
float transition;
float fadeIn;
float speed;
float time;
float scale;
ofPolyline path;
ofPolyline rotationTimeline;
bool isLoaded;
ofShader shader;
ofxGpuLutBlend lut;
//int totalframes,framecount;
};
|