Copies fill styles from the specified style object to the canvas context.
321866
function(g, options) {
        var compositeOperation = options.compositeOperation
                || options.composition || 'source-over';
        g.globalCompositeOperation = compositeOperation;// 
        g.fillStyle = options.fillColor || options.color;
        if (options.fillImage) {
            g.fillStyle = g.createPattern(options.fillImage, "repeat");
        }
        g.globalAlpha = options.fillOpacity || options.opacity || 0;
    }
1155125
function setStyle(element, styles) {
    var elementStyle = element.style, match;
    if (!elementStyle) {
      return element;
    }
    if (typeof styles === 'string') {
      element.style.cssText += ';' + styles;
      return styles.indexOf('opacity') > -1
        ? setOpacity(element, styles.match(/opacity:\s*(\d?\.?\d*)/)[1])
        : element;
    }
    for (var property in styles) {
      if (property === 'opacity') {
        setOpacity(element, styles[property]);
      }
      else {
        var normalizedProperty = (property === 'float' || property === 'cssFloat')
          ? (typeof elementStyle.styleFloat === 'undefined' ? 'cssFloat' : 'styleFloat')
          : property;
        elementStyle[normalizedProperty] = styles[property];
      }
    }
    return element;
  }
1057879
function(context, geometry, style, featureId, type) {
        var components = geometry.components;
        var len = components.length;
        context.beginPath();
        var start = this.getLocalXY(components[0]);
        var x = start[0];
        var y = start[1];
        if (!isNaN(x) && !isNaN(y)) {
            context.moveTo(start[0], start[1]);
            for (var i=1; i<len; ++i) {
                var pt = this.getLocalXY(components[i]);
                context.lineTo(pt[0], pt[1]);
            }
            if (type === "fill") {
                context.fill();
            } else {
                context.stroke();
            }
        }
    }
42567
function (col, opaque) {
            this.save();
            this.resetTransform();
            this.currentColor.copy(col);
            if (opaque) {
                this.compositor.clear();
            }
            else {
                this.fillRect(0, 0, this.canvas.width, this.canvas.height);
            }
            this.restore();
        }
814179
function (ctx, scale, layers, styles, zoom, minX, maxX, minY) {
  // background first
  styles.forEach(function(style) {
    if (cartoSelectorIsMatch(style, null, null, zoom)) {
      style.rules.forEach(function(rule) {
        if (rule.name === "background-color") {
          ctx.fillStyle = rule.value.toString();
        }
        else if (rule.name === "background-image") {
          if (!(rule.value instanceof Canvas.Image)) {
            var content = rule.value.toString();
            var img = new Canvas.Image();
            var imagePath = path.normalize(__dirname + "/../static/images/" + content);
            img.src = fs.readFileSync(imagePath);
            rule.value = img;
          }
        
          img = rule.value;
          ctx.fillStyle = ctx.createPattern(img, "repeat");
        }
      });
      ctx.fillRect(0,0,ctx.canvas.width, ctx.canvas.height);
    }
  });
  
  // create list of attachments (in order) so that we can walk through and render them together for each layer
  // TODO: should be able to do this as part of the processing stage
  var attachments = styles.reduce(function(attachmentList, style) {
    if (style.attachment !== "__default__" && attachmentList.indexOf(style.attachment) === -1) {
      attachmentList.push(style.attachment);
    }
    return attachmentList;
  }, []);
  attachments.push("__default__");
  
  layers.forEach(function(layer, i) {
    var source = layer.source;
    var features = layer.features || layer;
    
    attachments.forEach(function(attachment) {
      
      features.forEach(function(feature) {
        // get all the drawing rules for this attachment and feature
        var collapsedStyle = {};
        var instanceOrder = [];
        styles.forEach(function(style) {
          if (style.attachment === attachment && cartoSelectorIsMatch(style, feature, source, zoom)) {
            style.rules.forEach(function(rule) {
              if (!collapsedStyle[rule.instance]) {
                collapsedStyle[rule.instance] = {};
                instanceOrder.push(rule.instance);
              }
              if (!collapsedStyle[rule.instance].hasOwnProperty(rule.name)) {
                collapsedStyle[rule.instance][rule.name] = rule.value;
              }
            });
          }
        });
        
        var renderInstance = function(instanceName) {
          var instanceStyle = collapsedStyle[instanceName];
          
          ctx.save();
  
          var shouldFill = false,
              shouldStroke = false,
              shouldMark = false,
              shouldPoint = false,
              shouldText = false,
              dashedStroke = false;
          for (var key in instanceStyle) {
            var rawValue = instanceStyle[key],
                value = rawValue.toString();
            
            if (key === "background-color" || key === "polygon-fill") {
              ctx.fillStyle = value;
              shouldFill = true;
            }
            else if (key === "background-image" || key === "polygon-pattern-file") {
              if (rawValue) {
                ctx.fillStyle = ctx.createPattern(rawValue, "repeat");
                shouldFill = true;
              }
            }
            else if (key === "line-width") {
              ctx.lineWidth = parseInt(value);
            }
            else if (key === "line-color") {
              ctx.strokeStyle = value;
              shouldStroke = true;
            }
            else if (key === "line-opacity") {
              // handled at stroke time below
            }
            else if (key === "line-join") {
              ctx.lineJoin = value;
            }
            else if (key === "line-cap") {
              ctx.lineCap = value;
            }
            else if (key === "line-miterlimit") {
              ctx.miterLimit = value;
            }
            else if (key === "line-dasharray") {
              // TODO: dasharray support
              // console.log("Dasharray: ", value);
              var dashedStroke = value.split(",").map(parseFloat);
              // console.log("    now: ", dashArray);
              // ctx.dash = dashArray;
              // ctx.lineDash = dashArray;
            }
            else if (key === "polygon-opacity") {
              // handled at fill time below
            }
            else if (key === "line-pattern-file") {
              if (rawValue) {
                ctx.strokeStyle = ctx.createPattern(rawValue, "repeat");
                shouldStroke = true;
              }
            }
            else if (key.indexOf("marker") === 0) {
              shouldMark = true;
            }
            else if (key === "point-file") {
              shouldPoint = true;
            }
            else if (key === "text-name") {
              shouldText = true;
            }
          }
          
          if (shouldFill || shouldStroke || shouldMark || shouldPoint || shouldText) {
            ctx.beginPath();
            var shape = feature.geometry || feature;
            var coordinates = shape.coordinates;
            renderPath[shape.type].call(ctx, coordinates, scale);
            if (shouldFill) {
              ctx.globalAlpha = parseFloat(instanceStyle["polygon-opacity"]) || 1.0;
              var fillColor = instanceStyle["polygon-fill"];
              var fillPattern = instanceStyle["polygon-pattern-file"]
              if (fillColor) {
                ctx.fillStyle = fillColor.toString();
                ctx.fill();
              }
              if (fillPattern) {
                ctx.fillStyle = ctx.createPattern(fillPattern, "repeat");;
                ctx.fill();
              }
            }
            if (shouldStroke) {
              ctx.globalAlpha = parseFloat(instanceStyle["line-opacity"]) || 1.0;
              if (dashedStroke) {
                // since canvas doesn't yet have dashed line support, we have to draw a dashed path :(
                ctx.closePath();
                ctx.beginPath();
                renderDashedPath[shape.type].call(ctx, dashedStroke, coordinates);
              }
              ctx.stroke();
            }
            ctx.closePath();
            
            if (shouldMark) {
              if (instanceStyle["marker-file"]) {
                renderImage[shape.type].call(ctx, instanceStyle["marker-file"], coordinates);
              }
              else {
                // we only support the "ellipse" type
                // we only support circles, not ellipses right now :\
                var radius = instanceStyle["marker-width"] || instanceStyle["marker-height"];
                radius = (radius ? radius.value : 10) / 2;

                var shouldFillMarker = false;
                var shouldStrokeMarker = false;
                if (instanceStyle["marker-fill"]) {
                  ctx.fillStyle = instanceStyle["marker-fill"].toString();
                  shouldFillMarker = true;
                }
                if (instanceStyle["marker-line-color"]) {
                  ctx.strokeStyle = instanceStyle["marker-line-color"].toString();
                  shouldStrokeMarker = true;
                }
                if (instanceStyle["marker-line-width"]) {
                  var lineWidth = instanceStyle["marker-line-width"].value;
                  ctx.lineWidth = lineWidth;
                  shouldStrokeMarker = !!lineWidth;
                }
                
                ctx.beginPath();
                renderDot[shape.type].call(ctx, radius, coordinates);
                if (shouldFillMarker) {
                  ctx.fill();
                }
                if (shouldStrokeMarker) {
                  ctx.stroke();
                }
                ctx.closePath();
              }
            }
            
            if (shouldPoint && instanceStyle["point-file"]) {
              renderImage[shape.type].call(ctx, instanceStyle["point-file"], coordinates);
            }
            
            if (shouldText) {
              var text = instanceStyle["text-name"];
              if (text.is === "propertyLookup") {
                text = text.toString(feature);
              }
              
              if (text) {
                var textSize = (instanceStyle["text-size"] || "10").toString();
                var textFace = (instanceStyle["text-face-name"] || "sans-serif").toString();
                ctx.font = textSize + "px '" + textFace + "'";
                
                var textInfo = {
                  text: text
                };
                
                // offsetting
                textInfo.offset = {
                  x: instanceStyle["text-dx"] ? instanceStyle["text-dx"].value : 0,
                  y: instanceStyle["text-dy"] ? instanceStyle["text-dy"].value : 0
                };
                
                // vertical alignment
                var verticalAlign = instanceStyle["text-vertical-alignment"];
                if (verticalAlign && verticalAlign.value !== "auto") {
                  ctx.textBaseline = {
                    top: "top",
                    middle: "middle",
                    bottom: "alphabetic"
                  }[verticalAlign];
                }
                else {
                  ctx.textBaseline = textInfo.offset.y === 0 ? "middle" : (textInfo.offset.y < 0 ? "top" : "alphabetic");
                }
                
                // horizontal alignment
                var textHorizontalAlignment = instanceStyle["text-horizontal-alignment"];
                if (textHorizontalAlignment) {
                  ctx.textAlign = textHorizontalAlignment.toString();
                }
                else {
                  // default to center
                  ctx.textAlign = "center";
                }
                textInfo.align = ctx.textAlign;
                
                // text-transform
                var textTransform = instanceStyle["text-transform"];
                textTransform = textTransform && textTransform.toString();
                if (textTransform === "uppercase") {
                  textInfo.text = text.toUpperCase();
                }
                if (textTransform === "lowercase") {
                  textInfo.text = text.toLowerCase();
                }
                if (textTransform === "capitalize") {
                  textInfo.text = text.replace(/\b(\w)/g, function(match, character) {
                    return character.toUpperCase();
                  });
                }
                
                // text-placement
                var placement = instanceStyle["text-placement"];
                textInfo.placement = placement ? placement.toString() : "point";
                
                // TODO: text-placement-type (currently like "dummy")
                // TODO: text-align (this is alignment within the text *box*)
                // We don't have anything that generates a box right now, so we dont' support this
                
                if (instanceStyle["text-halo-fill"]) {
                  ctx.strokeStyle = instanceStyle["text-halo-fill"].toString();
                  if (instanceStyle["text-halo-radius"]) {
                    ctx.lineWidth = instanceStyle["text-halo-radius"].value * 2;
                  }
                  
                  // definitely DON'T leave this set to miter :P
                  ctx.lineJoin = "round";
                  textInfo.stroke = true;
                  renderText[shape.type].call(ctx, textInfo, coordinates);
                }
              
                if (instanceStyle["text-fill"]) {
                  ctx.fillStyle = instanceStyle["text-fill"].toString();
                }
                
                textInfo.stroke = false;
                renderText[shape.type].call(ctx, textInfo, coordinates);
              }
            }
          }
          
          ctx.restore();
        };
      
        instanceOrder.forEach(function(instanceName) {
          if (instanceName !== "__default__") {
            renderInstance(instanceName);
          }
        });
      
        if (collapsedStyle["__default__"]) {
          renderInstance("__default__");
        }
      
      });
      
    });
  });
}
199166
function drawToContext(){
      startTime = +new Date;
      var nodes = r.getCachedNodes(); var edges = r.getCachedEdges();
      var coreStyle = cy.style()._private.coreStyle;
      
      // if( !forcedContext ){
      //   r.matchCanvasSize(data.container);
      // }

      var zoom = cy.zoom();
      var effectiveZoom = forcedZoom !== undefined ? forcedZoom : zoom;
      var pan = cy.pan();
      var effectivePan = {
        x: pan.x,
        y: pan.y
      };

      if( forcedPan ){
        effectivePan = forcedPan;
      }

      // apply pixel ratio

      effectiveZoom *= pixelRatio;
      effectivePan.x *= pixelRatio;
      effectivePan.y *= pixelRatio;
      
      var eles = {
        drag: {
          nodes: [],
          edges: []
        },
        nondrag: {
          nodes: [],
          edges: []
        }
      };

      function setContextTransform(context, clear){
        context.setTransform(1, 0, 0, 1, 0, 0);
        !forcedContext && (clear === undefined || clear) && context.clearRect(0, 0, r.canvasWidth, r.canvasHeight);
        
        if( !drawAllLayers ){
          context.translate(effectivePan.x, effectivePan.y);
          context.scale(effectiveZoom, effectiveZoom);
        }
        if( forcedPan ){
          context.translate(forcedPan.x, forcedPan.y);
        } 
        if( forcedZoom ){
          context.scale(forcedZoom, forcedZoom);
        }
      }

      var textureDraw = r.textureOnViewport && !forcedContext && (r.pinching || r.hoverData.dragging || r.swipePanning || r.data.wheelZooming);
      var scale;

      if( textureDraw ){

        var bb;

        if( !r.textureCache ){
          r.textureCache = {};

          bb = r.textureCache.bb = cy.boundingBox();

          var canvas = r.textureCache.texture = r.data.bufferCanvases[0];

          var cxt = canvas.getContext('2d');

          cxt.setTransform(1, 0, 0, 1, 0, 0);
          cxt.clearRect(0, 0, r.canvasWidth, r.canvasHeight);
          
          r.redraw({
            forcedContext: cxt,
            drawOnlyNodeLayer: true
          });

          var vp = r.textureCache.viewport = {
            zoom: cy.zoom(),
            pan: cy.pan(),
            width: r.canvasWidth,
            height: r.canvasHeight
          };

          vp.mpan = {
            x: (0 - vp.pan.x)/vp.zoom,
            y: (0 - vp.pan.y)/vp.zoom
          };
        }

        needDraw[CanvasRenderer.DRAG] = false;
        needDraw[CanvasRenderer.NODE] = false;

        var context = data.canvases[CanvasRenderer.NODE].getContext('2d');

        var texture = r.textureCache.texture;
        var z = cy.zoom();
        var p = cy.pan();
        var buffCanvas = r.textureCache.buffCanvas;
        var buffCxt = r.textureCache.buffCxt;
        var texture = r.textureCache.texture;
        var vp = r.textureCache.viewport;
        bb = r.textureCache.bb;

        context.setTransform(1, 0, 0, 1, 0, 0);
        context.clearRect(0, 0, vp.width, vp.height);

        var outsideBgColor = coreStyle['outside-texture-bg-color'].value;
        var outsideBgOpacity = coreStyle['outside-texture-bg-opacity'].value;
        r.fillStyle( context, outsideBgColor[0], outsideBgColor[1], outsideBgColor[2], outsideBgOpacity );
        context.fillRect( 0, 0, vp.width, vp.height );

        var pan = cy.pan();
        var zoom = cy.zoom();
        
        setContextTransform( context, false );

        context.clearRect( vp.mpan.x, vp.mpan.y, vp.width/vp.zoom/pixelRatio, vp.height/vp.zoom/pixelRatio );
        context.drawImage( texture, vp.mpan.x, vp.mpan.y, vp.width/vp.zoom/pixelRatio, vp.height/vp.zoom/pixelRatio );

      } else if( !forcedContext ){ // clear the cache since we don't need it
        r.textureCache = null;
      }

      var vpManip = (r.pinching || r.hoverData.dragging || r.swipePanning || r.data.wheelZooming || r.hoverData.draggingEles);
      var hideEdges = r.hideEdgesOnViewport && vpManip;
      var hideLabels = r.hideLabelsOnViewport && vpManip;

      if (needDraw[CanvasRenderer.DRAG] || needDraw[CanvasRenderer.NODE] || drawAllLayers || drawOnlyNodeLayer) {
        //NB : VERY EXPENSIVE
        //console.time('edgectlpts'); for( var looper = 0; looper <= looperMax; looper++ ){

        if( hideEdges ){ 
        } else {
          r.findEdgeControlPoints(edges);
        }

        //} console.timeEnd('edgectlpts')

        // console.time('sort'); for( var looper = 0; looper <= looperMax; looper++ ){
        var zEles = r.getCachedZSortedEles();
        // } console.timeEnd('sort')

        for (var i = 0; i < zEles.length; i++) {
          var ele = zEles[i];
          var list;

          if ( ele._private.rscratch.inDragLayer ) {
            list = eles.drag;
          } else {
            list = eles.nondrag;
          }

          list[ ele._private.group ].push( ele );
        }

        // console.time('updatecompounds'); for( var looper = 0; looper <= looperMax; looper++ ){
        // no need to update graph if there is no compound node
        // if ( cy.hasCompoundNodes() )
        // {
        //   r.updateAllCompounds(elements);
        // }
        // } console.timeEnd('updatecompounds')
      }
      
      
      function drawElements( list, context ){
        var edges = list.edges;
        var nodes = list.nodes;

        for (var i = 0; i < edges.length && !hideEdges; i++) {
          ele = edges[i];
          
          r.drawEdge(context, ele);
        }

        for (var i = 0; i < edges.length && !hideEdges && !hideLabels; i++) {
          ele = edges[i];
          
          r.drawEdgeText(context, ele);
        }

        for (var i = 0; i < edges.length && !hideEdges; i++) {
          ele = edges[i];
          
          r.drawEdge(context, ele, true);
        }

        for( var i = 0; i < nodes.length; i++ ){
          var ele = nodes[i];

          r.drawNode(context, ele);
          
          if( !hideLabels ){
            r.drawNodeText(context, ele);
          }
          
          r.drawNode(context, ele, true);
        }

      }


      // console.time('drawing'); for( var looper = 0; looper <= looperMax; looper++ ){
      if (needDraw[CanvasRenderer.NODE] || drawAllLayers || drawOnlyNodeLayer) {
        // console.log('redrawing node layer');
        
        var context = forcedContext || data.canvases[CanvasRenderer.NODE].getContext('2d');

        setContextTransform( context );
        drawElements(eles.nondrag, context);
        
        if( !drawAllLayers ){
          needDraw[CanvasRenderer.NODE] = false; 
        }
      }
      
      if ( !drawOnlyNodeLayer && (needDraw[CanvasRenderer.DRAG] || drawAllLayers) ) {
        
        var context = forcedContext || data.canvases[CanvasRenderer.DRAG].getContext('2d');
        
        setContextTransform( context );
        drawElements(eles.drag, context);
        
        if( !drawAllLayers ){
          needDraw[CanvasRenderer.DRAG] = false;
        }
      }
      
      if ( !drawOnlyNodeLayer && (needDraw[CanvasRenderer.SELECT_BOX] && !drawAllLayers) ) {
        // console.log('redrawing selection box');
        
        var context = forcedContext || data.canvases[CanvasRenderer.SELECT_BOX].getContext('2d');
        
        setContextTransform( context );

        if (data.select[4] == 1) {
          var zoom = data.cy.zoom();
          var borderWidth = coreStyle['selection-box-border-width'].value / zoom;
          
          context.lineWidth = borderWidth;
          context.fillStyle = "rgba(" 
            + coreStyle['selection-box-color'].value[0] + ","
            + coreStyle['selection-box-color'].value[1] + ","
            + coreStyle['selection-box-color'].value[2] + ","
            + coreStyle['selection-box-opacity'].value + ")";
          
          context.fillRect(
            data.select[0],
            data.select[1],
            data.select[2] - data.select[0],
            data.select[3] - data.select[1]);
          
          if (borderWidth > 0) {
            context.strokeStyle = "rgba(" 
              + coreStyle['selection-box-border-color'].value[0] + ","
              + coreStyle['selection-box-border-color'].value[1] + ","
              + coreStyle['selection-box-border-color'].value[2] + ","
              + coreStyle['selection-box-opacity'].value + ")";
            
            context.strokeRect(
              data.select[0],
              data.select[1],
              data.select[2] - data.select[0],
              data.select[3] - data.select[1]);
          }
        }

        if( data.bgActivePosistion ){
          var zoom = data.cy.zoom();
          var pos = data.bgActivePosistion;

          context.fillStyle = "rgba(" 
            + coreStyle['active-bg-color'].value[0] + ","
            + coreStyle['active-bg-color'].value[1] + ","
            + coreStyle['active-bg-color'].value[2] + ","
            + coreStyle['active-bg-opacity'].value + ")";

          context.beginPath();
          context.arc(pos.x, pos.y, coreStyle['active-bg-size'].pxValue / zoom, 0, 2 * Math.PI); 
          context.fill();
        }
        
        if( !drawAllLayers ){
          needDraw[CanvasRenderer.SELECT_BOX] = false; 
        }
      }

      // } console.timeEnd('drawing')

      var endTime = +new Date;

      if( r.averageRedrawTime === undefined ){
        r.averageRedrawTime = endTime - startTime;
      }

      if( r.redrawCount === undefined ){
        r.redrawCount = 0;
      }

      r.redrawCount++;

      if( r.redrawTotalTime === undefined ){
        r.redrawTotalTime = 0;
      }

      r.redrawTotalTime += endTime - startTime;

      // use a weighted average with a bias from the previous average so we don't spike so easily
      r.averageRedrawTime = r.averageRedrawTime/2 + (endTime - startTime)/2;
      //console.log('actual: %i, average: %i', endTime - startTime, this.averageRedrawTime);

      r.currentlyDrawing = false;
    }
1248921
def set_style(self, style):
        
        style = SolarizedStyle  # get_style_by_name(style)
        self._style = style
        self._clear_caches()
45000
def copy_style(shapefile_path):
        
        source_qml_path = resources_path('petabencana', 'flood-style.qml')
        output_qml_path = shapefile_path.replace('shp', 'qml')
        LOGGER.info('Copying qml to: %s' % output_qml_path)
        copy(source_qml_path, output_qml_path)
70348
function iterateStyleRules(argument) {
      if (typeof argument === 'string') {
        checkStyleExistence(styleDefinitions, argument);

        collectedStyles.push(styleDefinitions[argument]);
        return;
      }

      if (typeof argument === 'object') {
        Object.keys(argument).forEach(function(styleName) {
          checkStyleExistence(styleDefinitions, styleName);

          if (argument[styleName]) {
            collectedStyles.push(styleDefinitions[styleName])
          }
        })
      }
    }
565474
function (col, opaque) {
            this.save();
            this.resetTransform();
            this.backBufferContext2D.globalCompositeOperation = opaque ? "copy" : "source-over";
            this.backBufferContext2D.fillStyle = (col instanceof me.Color) ? col.toRGBA() : col;
            this.fillRect(0, 0, this.backBufferCanvas.width, this.backBufferCanvas.height);
            this.restore();
        }
261918
function(styles) {

	var computedStyles = document.defaultView.getComputedStyle(this._node),
		i,
		eachStyle,
		cssMap = {}

	// String case, just return the correct style
	if (typeof styles == "string") {
		return computedStyles[styles]
	}

	for (i=0; eachStyle = styles[i]; i++) {
		cssMap[eachStyle] = computedStyles[eachStyle]
	}
	return cssMap
}
1138247
function createColoredCanvas(color)
{
    const canvas = document.createElement('canvas');

    canvas.width = 6;
    canvas.height = 1;

    const context = canvas.getContext('2d');

    context.fillStyle = color;
    context.fillRect(0, 0, 6, 1);

    return canvas;
}
902537
private void  updateStyle(RendererState state, Style style)
   {
      // Now update each style property we know about
      if (isSpecified(style, SVG.SPECIFIED_COLOR))
      {
         state.style.color = style.color;
      }

      if (isSpecified(style, SVG.SPECIFIED_OPACITY))
      {
         state.style.opacity = style.opacity;
      }

      if (isSpecified(style, SVG.SPECIFIED_FILL))
      {
         state.style.fill = style.fill;
         state.hasFill = (style.fill != null && style.fill != Colour.TRANSPARENT);
      }

      if (isSpecified(style, SVG.SPECIFIED_FILL_OPACITY))
      {
         state.style.fillOpacity = style.fillOpacity;
      }

      // If either fill or its opacity has changed, update the fillPaint
      if (isSpecified(style, SVG.SPECIFIED_FILL | SVG.SPECIFIED_FILL_OPACITY | SVG.SPECIFIED_COLOR | SVG.SPECIFIED_OPACITY))
      {
         setPaintColour(state, true, state.style.fill);
      }

      if (isSpecified(style, SVG.SPECIFIED_FILL_RULE))
      {
         state.style.fillRule = style.fillRule;
      }


      if (isSpecified(style, SVG.SPECIFIED_STROKE))
      {
         state.style.stroke = style.stroke;
         state.hasStroke = (style.stroke != null && style.stroke != Colour.TRANSPARENT);
      }

      if (isSpecified(style, SVG.SPECIFIED_STROKE_OPACITY))
      {
         state.style.strokeOpacity = style.strokeOpacity;
      }

      if (isSpecified(style, SVG.SPECIFIED_STROKE | SVG.SPECIFIED_STROKE_OPACITY | SVG.SPECIFIED_COLOR | SVG.SPECIFIED_OPACITY))
      {
         setPaintColour(state, false, state.style.stroke);
      }

      if (isSpecified(style, SVG.SPECIFIED_VECTOR_EFFECT))
      {
         state.style.vectorEffect = style.vectorEffect;
      }

      if (isSpecified(style, SVG.SPECIFIED_STROKE_WIDTH))
      {
         state.style.strokeWidth = style.strokeWidth;
         state.strokePaint.setStrokeWidth(state.style.strokeWidth.floatValue(this));
      }

      if (isSpecified(style, SVG.SPECIFIED_STROKE_LINECAP))
      {
         state.style.strokeLineCap = style.strokeLineCap;
         switch (style.strokeLineCap)
         {
            case Butt:
               state.strokePaint.setStrokeCap(Paint.Cap.BUTT);
               break;
            case Round:
               state.strokePaint.setStrokeCap(Paint.Cap.ROUND);
               break;
            case Square:
               state.strokePaint.setStrokeCap(Paint.Cap.SQUARE);
               break;
            default:
               break;
         }
      }

      if (isSpecified(style, SVG.SPECIFIED_STROKE_LINEJOIN))
      {
         state.style.strokeLineJoin = style.strokeLineJoin;
         switch (style.strokeLineJoin)
         {
            case Miter:
               state.strokePaint.setStrokeJoin(Paint.Join.MITER);
               break;
            case Round:
               state.strokePaint.setStrokeJoin(Paint.Join.ROUND);
               break;
            case Bevel:
               state.strokePaint.setStrokeJoin(Paint.Join.BEVEL);
               break;
            default:
               break;
         }
      }

      if (isSpecified(style, SVG.SPECIFIED_STROKE_MITERLIMIT))
      {
         // FIXME: must be >= 0
         state.style.strokeMiterLimit = style.strokeMiterLimit;
         state.strokePaint.setStrokeMiter(style.strokeMiterLimit);
      }

      if (isSpecified(style, SVG.SPECIFIED_STROKE_DASHARRAY))
      {
         state.style.strokeDashArray = style.strokeDashArray;
      }

      if (isSpecified(style, SVG.SPECIFIED_STROKE_DASHOFFSET))
      {
         state.style.strokeDashOffset = style.strokeDashOffset;
      }

      if (isSpecified(style, SVG.SPECIFIED_STROKE_DASHARRAY | SVG.SPECIFIED_STROKE_DASHOFFSET))
      {
         // Either the dash array or dash offset has changed.
         if (state.style.strokeDashArray == null)
         {
            state.strokePaint.setPathEffect(null);
         }
         else
         {
            float  intervalSum = 0f;
            int    n = state.style.strokeDashArray.length;
            // SVG dash arrays can be odd length, whereas Android dash arrays must have an even length.
            // So we solve the problem by doubling the array length.
            int    arrayLen = (n % 2==0) ? n : n*2;
            float[] intervals = new float[arrayLen];
            for (int i=0; i<arrayLen; i++) {
               intervals[i] = state.style.strokeDashArray[i % n].floatValue(this);
               intervalSum += intervals[i];
            }
            if (intervalSum == 0f) {
               state.strokePaint.setPathEffect(null);
            } else {
               float offset = state.style.strokeDashOffset.floatValue(this);
               if (offset < 0) {
                  // SVG offsets can be negative. Not sure if Android ones can be.
                  // Just in case we will convert it.
                  offset = intervalSum + (offset % intervalSum);
               }
               state.strokePaint.setPathEffect( new DashPathEffect(intervals, offset) );
            }
         }
      }

      if (isSpecified(style, SVG.SPECIFIED_FONT_SIZE))
      {
         float  currentFontSize = getCurrentFontSize();
         state.style.fontSize = style.fontSize;
         state.fillPaint.setTextSize(style.fontSize.floatValue(this, currentFontSize));
         state.strokePaint.setTextSize(style.fontSize.floatValue(this, currentFontSize));
      }

      if (isSpecified(style, SVG.SPECIFIED_FONT_FAMILY))
      {
         state.style.fontFamily = style.fontFamily;
      }

      if (isSpecified(style, SVG.SPECIFIED_FONT_WEIGHT))
      {
         // Font weights are 100,200...900
         if (style.fontWeight == Style.FONT_WEIGHT_LIGHTER && state.style.fontWeight > 100)
            state.style.fontWeight -= 100;
         else if (style.fontWeight == Style.FONT_WEIGHT_BOLDER && state.style.fontWeight < 900)
            state.style.fontWeight += 100;
         else
            state.style.fontWeight = style.fontWeight;
      }

      if (isSpecified(style, SVG.SPECIFIED_FONT_STYLE))
      {
         state.style.fontStyle = style.fontStyle;
      }

      // If typeface, weight or style has changed, update the paint typeface
      if (isSpecified(style, SVG.SPECIFIED_FONT_FAMILY | SVG.SPECIFIED_FONT_WEIGHT | SVG.SPECIFIED_FONT_STYLE))
      {
         Typeface  font = null;

         if (state.style.fontFamily != null && document != null) {
            SVGExternalFileResolver  fileResolver = SVG.getFileResolver();

            for (String fontName: state.style.fontFamily) {
               font = checkGenericFont(fontName, state.style.fontWeight, state.style.fontStyle);
               if (font == null && fileResolver != null) {
                  font = fileResolver.resolveFont(fontName, state.style.fontWeight, String.valueOf(state.style.fontStyle));
               }
               if (font != null)
                  break;
            }
         }
         if (font == null) {
            // Fall back to default font
            font = checkGenericFont(DEFAULT_FONT_FAMILY, state.style.fontWeight, state.style.fontStyle);
         }
         state.fillPaint.setTypeface(font);
         state.strokePaint.setTypeface(font);
      }

      if (isSpecified(style, SVG.SPECIFIED_TEXT_DECORATION))
      {
         state.style.textDecoration = style.textDecoration;
         state.fillPaint.setStrikeThruText(style.textDecoration == TextDecoration.LineThrough);
         state.fillPaint.setUnderlineText(style.textDecoration == TextDecoration.Underline);
         // There is a bug in Android <= JELLY_BEAN (16) that causes stroked underlines to
         // not be drawn properly. See bug (39511). This has been fixed in JELLY_BEAN_MR1 (4.2)
         if (android.os.Build.VERSION.SDK_INT >= 17) {
            state.strokePaint.setStrikeThruText(style.textDecoration == TextDecoration.LineThrough);
            state.strokePaint.setUnderlineText(style.textDecoration == TextDecoration.Underline);
         }
      }

      if (isSpecified(style, SVG.SPECIFIED_DIRECTION))
      {
         state.style.direction = style.direction;
      }

      if (isSpecified(style, SVG.SPECIFIED_TEXT_ANCHOR))
      {
         state.style.textAnchor = style.textAnchor;
      }

      if (isSpecified(style, SVG.SPECIFIED_OVERFLOW))
      {
         state.style.overflow = style.overflow;
      }

      if (isSpecified(style, SVG.SPECIFIED_MARKER_START))
      {
         state.style.markerStart = style.markerStart;
      }

      if (isSpecified(style, SVG.SPECIFIED_MARKER_MID))
      {
         state.style.markerMid = style.markerMid;
      }

      if (isSpecified(style, SVG.SPECIFIED_MARKER_END))
      {
         state.style.markerEnd = style.markerEnd;
      }

      if (isSpecified(style, SVG.SPECIFIED_DISPLAY))
      {
         state.style.display = style.display;
      }

      if (isSpecified(style, SVG.SPECIFIED_VISIBILITY))
      {
         state.style.visibility = style.visibility;
      }

      if (isSpecified(style, SVG.SPECIFIED_CLIP))
      {
         state.style.clip = style.clip;
      }

      if (isSpecified(style, SVG.SPECIFIED_CLIP_PATH))
      {
         state.style.clipPath = style.clipPath;
      }

      if (isSpecified(style, SVG.SPECIFIED_CLIP_RULE))
      {
         state.style.clipRule = style.clipRule;
      }

      if (isSpecified(style, SVG.SPECIFIED_MASK))
      {
         state.style.mask = style.mask;
      }

      if (isSpecified(style, SVG.SPECIFIED_STOP_COLOR))
      {
         state.style.stopColor = style.stopColor;
      }

      if (isSpecified(style, SVG.SPECIFIED_STOP_OPACITY))
      {
         state.style.stopOpacity = style.stopOpacity;
      }

      if (isSpecified(style, SVG.SPECIFIED_VIEWPORT_FILL))
      {
         state.style.viewportFill = style.viewportFill;
      }

      if (isSpecified(style, SVG.SPECIFIED_VIEWPORT_FILL_OPACITY))
      {
         state.style.viewportFillOpacity = style.viewportFillOpacity;
      }

      if (isSpecified(style, SVG.SPECIFIED_IMAGE_RENDERING))
      {
         state.style.imageRendering = style.imageRendering;
      }
   }
374113
private CssFormatter copy( @Nullable StringBuilder output ) {
        try {
            CssFormatter formatter = (CssFormatter)clone();
            formatter.output = output == null ? state.pool.get() : output;
            formatter.insets = state.pool.get();
            formatter.insets.append( insets );
            return formatter;
        } catch( CloneNotSupportedException ex ) {
            throw new LessException( ex );
        }
    }
990489
function (obj) {
        var clone = _.clone(obj);
        if (obj.style) {
            var style = obj.style;
            clone.style = {
                "font-family": style.fontFamily,
                "font-size": style.fontSize + "px",
                "font-weight": (style.mask & bin(4)) ? "bold" : "normal",
                "font-style": (style.mask & bin(5)) ? "italic" : "normal",
                "text-decoration": (((style.mask & bin(6)) ? "underline " : "") + ((style.mask & bin(7)) ? "line-through" : "")),
                "text-align": style.textAlign,
                "color": style.color,
                "background-color": style.backgroundColor,
                "border": [style.borderWidth + "px", style.borderStyle, style.borderColor].join(" "),
                "padding": style.padding.join("px ") + "px"
            };
            _.extend(clone.style, checkBorder(style.mask));
        }
        // init style if null
        clone.style || (clone.style = {});
        return clone;
    }
964618
function _setStyle(canvas, ctx, params, styleName) {
	if (params[styleName]) {
		if (isFunction(params[styleName])) {
			// Handle functions
			ctx[styleName] = params[styleName].call(canvas, params);
		} else {
			// Handle string values
			ctx[styleName] = params[styleName];
		}
	}
}
581974
function (element, style) {
			var styleString = '';

			for (var key in style) {
				styleString += key + ': ' + style[key] + ';';
			}

			element.setAttribute('style', styleString);

			return element;
		}