Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added rgba tween

  • Loading branch information...
commit 8207d939dbe857ba62715b8cb8a302bce7cfc2a7 1 parent 3b6ae4f
Ran Eilam authored
9 src/Timeline.cpp
@@ -10,6 +10,7 @@ using namespace std;
10 10 typedef LinearTweenForm<int ,1,false> LinearIntForm;
11 11 typedef LinearTweenForm<int ,1,true> LinearIntFormFloored;
12 12 typedef LinearTweenForm<float,1,false> LinearFloatForm;
  13 +typedef LinearTweenForm<char ,4,false> LinearRgbaForm;
13 14
14 15 Timeline::Timeline() : tickers() {
15 16 }
@@ -68,3 +69,11 @@ Tween *Timeline::build_path_tween(IProxy<int,2> *proxy, ICompleter *completer,
68 69 PathTweenForm *form = new PathTweenForm(proxy, path);
69 70 return new Tween(this, completer, form, duration, ease_type, control);
70 71 }
  72 +
  73 +Tween *Timeline::build_rgba_tween(IProxy<char,4> *proxy, ICompleter *completer,
  74 + int duration, Vector4c from, Vector4c to,
  75 + int ease_type, CycleControl *control) {
  76 + LinearRgbaForm *form = new LinearRgbaForm(proxy, from, to);
  77 + return new Tween(this, completer, form, duration, ease_type, control);
  78 +}
  79 +
12 src/Timeline.h
@@ -22,9 +22,10 @@ class Timeline : public IClock {
22 22 void unregister_ticker(ITicker *ticker);
23 23 void tick(Uint32 now);
24 24
25   - Tween *build_int_tween(IProxy<int,1> *proxy, ICompleter *completer,
26   - int duration, int from, int to, int ease_type,
27   - CycleControl *control);
  25 + Tween *build_int_tween(IProxy<int,1> *proxy, ICompleter *completer,
  26 + int duration, int from, int to, int ease_type,
  27 + CycleControl *control);
  28 +
28 29 Tween *build_float_tween(IProxy<float,1> *proxy, ICompleter *completer,
29 30 int duration, float from, float to, int ease_type,
30 31 CycleControl *control);
@@ -32,6 +33,11 @@ class Timeline : public IClock {
32 33 Tween *build_path_tween(IProxy<int,2> *proxy, ICompleter *completer,
33 34 int duration, IPath *path, int ease_type,
34 35 CycleControl *control);
  36 +
  37 + Tween *build_rgba_tween(IProxy<char,4> *proxy, ICompleter *completer,
  38 + int duration, Vector4c from, Vector4c to,
  39 + int ease_type, CycleControl *control);
  40 +
35 41 private:
36 42 std::set<ITicker*> tickers;
37 43
16 src/Vector.h
@@ -49,6 +49,7 @@ Vector<T,DIM> operator- (const Vector<T,DIM>& lhs, const Vector<T,DIM>& rhs) {
49 49 return res;
50 50 }
51 51
  52 +// * on int vector and float k to int vector
52 53 template<int DIM>
53 54 Vector<int,DIM> operator* (const Vector<int,DIM>& t, float k) {
54 55 Vector<int,DIM> res;
@@ -56,6 +57,7 @@ Vector<int,DIM> operator* (const Vector<int,DIM>& t, float k) {
56 57 return res;
57 58 }
58 59
  60 +// * on float vector and float k to float vector
59 61 template<int DIM>
60 62 Vector<float,DIM> operator* (const Vector<float,DIM>& t, float k) {
61 63 Vector<float,DIM> res;
@@ -63,6 +65,20 @@ Vector<float,DIM> operator* (const Vector<float,DIM>& t, float k) {
63 65 return res;
64 66 }
65 67
  68 +// * on char vector and float k
  69 +template<int DIM>
  70 +Vector<char,DIM> operator* (const Vector<char,DIM>& t, float k) {
  71 + Vector<char,DIM> res;
  72 + for (unsigned i=0; i<DIM; ++i) {
  73 + int v = (int) round(k * (float) t[i]);
  74 + res[i] = v > 255? 255:
  75 + v < 0? 0:
  76 + v;
  77 + }
  78 + return res;
  79 +}
  80 +
  81 +// * on float vector and int k to int vector
66 82 template<int DIM>
67 83 Vector<int,DIM> operator* (const Vector<float,DIM>& t, int k) {
68 84 Vector<int,DIM> res;
6 src/VectorTypes.h
@@ -4,9 +4,9 @@
4 4
5 5 #include "Vector.h"
6 6
7   -typedef Vector<int,1> Vector1i;
8   -typedef Vector<int,2> Vector2i;
9   -typedef Vector<int,4> Vector4i;
  7 +typedef Vector<int,1> Vector1i;
  8 +typedef Vector<int,2> Vector2i;
  9 +typedef Vector<char,4> Vector4c;
10 10
11 11 typedef Vector<float,1> Vector1f;
12 12 typedef Vector<float,2> Vector2f;

0 comments on commit 8207d93

Please sign in to comment.
Something went wrong with that request. Please try again.