Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F126621
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/util/gradient.cpp b/util/gradient.cpp
index 4e40d748..34ac35d1 100644
--- a/util/gradient.cpp
+++ b/util/gradient.cpp
@@ -1,40 +1,44 @@
#include "gradient.h"
#include "funcs.h"
namespace Effects{
/* this class does virtually no error checking. great job */
Gradient::Gradient(int size, int startColor, int endColor):
colors(0),
size(size),
index(0){
colors = new int[size];
Util::blend_palette(colors, size / 2, startColor, endColor);
Util::blend_palette(colors + size / 2, size / 2, endColor, startColor);
}
void Gradient::forward(){
index = (index + 1) % size;
}
void Gradient::backward(){
index = (index - 1 + size) % size;
}
void Gradient::update(){
forward();
}
+void Gradient::reset(){
+ index = 0;
+}
+
int Gradient::current(){
return colors[index];
}
int Gradient::current(int offset){
return colors[(index + offset + size) % size];
}
Gradient::~Gradient(){
delete[] colors;
}
}
diff --git a/util/gradient.h b/util/gradient.h
index e24fb313..a1bc91ba 100644
--- a/util/gradient.h
+++ b/util/gradient.h
@@ -1,29 +1,32 @@
#ifndef _paintown_gradient_h
#define _paintown_gradient_h
namespace Effects{
class Gradient{
public:
Gradient(int size, int startColor, int endColor);
/* move to next color. update is an alias for `forward' */
void update();
void forward();
void backward();
+ /* start at startColor */
+ void reset();
+
/* get current color */
int current();
int current(int offset);
virtual ~Gradient();
protected:
int * colors;
unsigned int size;
unsigned int index;
};
}
#endif
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Jun 11, 12:15 PM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
68985
Default Alt Text
(1 KB)
Attached To
Mode
R75 R-Tech1
Attached
Detach File
Event Timeline