Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
diff --git a/util/gradient.cpp b/util/gradient.cpp
index fe50b2bc..4e40d748 100644
--- a/util/gradient.cpp
+++ b/util/gradient.cpp
@@ -1,28 +1,40 @@
#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::update(){
+void Gradient::forward(){
index = (index + 1) % size;
}
+void Gradient::backward(){
+ index = (index - 1 + size) % size;
+}
+
+void Gradient::update(){
+ forward();
+}
+
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 b0e798b9..e24fb313 100644
--- a/util/gradient.h
+++ b/util/gradient.h
@@ -1,26 +1,29 @@
#ifndef _paintown_gradient_h
#define _paintown_gradient_h
namespace Effects{
class Gradient{
public:
Gradient(int size, int startColor, int endColor);
- /* move to next color */
+ /* move to next color. update is an alias for `forward' */
void update();
+ void forward();
+ void backward();
/* get current color */
int current();
+ int current(int offset);
virtual ~Gradient();
protected:
int * colors;
unsigned int size;
unsigned int index;
};
}
#endif

File Metadata

Mime Type
text/x-diff
Expires
Thu, Jun 11, 12:45 PM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
69092
Default Alt Text
(1 KB)

Event Timeline