]> git.proxmox.com Git - sencha-touch.git/blob - src/src/draw/gradient/Gradient.js
import Sencha Touch 2.4.2 source
[sencha-touch.git] / src / src / draw / gradient / Gradient.js
1 /**
2 * @class Ext.draw.gradient.Gradient
3 *
4 * Creates a gradient.
5 */
6 Ext.define('Ext.draw.gradient.Gradient', {
7
8 isGradient: true,
9
10 config: {
11 /**
12 * @cfg {Array/Object} Defines the stops of the gradient.
13 */
14 stops: []
15 },
16
17 applyStops: function (newStops) {
18 var stops = [],
19 ln = newStops.length,
20 i, stop, color;
21
22 for (i = 0; i < ln; i++) {
23 stop = newStops[i];
24 color = Ext.draw.Color.fly(stop.color || 'none');
25 stops.push({
26 offset: Math.min(1, Math.max(0, 'offset' in stop ? stop.offset : stop.position || 0)),
27 color: color.toString()
28 });
29 }
30 stops.sort(function (a, b) {
31 return a.offset - b.offset;
32 });
33 return stops;
34 },
35
36 onClassExtended: function (subClass, member) {
37 if (!member.alias && member.type) {
38 member.alias = 'gradient.' + member.type;
39 }
40 },
41
42 constructor: function (config) {
43 this.initConfig(config);
44 },
45
46 /**
47 * @protected
48 * Generates the gradient for the given context.
49 * @param {Ext.draw.engine.SvgContext} ctx The context.
50 * @param {Object} bbox
51 * @return {Object}
52 */
53 generateGradient: Ext.emptyFn
54
55 });