Permalink
Browse files

fixed gradientarray()

  • Loading branch information...
1 parent 362ec7b commit 211d217321ba78a5869e0ba0defb22ae0f1e393c robert committed Oct 25, 2011
Showing with 8 additions and 15 deletions.
  1. +8 −15 jquery.xcolor.js
View
23 jquery.xcolor.js
@@ -1103,25 +1103,18 @@
return null;
};
- this["gradientarray"] = function (arr, ndx, size) {
+ this["gradientarray"] = function(arr, level, deg) {
- if (ndx > size) return null;
+ if (level > deg || !arr.length) return null;
- var e = (ndx * (arr.length - 1) / size)|0;
- var m = (ndx - size * e / (arr.length - 1)) / size;
-
- var a = new xColor(arr[e]);
- var b = new xColor(arr[e + 1]);
-
- if (a.success & b.success) {
+ if (arr.length == 1) {
+ return new xColor(arr[0]);
+ }
- a["r"] = (a["r"] + arr.length * (b["r"] - a["r"]) * m)|0;
- a["g"] = (a["g"] + arr.length * (b["g"] - a["g"]) * m)|0;
- a["b"] = (a["b"] + arr.length * (b["b"] - a["b"]) * m)|0;
+ var e = level * (arr.length - 1) / (deg + 1) | 0;
+ var step = deg / (arr.length - 1);
- return a;
- }
- return null;
+ return $["xcolor"]["gradientlevel"](arr[e], arr[e + 1], level - e * step, step);
};
this["nearestname"] = function (a) {

0 comments on commit 211d217

Please sign in to comment.