This creates a color grid
347479
function() {
	   
	   var grid, eventDelegation, square, i;
	   
	   // remember squares
	   this.squares = [];
	
	   // container
	   grid = inputEx.cn('div', {className: 'inputEx-ColorField-Grid'});
	   
	   // Is event delegation available ?
	   // (YAHOO.util.Event.delegate method is in "event-delegate" YUI-module)
	   eventDelegation = !lang.isUndefined(Event.delegate);
	   
	   for(i = 0 ; i < this.length ; i++) {
	      
	      //var square = inputEx.cn('div', {className: 'inputEx-ColorField-square'},{backgroundColor: this.colors[i], width:this.cellWidth+"px", height:this.cellHeight+"px", margin:this.cellMargin+"px" });
	      square = inputEx.cn('div', {className: 'inputEx-ColorField-square'},{backgroundColor: this.colors[i] });
	   	grid.appendChild(square);
			
	   	this.squares.push(square);
	   	
	   	// No event delegation available : add a listener on each square
	   	if (!eventDelegation) {
	   	  Event.addListener(square, "mousedown", function(e) {
	   	     var el = Event.getTarget(e);
	   	     this.onColorClick(e,el,grid);
	   	  }, this, true );
   	   }
	   	
	   	// <br clear='both'/> insertion to end a line
	   	// ( + always after the last colored square)
	   	if (i%this.cellPerLine === this.cellPerLine-1 || i === this.length-1) {
            grid.appendChild(inputEx.cn('br',{clear:'both'}));
         }
      }
      
      // Mousedown event delegation
      if (eventDelegation) {
         
         if (!lang.isUndefined(YAHOO.util.Selector)) {
            
            Event.delegate(grid,"mousedown",this.onColorClick,"div.inputEx-ColorField-square",this,true);
            
         } else {
            
            Event.delegate(grid,"mousedown",this.onColorClick,function(el) {
               if (el.nodeName === "DIV" && YAHOO.util.Dom.hasClass(el,'inputEx-ColorField-square')) {
                  return el;
               }
            },this,true);
            
         }
      }
      
	   return grid;
	}
693380
function Grid(props) {
  const grid = new contrib.grid({...props, screen: { append: () => {} }});
  const children = props.children instanceof Array ? props.children : [props.children];
  return React.createElement(props.component || 'element', {}, children.map((child, key) => {
    const props = child.props;
    const options = grid.set(props.row, props.col, props.rowSpan || 1, props.colSpan || 1, x => x, props.options);
    options.key = key;
    return React.cloneElement(child, options);
  }));
}
288565
private static void paintRegion(SynthContext state, Graphics g, Rectangle bounds) {
        JComponent c      = state.getComponent();
        SynthStyle style  = state.getStyle();
        int        x;
        int        y;
        int        width;
        int        height;

        if (bounds == null) {
            x      = 0;
            y      = 0;
            width  = c.getWidth();
            height = c.getHeight();
        } else {
            x      = bounds.x;
            y      = bounds.y;
            width  = bounds.width;
            height = bounds.height;
        }

        // Fill in the background, if necessary.
        boolean subregion = state.getRegion().isSubregion();

        if ((subregion && style.isOpaque(state)) || (!subregion && c.isOpaque())) {
            g.setColor(style.getColor(state, ColorType.BACKGROUND));
            g.fillRect(x, y, width, height);
        }
    }
1011282
def drawGrid( self, painter ):
        
        # draw the minor grid lines
        pen = QPen(self.borderColor())
        painter.setPen(pen)
        painter.setBrush(self.baseColor())
        
        # draw the grid data
        painter.drawRect(self._buildData['grid_rect'])
        
        painter.setBrush(self.alternateColor())
        painter.setPen(Qt.NoPen)
        
        if ( self.alternatingRowColors() ):
            for alt_rect in self._buildData['grid_h_alt']:
                painter.drawRect(alt_rect)
        
        if ( self.alternatingColumnColors() ):
            for alt_rect in self._buildData['grid_v_alt']:
                painter.drawRect(alt_rect)
        
        if ( self.showGrid() ):
            painter.setPen(pen)
            
            grid = []
            if ( self.showRows() ):
                grid += self._buildData['grid_h_lines']
            
            if ( self.showColumns() ):
                grid += self._buildData['grid_v_lines']
            
            painter.drawLines(grid)
680428
function GridLayout(colCount, tileSpans) {
      var self, layoutInfo, gridStyles, layoutTime, mapTime, reflowTime;

      layoutTime = $mdUtil.time(function() {
        layoutInfo = calculateGridFor(colCount, tileSpans);
      });

      return self = {

        /**
         * An array of objects describing each tile's position in the grid.
         */
        layoutInfo: function() {
          return layoutInfo;
        },

        /**
         * Maps grid positioning to an element and a set of styles using the
         * provided updateFn.
         */
        map: function(updateFn) {
          mapTime = $mdUtil.time(function() {
            var info = self.layoutInfo();
            gridStyles = updateFn(info.positioning, info.rowCount);
          });
          return self;
        },

        /**
         * Default animator simply sets the element.css( <styles> ). An alternate
         * animator can be provided as an argument. The function has the following
         * signature:
         *
         *    function({grid: {element: JQLite, style: Object}, tiles: Array<{element: JQLite, style: Object}>)
         */
        reflow: function(animatorFn) {
          reflowTime = $mdUtil.time(function() {
            var animator = animatorFn || defaultAnimator;
            animator(gridStyles.grid, gridStyles.tiles);
          });
          return self;
        },

        /**
         * Timing for the most recent layout run.
         */
        performance: function() {
          return {
            tileCount: tileSpans.length,
            layoutTime: layoutTime,
            mapTime: mapTime,
            reflowTime: reflowTime,
            totalTime: layoutTime + mapTime + reflowTime
          };
        }
      };
    }
282780
def draw_canvas():
    """"""
    for x in range(len(world)):
        for y in range(len(world[x])):
            if world[x][y].value:
                color = world[x][y].color_alive.get_as_hex()
            else:
                color = world[x][y].color_dead.get_as_hex()
            canvas.itemconfig(canvas_grid[x][y], fill=color)
975423
private GridLines getGridLines(byte[] data, int offset)
   {
      Color normalLineColor = ColorType.getInstance(data[offset]).getColor();
      LineStyle normalLineStyle = LineStyle.getInstance(data[offset + 3]);
      int intervalNumber = data[offset + 4];
      LineStyle intervalLineStyle = LineStyle.getInstance(data[offset + 5]);
      Color intervalLineColor = ColorType.getInstance(data[offset + 6]).getColor();
      return new GridLines(normalLineColor, normalLineStyle, intervalNumber, intervalLineStyle, intervalLineColor);
   }
35855
function createGridClipShape(rect, seriesModel, cb) {
    var rectEl = new graphic.Rect({
        shape: {
            x: rect.x - 10,
            y: rect.y - 10,
            width: 0,
            height: rect.height + 20
        }
    });
    graphic.initProps(rectEl, {
        shape: {
            width: rect.width + 20,
            height: rect.height + 20
        }
    }, seriesModel, cb);

    return rectEl;
}
250410
function recolorBillboard(img, color) {
  var canvas = document.createElement("canvas");
  canvas.width = img.width;
  canvas.height = img.height;

  // Copy the image contents to the canvas
  var context = canvas.getContext("2d");
  context.drawImage(img, 0, 0);
  var image = context.getImageData(0, 0, canvas.width, canvas.height);
  var normClr = [color.red, color.green, color.blue, color.alpha];

  var length = image.data.length; //pixel count * 4
  for (var i = 0; i < length; i += 4) {
    for (var j = 0; j < 4; j++) {
      image.data[j + i] *= normClr[j];
    }
  }

  context.putImageData(image, 0, 0);
  return canvas.toDataURL();
  //    return context.getImageData(0, 0, canvas.width, canvas.height);
}
624712
function ( type, settings, parent, colors ) {

        T.dom( type, null, settings, parent, 0 );

        var n = parent.childNodes[0].childNodes.length - 1, c;

        for( var i = 0; i < colors.length; i++ ){

            c = colors[i];
            T.dom( 'stop', null, { offset:c[0]+'%', style:'stop-color:'+c[1]+'; stop-opacity:'+c[2]+';' }, parent, [0,n] );

        }

    }
1156894
def grid(box, draw)
      x, y, w, h = box.x, box.y, box.width, box.height
      use_cairo do |cc|
        (x..@width + w).step(w)  { |ix| line_xy(ix, y - @height, ix, @height + y, draw) }
        (y..@height + h).step(h) { |iy| line_xy(x - @width, iy, @width + x, iy, draw) }
      end
    end
425831
private void paintArrows(Graphics2D g, JComponent c, int width, int height) {
        int xOffset = width / 2 - 5;
        int yOffset = height / 2 - 3;

        g.translate(xOffset, yOffset);

        Shape s = shapeGenerator.createArrowLeft(0.5, 0.5, 3, 4);

        g.setPaint(getCommonArrowPaint(s, type));
        g.fill(s);

        s = shapeGenerator.createArrowRight(6.5, 0.5, 3, 4);
        g.setPaint(getCommonArrowPaint(s, type));
        g.fill(s);

        g.translate(-xOffset, -yOffset);
    }
155471
def draw_grid(self):
        """"""
        self.screen.fill((0xbb, 0xad, 0xa0), self.origin + (self.game_width, self.game_height))
        for y, row in enumerate(self.grid):
            for x, cell in enumerate(row):
                self.screen.blit(self.tiles[cell], self.get_tile_location(x, y))
1141732
def define_grid(self, matrix):
        
        self.style['grid-template-areas'] = ''.join("'%s'"%(' '.join(x)) for x in matrix)
603396
function _colorToRgbArray(color) {
	var originalColor, elem,
		rgb = [],
		multiple = 1;

	// Deal with complete transparency
	if (color === 'transparent') {
		color = 'rgba(0, 0, 0, 0)';
	} else if (color.match(/^([a-z]+|#[0-9a-f]+)$/gi)) {
		// Deal with hexadecimal colors and color names
		elem = document.head;
		originalColor = elem.style.color;
		elem.style.color = color;
		color = $.css(elem, 'color');
		elem.style.color = originalColor;
	}
	// Parse RGB string
	if (color.match(/^rgb/gi)) {
		rgb = color.match(/(\d+(\.\d+)?)/gi);
		// Deal with RGB percentages
		if (color.match(/%/gi)) {
			multiple = 2.55;
		}
		rgb[0] *= multiple;
		rgb[1] *= multiple;
		rgb[2] *= multiple;
		// Ad alpha channel if given
		if (rgb[3] !== undefined) {
			rgb[3] = parseFloat(rgb[3]);
		} else {
			rgb[3] = 1;
		}
	}
	return rgb;
}
729994
function Gridpanel( canvas, width, height, left, top ) {
		var gridpanel,
			data = [],
			xValue = function( d ) { return d[ 0 ]; },
			yValue = function( d ) { return d[ 1 ]; },
			yMax = 0, _yMax,
			numRows, numCols,
			graphs, area,
			headers = [
				'Condition 1: really long description which goes on and on',
				'Condition 2',
				'Condition 3'
			],
			labels = headers,
			annotations, title;

		// [1] Instantiate a new gridpanel generator and configure:
		gridpanel = xfig.multipanel( canvas )
			.width( width )
			.height( height )
			.gutter( 120 )
			.position({
				'left': left,
				'top': top
			});

		// Get data:
		d3.json( 'data/gridpanel.data.json', function ( error, json ) {

			numRows = json.length;
			numCols = json.length;

			// [2] For each panel dataset, instantiate a new data generator and configure:
			for ( var i = 0; i < numRows; i++ ) {
				for ( var j = 0; j < numCols; j++ ) {

					data.push(
						xfig.data( [ json[ i ], json[ j ] ] )
							.accessors( 'x', xValue )
							.accessors( 'y', yValue )
					);

					// Compute the yMax:
					_yMax = data[ data.length-1 ].max( yValue );
					yMax = ( yMax < _yMax ) ? _yMax : yMax;
				} // end FOR j
			} // end FOR i

			// Bind the data instance to the gridpanel:
			gridpanel.data( data )
				.rows( numRows )
				.cols( numCols )
				.xMin( 0 )
				.xMax( 1 )
				.yMin( 0 )
				.yMax( yMax )
				.yLabel( 'density [a.u.]' )
				.headers( headers )
				.labels( labels );

			// Create the gridpanel:
			gridpanel.create();

			// [3] Instantiate a new annotations generator and configure:
			annotations = xfig.annotations( gridpanel );

			// Create the annotations element:
			annotations.create();

			// [3.1] Instantiate a new title instance and configure:
			title = annotations.title()
				.top( -80 )
				.left( 450 );

			// Add a (sub)title:
			title.create( 'Subtitle' );

			// [4] For each panel graph, instantiate a new area generator and configure:
			graphs = gridpanel.children().graph;
			for ( var k = 0; k < graphs.length; k++ ) {
				area = xfig.area( graphs[ k ] )
					.labels( [ 'data 0', 'data 1' ] );

				// Create the area:
				area.create();
			} // end FOR k

		});

	}
1099602
private int[] buildVertexColor() {
        int[] color = new int[g.length];

        int n = 1;
        Arrays.fill(color, -1);
        for (long cycle : cycles) {
            for (int i = 0; i < g.length; i++) {
                if ((cycle & 0x1) == 0x1) color[i] = color[i] < 0 ? n : 0;
                cycle >>= 1;
            }
            n++;
        }

        return color;
    }