Web Interface For Lite Argus Control modules
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

311 lines
9.6 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * VERSION: 0.2.2
  3. * DATE: 2018-05-30
  4. * UPDATES AND DOCS AT: http://greensock.com
  5. *
  6. * @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
  7. * This work is subject to the terms at http://greensock.com/standard-license or for
  8. * Club GreenSock members, the software agreement that was issued with your membership.
  9. *
  10. * @author: Jack Doyle, jack@greensock.com
  11. **/
  12. /* eslint-disable */
  13. import { _gsScope } from "./TweenLite.js";
  14. var _numExp = /(\d|\.)+/g,
  15. _ColorFilter, _ColorMatrixFilter,
  16. _colorProps = ["redMultiplier","greenMultiplier","blueMultiplier","alphaMultiplier","redOffset","greenOffset","blueOffset","alphaOffset"],
  17. _colorLookup = {aqua:[0,255,255],
  18. lime:[0,255,0],
  19. silver:[192,192,192],
  20. black:[0,0,0],
  21. maroon:[128,0,0],
  22. teal:[0,128,128],
  23. blue:[0,0,255],
  24. navy:[0,0,128],
  25. white:[255,255,255],
  26. fuchsia:[255,0,255],
  27. olive:[128,128,0],
  28. yellow:[255,255,0],
  29. orange:[255,165,0],
  30. gray:[128,128,128],
  31. purple:[128,0,128],
  32. green:[0,128,0],
  33. red:[255,0,0],
  34. pink:[255,192,203],
  35. cyan:[0,255,255],
  36. transparent:[255,255,255,0]},
  37. _parseColor = function(color) {
  38. if (color === "" || color == null || color === "none") {
  39. return _colorLookup.transparent;
  40. } else if (_colorLookup[color]) {
  41. return _colorLookup[color];
  42. } else if (typeof(color) === "number") {
  43. return [color >> 16, (color >> 8) & 255, color & 255];
  44. } else if (color.charAt(0) === "#") {
  45. if (color.length === 4) { //for shorthand like #9F0
  46. color = "#" + color.charAt(1) + color.charAt(1) + color.charAt(2) + color.charAt(2) + color.charAt(3) + color.charAt(3);
  47. }
  48. color = parseInt(color.substr(1), 16);
  49. return [color >> 16, (color >> 8) & 255, color & 255];
  50. }
  51. return color.match(_numExp) || _colorLookup.transparent;
  52. },
  53. _parseColorFilter = function(t, v, pg) {
  54. if (!_ColorFilter) {
  55. _ColorFilter = (_gsScope.ColorFilter || _gsScope.createjs.ColorFilter);
  56. if (!_ColorFilter) {
  57. throw("EaselPlugin error: The EaselJS ColorFilter JavaScript file wasn't loaded.");
  58. }
  59. }
  60. var filters = t.filters || [],
  61. i = filters.length,
  62. c, s, e, a, p;
  63. while (--i > -1) {
  64. if (filters[i] instanceof _ColorFilter) {
  65. s = filters[i];
  66. break;
  67. }
  68. }
  69. if (!s) {
  70. s = new _ColorFilter();
  71. filters.push(s);
  72. t.filters = filters;
  73. }
  74. e = s.clone();
  75. if (v.tint != null) {
  76. c = _parseColor(v.tint);
  77. a = (v.tintAmount != null) ? Number(v.tintAmount) : 1;
  78. e.redOffset = Number(c[0]) * a;
  79. e.greenOffset = Number(c[1]) * a;
  80. e.blueOffset = Number(c[2]) * a;
  81. e.redMultiplier = e.greenMultiplier = e.blueMultiplier = 1 - a;
  82. } else {
  83. for (p in v) {
  84. if (p !== "exposure") if (p !== "brightness") {
  85. e[p] = Number(v[p]);
  86. }
  87. }
  88. }
  89. if (v.exposure != null) {
  90. e.redOffset = e.greenOffset = e.blueOffset = 255 * (Number(v.exposure) - 1);
  91. e.redMultiplier = e.greenMultiplier = e.blueMultiplier = 1;
  92. } else if (v.brightness != null) {
  93. a = Number(v.brightness) - 1;
  94. e.redOffset = e.greenOffset = e.blueOffset = (a > 0) ? a * 255 : 0;
  95. e.redMultiplier = e.greenMultiplier = e.blueMultiplier = 1 - Math.abs(a);
  96. }
  97. i = 8;
  98. while (--i > -1) {
  99. p = _colorProps[i];
  100. if (s[p] !== e[p]) {
  101. pg._addTween(s, p, s[p], e[p], "easel_colorFilter");
  102. }
  103. }
  104. pg._overwriteProps.push("easel_colorFilter");
  105. if (!t.cacheID) {
  106. throw("EaselPlugin warning: for filters to display in EaselJS, you must call the object's cache() method first. " + t);
  107. }
  108. },
  109. _idMatrix = [1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],
  110. _lumR = 0.212671,
  111. _lumG = 0.715160,
  112. _lumB = 0.072169,
  113. _applyMatrix = function(m, m2) {
  114. if (!(m instanceof Array) || !(m2 instanceof Array)) {
  115. return m2;
  116. }
  117. var temp = [],
  118. i = 0,
  119. z = 0,
  120. y, x;
  121. for (y = 0; y < 4; y++) {
  122. for (x = 0; x < 5; x++) {
  123. z = (x === 4) ? m[i + 4] : 0;
  124. temp[i + x] = m[i] * m2[x] + m[i+1] * m2[x + 5] + m[i+2] * m2[x + 10] + m[i+3] * m2[x + 15] + z;
  125. }
  126. i += 5;
  127. }
  128. return temp;
  129. },
  130. _setSaturation = function(m, n) {
  131. if (isNaN(n)) {
  132. return m;
  133. }
  134. var inv = 1 - n,
  135. r = inv * _lumR,
  136. g = inv * _lumG,
  137. b = inv * _lumB;
  138. return _applyMatrix([r + n, g, b, 0, 0, r, g + n, b, 0, 0, r, g, b + n, 0, 0, 0, 0, 0, 1, 0], m);
  139. },
  140. _colorize = function(m, color, amount) {
  141. if (isNaN(amount)) {
  142. amount = 1;
  143. }
  144. var c = _parseColor(color),
  145. r = c[0] / 255,
  146. g = c[1] / 255,
  147. b = c[2] / 255,
  148. inv = 1 - amount;
  149. return _applyMatrix([inv + amount * r * _lumR, amount * r * _lumG, amount * r * _lumB, 0, 0, amount * g * _lumR, inv + amount * g * _lumG, amount * g * _lumB, 0, 0, amount * b * _lumR, amount * b * _lumG, inv + amount * b * _lumB, 0, 0, 0, 0, 0, 1, 0], m);
  150. },
  151. _setHue = function(m, n) {
  152. if (isNaN(n)) {
  153. return m;
  154. }
  155. n *= Math.PI / 180;
  156. var c = Math.cos(n),
  157. s = Math.sin(n);
  158. return _applyMatrix([(_lumR + (c * (1 - _lumR))) + (s * (-_lumR)), (_lumG + (c * (-_lumG))) + (s * (-_lumG)), (_lumB + (c * (-_lumB))) + (s * (1 - _lumB)), 0, 0, (_lumR + (c * (-_lumR))) + (s * 0.143), (_lumG + (c * (1 - _lumG))) + (s * 0.14), (_lumB + (c * (-_lumB))) + (s * -0.283), 0, 0, (_lumR + (c * (-_lumR))) + (s * (-(1 - _lumR))), (_lumG + (c * (-_lumG))) + (s * _lumG), (_lumB + (c * (1 - _lumB))) + (s * _lumB), 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], m);
  159. },
  160. _setContrast = function(m, n) {
  161. if (isNaN(n)) {
  162. return m;
  163. }
  164. n += 0.01;
  165. return _applyMatrix([n,0,0,0,128 * (1 - n), 0,n,0,0,128 * (1 - n), 0,0,n,0,128 * (1 - n), 0,0,0,1,0], m);
  166. },
  167. _parseColorMatrixFilter = function(t, v, pg) {
  168. if (!_ColorMatrixFilter) {
  169. _ColorMatrixFilter = (_gsScope.ColorMatrixFilter || _gsScope.createjs.ColorMatrixFilter);
  170. if (!_ColorMatrixFilter) {
  171. throw("EaselPlugin error: The EaselJS ColorMatrixFilter JavaScript file wasn't loaded.");
  172. }
  173. }
  174. var filters = t.filters || [],
  175. i = filters.length,
  176. matrix, startMatrix, s;
  177. while (--i > -1) {
  178. if (filters[i] instanceof _ColorMatrixFilter) {
  179. s = filters[i];
  180. break;
  181. }
  182. }
  183. if (!s) {
  184. s = new _ColorMatrixFilter(_idMatrix.slice());
  185. filters.push(s);
  186. t.filters = filters;
  187. }
  188. startMatrix = s.matrix;
  189. matrix = _idMatrix.slice();
  190. if (v.colorize != null) {
  191. matrix = _colorize(matrix, v.colorize, Number(v.colorizeAmount));
  192. }
  193. if (v.contrast != null) {
  194. matrix = _setContrast(matrix, Number(v.contrast));
  195. }
  196. if (v.hue != null) {
  197. matrix = _setHue(matrix, Number(v.hue));
  198. }
  199. if (v.saturation != null) {
  200. matrix = _setSaturation(matrix, Number(v.saturation));
  201. }
  202. i = matrix.length;
  203. while (--i > -1) {
  204. if (matrix[i] !== startMatrix[i]) {
  205. pg._addTween(startMatrix, i, startMatrix[i], matrix[i], "easel_colorMatrixFilter");
  206. }
  207. }
  208. pg._overwriteProps.push("easel_colorMatrixFilter");
  209. if (!t.cacheID) {
  210. throw("EaselPlugin warning: for filters to display in EaselJS, you must call the object's cache() method first. " + t);
  211. }
  212. pg._matrix = startMatrix;
  213. };
  214. var EaselPlugin = _gsScope._gsDefine.plugin({
  215. propName: "easel",
  216. priority: -1,
  217. version: "0.2.2",
  218. API: 2,
  219. //called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
  220. init: function(target, value, tween, index) {
  221. this._target = target;
  222. var p, pt, tint, colorMatrix, end, labels, i;
  223. for (p in value) {
  224. end = value[p];
  225. if (typeof(end) === "function") {
  226. end = end(index, target);
  227. }
  228. if (p === "colorFilter" || p === "tint" || p === "tintAmount" || p === "exposure" || p === "brightness") {
  229. if (!tint) {
  230. _parseColorFilter(target, value.colorFilter || value, this);
  231. tint = true;
  232. }
  233. } else if (p === "saturation" || p === "contrast" || p === "hue" || p === "colorize" || p === "colorizeAmount") {
  234. if (!colorMatrix) {
  235. _parseColorMatrixFilter(target, value.colorMatrixFilter || value, this);
  236. colorMatrix = true;
  237. }
  238. } else if (p === "frame") {
  239. this._firstPT = pt = {_next:this._firstPT, t:target, p:"gotoAndStop", s:target.currentFrame, f:true, n:"frame", pr:0, type:0, m:Math.round};
  240. if (typeof(end) === "string" && end.charAt(1) !== "=" && (labels = target.labels)) {
  241. for (i = 0; i < labels.length; i++) {
  242. if (labels[i].label === end) {
  243. end = labels[i].position;
  244. }
  245. }
  246. }
  247. pt.c = (typeof(end) === "number") ? end - pt.s : parseFloat((end+"").split("=").join(""));
  248. if (pt._next) {
  249. pt._next._prev = pt;
  250. }
  251. } else if (target[p] != null) {
  252. this._firstPT = pt = {_next:this._firstPT, t:target, p:p, f:(typeof(target[p]) === "function"), n:p, pr:0, type:0};
  253. pt.s = (!pt.f) ? parseFloat(target[p]) : target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]();
  254. pt.c = (typeof(end) === "number") ? end - pt.s : (typeof(end) === "string") ? parseFloat(end.split("=").join("")) : 0;
  255. if (pt._next) {
  256. pt._next._prev = pt;
  257. }
  258. }
  259. }
  260. return true;
  261. },
  262. //called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
  263. set: function(v) {
  264. var pt = this._firstPT,
  265. min = 0.000001,
  266. val;
  267. while (pt) {
  268. val = pt.c * v + pt.s;
  269. if (pt.m) {
  270. val = pt.m(val, pt.t);
  271. } else if (val < min && val > -min) {
  272. val = 0;
  273. }
  274. if (pt.f) {
  275. pt.t[pt.p](val);
  276. } else {
  277. pt.t[pt.p] = val;
  278. }
  279. pt = pt._next;
  280. }
  281. if (this._target.cacheID) {
  282. this._target.updateCache();
  283. }
  284. }
  285. });
  286. export { EaselPlugin, EaselPlugin as default };