Parses gradient definition into an object.
This object can be used to transform gradient into various
forms
@param  {String} gradient Gradient definition
@return {LinearGradient}
773939
function(gradient) {
			// cut out all redundant data
			if (this.isLinearGradient(gradient)) {
				gradient = gradient.replace(/^\s*[\-a-z]+\s*\(|\)\s*$/ig, '');
			} else {
				throw 'Invalid linear gradient definition:\n' + gradient;
			}

			return new LinearGradient(gradient);
		}
220761
function(editor, syntax, profile) {
			var info = editorUtils.outputInfo(editor, syntax, profile);
			if (!~cssSyntaxes.indexOf(info.syntax)) {
				return false;
			}
			
			// let's see if we are expanding gradient definition
			var caret = editor.getCaretPos();
			var content = info.content;
			var gradients = this.gradientsFromCSSProperty(content, caret);
			if (gradients) {
				if (!isValidCaretPosition(gradients, caret, info.syntax)) {
					return false;
				}

				var cssProperty = gradients.property;
				var cssRule = cssProperty.parent;
				var ruleStart = cssRule.options.offset || 0;
				var ruleEnd = ruleStart + cssRule.toString().length;
				
				// Handle special case:
				// user wrote gradient definition between existing CSS 
				// properties and did not finished it with semicolon.
				// In this case, we have semicolon right after gradient 
				// definition and re-parse rule again
				if (/[\n\r]/.test(cssProperty.value())) {
					// insert semicolon at the end of gradient definition
					var insertPos = cssProperty.valueRange(true).start + utils.last(gradients.gradients).matchedPart.end;
					content = utils.replaceSubstring(content, ';', insertPos);
					
					var _gradients = this.gradientsFromCSSProperty(content, caret);
					if (_gradients) {
						gradients = _gradients;
						cssProperty = gradients.property;
						cssRule = cssProperty.parent;
					}
				}
				
				// make sure current property has terminating semicolon
				cssProperty.end(';');
				
				// resolve CSS property name
				var resolvedName = resolvePropertyName(cssProperty.name(), syntax);
				if (resolvedName) {
					cssProperty.name(resolvedName);
				}
				
				pasteGradient(cssProperty, gradients.gradients);
				editor.replaceContent(cssRule.toString(), ruleStart, ruleEnd, true);
				return true;
			}
			
			return this.expandGradientOutsideValue(editor, syntax);
		}
453022
function getDirection(gradient) {
    var segs;
    var angle;
    var result = {};

    if (gradient.sideCorner) {
        segs = gradient.sideCorner.split(/\s+/);

        var to = segs[0] === 'to';
        if (to) {
            // sideCorner starts with "to" so we shift it off since we don't
            // need this element anymore, and continue with generating the
            // gradient in the normal direction.
            segs.shift();
        } else {
            // sideCorner does not start with "to", so we need to reverse the
            // direction.
            var reverseDirections = {
                top: 'bottom',
                bottom: 'top',
                left: 'right',
                right: 'left'
            };
            segs[0] = reverseDirections[segs[0]];
        }

        result.direction = segs[0];
        // side corner is  `top right` or `bottom left` etc.
        if (segs.length > 1) {
            // fallback to one direction
            result.isFallback = true;
            result.message =
                'IE filter doesn\'t support side corner gradient, ' +
                'we use the first side of the side corner as fallback.';
        }
    } else {
        angle = normalizeAngle(gradient.angle.value, gradient.angle.unit);
        result = angleToDirection(angle);
    }

    return result;
}
409454
function(gradient) {
					if (cache[gradient]) {
						return cache[gradient];
					}
					var parts = gradient.match(/^(\b|\B-[a-z]{1,10}-)((?:repeating-)?(?:linear|radial)-gradient)/);
					// "", "-moz-", etc.
					var prefix = parts && parts[1];
					// "linear-gradient", "radial-gradient", etc.
					var func = parts && parts[2];

					var values = gradient.replace(/^(?:\b|\B-[a-z]{1,10}-)(?:repeating-)?(?:linear|radial)-gradient\(|\)$/g, '').split(/\s*,\s*/);

					if (func.indexOf('linear') >= 0) {
						return cache[gradient] = convertToW3CLinearGradient(prefix, func, values);
					} else if (func.indexOf('radial') >= 0) {
						return cache[gradient] = convertToW3CRadialGradient(prefix, func, values);
					}
					return cache[gradient] = func + '(' + values.join(',') + ')';
				}
610917
def linear_gradient(start_hex, finish_hex, n=10):
    
    s = hex2rgb(start_hex)
    f = hex2rgb(finish_hex)
    gradient = [s]
    for t in range(1, n):
        curr_vector = [int(s[j] + (float(t)/(n-1))*(f[j]-s[j])) for j in range(3)]
        gradient.append(curr_vector)
    return [rgb2hex([c/255. for c in rgb]) for rgb in gradient]
1041459
def gradient(self):
        """"""
        result = np.zeros((self.numc, 3), float)
        for index1 in range(self.numc):
            result[index1] = self.gradient_component(index1)
        return result
1004667
function plugin() {
  return function(style){
    style.include(__dirname);

    if (Canvas) {
      style.define('has-canvas', nodes.true);

      // gradients
      style.define('create-gradient-image', gradient.create);
      style.define('gradient-data-uri', gradient.dataURL);
      style.define('add-color-stop', gradient.addColorStop);

      // color images
      style.define('create-color-image', colorImage.create);
      style.define('color-data-uri', colorImage.dataURL);
    } else {
      style.define('has-canvas', nodes.false);
    }
  };
}
563922
def as_gradient(self, name=None, style=None, rgb_mode=False):
        
        return self._as_gradient(
            ('wrapper', ),
            name=name,
            style=style,
            rgb_mode=rgb_mode,
        )
1038034
def parse(node)
      node.xpath('*').each do |node_child|
        case node_child.name
        when 'gsLst'
          node_child.xpath('*').each do |gradient_stop_node|
            @gradient_stops << GradientStop.new(parent: self).parse(gradient_stop_node)
          end
        when 'path'
          @path = node_child.attribute('path').value.to_sym
        when 'lin'
          @linear_gradient = LinearGradient.new(parent: self).parse(node_child)
        end
      end
      self
    end
954687
function normalize(property, value, prefix){
  var result = value.toString(),
      args;

  /* Fixing the gradients */
  if (~result.indexOf('gradient(')) {

    /* Normalize color stops */
    result = result.replace(RE_GRADIENT_STOPS,'$1$4$3$2');

    /* Normalize legacy gradients */
    result = result.replace(RE_GRADIENT_VAL, function(){
        args = [].slice.call(arguments, 1);
        return normalizeGradient(args, prefix);
    });

    /* Adding prefixes to the legacy gradients */
    if (prefix) result = result.replace(RE_GRADIENT_TYPE, '-' + prefix + '-$1');
  }

  /* Adding prefixes to the `transform` values of legacy `transition` property */
  if (prefix && (property == "'transition'" || property == "'transition-property'")) {
    result = result.replace(RE_TRANSFORM, '-' + prefix + '-$1');
  }

  /* Removing `fill` keyword from the legacy `border-image` property */
  if (prefix && (property == "'border-image'" || property == "'border-image-slice'")) {
    result = result.replace(RE_FILL_KEYWORD, ' ');
  }

  return result;
}
232860
function regularizeNone(weights, gradientCount) {
  const [gradient, count] = gradientCount;

  for (let i = 0; i < gradient.length; i++) {
    let grad = (gradient[i] || 0) / count;
    weights[i] = (weights[i] || 0) - grad;
  }
}
397363
function parse(styles) {
  styles = (styles || '').trim();

  if (!styles) return {};

  return styles
    .split(';')
    .reduce(function(obj, str){
      var n = str.indexOf(':');
      // skip if there is no :, or if it is the first/last character
      if (n < 1 || n === str.length-1) return obj;
      obj[str.slice(0,n).trim()] = str.slice(n+1).trim();
      return obj;
    }, {});
}
324877
def gradient(self):
        
        functional = self

        if self.exponent == 1:
            class L1Gradient(Operator):

                """The gradient operator of this functional."""

                def __init__(self):
                    """Initialize a new instance."""
                    super(L1Gradient, self).__init__(
                        functional.domain, functional.domain, linear=False)

                def _call(self, x):
                    """Apply the gradient operator to the given point."""
                    return x.ufuncs.sign()

                def derivative(self, x):
                    """Derivative is a.e. zero."""
                    return ZeroOperator(self.domain)

            return L1Gradient()

        elif self.exponent == 2:
            class L2Gradient(Operator):

                """The gradient operator of this functional."""

                def __init__(self):
                    """Initialize a new instance."""
                    super(L2Gradient, self).__init__(
                        functional.domain, functional.domain, linear=False)

                def _call(self, x):
                    """Apply the gradient operator to the given point.

                    The gradient is not defined in 0.
                    """
                    norm_of_x = x.norm()
                    if norm_of_x == 0:
                        return self.domain.zero()
                    else:
                        return x / norm_of_x

            return L2Gradient()

        else:
            raise NotImplementedError('`gradient` only implemented for p=1 '
                                      'and p=2')
790159
function setGradient(element, startColor, endColor) {
    var start = startColor.toCSS(),
      end   = endColor.toCSS(),
      styles = window.getComputedStyle(document.documentElement, ''), 
      prefix = (Array.prototype.slice.call(styles).join('').match(/-(moz|webkit|ms)-/) || (styles.OLink === '' && ['', 'o']))[1];
      
    element.css('background-image', '-'+prefix+'-linear-gradient(left, '+start+' 0%, '+end+' 100%)');
  }
1370946
public void copyTo(Gradient g) {
		g.numKnots = numKnots;
		g.map = (int[])map.clone();
		g.xKnots = (int[])xKnots.clone();
		g.yKnots = (int[])yKnots.clone();
		g.knotTypes = (byte[])knotTypes.clone();
	}
1131926
def gradient(self):
        """"""

        # First we store the functional in a variable
        functional = self

        # The class corresponding to the gradient operator.
        class MyGradientOperator(odl.Operator):

            """Class implementing the gradient operator."""

            def __init__(self):
                """Initialize a new instance."""
                super(MyGradientOperator, self).__init__(
                    domain=functional.domain, range=functional.domain)

            def _call(self, x):
                """Evaluate the gradient."""
                # Here we can access the store functional from a few lines
                # above
                return 2.0 * x + functional.y

        return MyGradientOperator()
16569
function getColourAt(gradient, p) {
  p = clamp(p, 0, 0.9999);  // FIXME
  let r = Math.floor(p * (gradient.length - 1));
  let q = p * (gradient.length - 1) - r;
  return Colour.mix(gradient[r + 1], gradient[r], q);
}