Draw a vertical gradient
12518
def vertical_gradient(self, x0, y0, x1, y1, start, end):
        """"""
        x0, y0, x1, y1 = self.rect_helper(x0, y0, x1, y1)
        grad = gradient_list(start, end, y1 - y0)
        for x in range(x0, x1 + 1):
            for y in range(y0, y1 + 1):
                self.point(x, y, grad[y - y0])
914933
def draw(self, milliseconds, surface, cell):
        """"""
        # print self.cells[cell]
        self.source = self.cells[cell].copy()
        # Find the current scale of the image in relation to its original scale.
        current_scale = Vector2()
        current_scale.X = self.rect.width / float(self.untransformed_image.get_width())
        current_scale.Y = self.rect.height / float(self.untransformed_image.get_height())
        # self.source.x *= self.scale.X
        # self.source.y *= self.scale.Y
        self.source.width *= current_scale.X
        self.source.height *= current_scale.Y
        super(SpriteSheet, self).draw(milliseconds, surface)
529673
def _init_vertical(self):
        """"""
        self.scale.grid(row=0, sticky='ns')
        # showvalue
        padx1, padx2 = 0, 0
        pady1, pady2 = 0, 0
        if self._showvalue:
            self.label.configure(text=self._formatter.format(self._start))
            if self._labelpos == 'w':
                self.label.place(in_=self.scale, bordermode='outside',
                                 relx=0, y=0, anchor='e')
                self.update_idletasks()
                padx1 = self.label.winfo_width()
                self.label.configure(text=self._formatter.format(self._start + self._extent))
                self.update_idletasks()
                padx1 = max(self.label.winfo_width(), padx1)
            elif self._labelpos == 'e':
                self.label.place(in_=self.scale, bordermode='outside',
                                 relx=1, y=1, anchor='w')
                self.update_idletasks()
                padx2 = self.label.winfo_width()
                self.label.configure(text=self._formatter.format(self._start + self._extent))
                self.update_idletasks()
                padx2 = max(self.label.winfo_width(), padx2)
            else:  # self._labelpos in ['n', 's']:
                if self._labelpos == 'n':
                    rely = 0
                    anchor = 's'
                    pady1 = self.label.winfo_reqheight()
                else:
                    rely = 1
                    anchor = 'n'
                    pady2 = self.label.winfo_reqheight()
                self.label.place(in_=self.scale, bordermode='outside', relx=0.5,
                                 rely=rely, anchor=anchor)
                self.update_idletasks()
                w = self.label.winfo_width()
                self.label.configure(text=self._formatter.format(self._start + self._extent))
                self.update_idletasks()
                w = max(w, self.label.winfo_width())
                ws = self.scale.winfo_reqwidth()
                if w > ws:
                    padx = (w - ws) // 2
                    if self._tickinterval:
                        if self._tickpos == 'e':
                            padx1 = padx
                        else:   # self._tickpos == 'w'
                            padx2 = padx
                    else:
                        padx1, padx2 = padx, padx
        # ticks
        padx1_2, padx2_2 = 0, 0
        if self._tickinterval:
            nb_interv = int(self._extent / self._tickinterval)
            if self._tickpos == 'w':
                for i in range(nb_interv + 1):
                    tick = self._start + i * self._tickinterval
                    self.ticks.append(tick)
                    self.ticklabels.append(ttk.Label(self,
                                                     style=self._style_name + ".TLabel",
                                                     text=self._formatter.format(tick)))
                    self.ticklabels[i].place(in_=self.scale, bordermode='outside',
                                             x=-1 - padx1, y=0,
                                             anchor='e')
                    self.update_idletasks()
                    padx1_2 = max(self.ticklabels[i].winfo_width(), padx1_2)
            else:  # self._tickpos == 'e'
                w = self.scale.winfo_reqwidth()
                for i in range(nb_interv + 1):
                    tick = self._start + i * self._tickinterval
                    self.ticks.append(tick)
                    self.ticklabels.append(ttk.Label(self,
                                                     style=self._style_name + ".TLabel",
                                                     text=self._formatter.format(tick)))
                    self.ticklabels[i].place(in_=self.scale, bordermode='outside',
                                             x=w + 1 + padx2, y=0,
                                             anchor='w')
                    self.update_idletasks()
                    padx2_2 = max(self.ticklabels[i].winfo_width(), padx2_2)
        self.scale.grid_configure(padx=(padx1 + padx1_2 + 1, padx2 + padx2_2 + 1),
                                  pady=(pady1, pady2))
999809
function VerticalLStrategy(connector)
{
	this.connector = connector;
	
	this.startSegment;
	this.endSegment;
	
	this.strategyName = "vertical_L";
	
	this.isApplicable = function()
	{
		var sourceMiddle = Math.floor(this.connector.source.left() + this.connector.source.width() / 2);
		var dl = this.connector.destination.left();
		var dw = this.connector.destination.width();
		var st = this.connector.source.top();
		var sh = this.connector.source.height();
		var destMiddle = Math.floor(this.connector.destination.top() + this.connector.destination.height() / 2);

		if(sourceMiddle > dl && sourceMiddle < dl + dw)
			return false;
		if(destMiddle > st && destMiddle < st + sh)
			return false;
		return true;
	}
	/**
	 * Chooses the longest segment as the "middle" segment.
	 */
	this.getMiddleSegment = function() {
		if(this.startSegment.length > this.endSegment.length)
			return this.startSegment;
		return this.endSegment;
	}
	this.paint = function() {
		this.startSegment = this.connector.createSegment();
		this.endSegment = this.connector.createSegment();
		var destMiddleY = Math.floor(this.connector.destination.top() + this.connector.destination.height() / 2);
		var dl = this.connector.destination.left();
		var dw = this.connector.destination.width();
		var st = this.connector.source.top();
		var sh = this.connector.source.height();
		this.startSegment.startX = Math.floor(this.connector.source.left() + this.connector.source.width() / 2);
		// decide which side of the source block to connect to
		if(Math.abs(destMiddleY - st) < Math.abs(destMiddleY - (st + sh))) {
			// use the upper face
			this.startSegment.orientation = (destMiddleY < st) ? UP : DOWN;
			this.startSegment.startY = st;
		} else {
			// use the lower face
			this.startSegment.orientation = (destMiddleY > (st + sh)) ? DOWN : UP;
			this.startSegment.startY = st + sh;
		}
		
		this.startSegment.length = Math.abs(destMiddleY - this.startSegment.startY);
		
		// decide which side of the destination block to connect to
		if(Math.abs(this.startSegment.startX - dl) < Math.abs(this.startSegment.startX - (dl + dw)))
		{
			// use the left face
			this.endSegment.orientation = (this.startSegment.startX < dl) ? RIGHT : LEFT;
			this.endSegment.length = Math.abs(this.startSegment.startX - dl);
		}
		else
		{
			// use the right face
			this.endSegment.orientation = (this.startSegment.startX > dl + dw) ? LEFT : RIGHT;
			this.endSegment.length = Math.abs(this.startSegment.startX - (dl + dw));
		}
	}
}
754496
function Gradient(size, start) {
  this.size = size;
  this.canvas = new Canvas(1, 1);
  this.setStartPosition(start);
  this.ctx = this.canvas.getContext('2d');
  this.grad = this.ctx.createLinearGradient(
      this.from[0], this.from[1],
      this.to[0], this.to[1]);
}
341196
public static void vertical(GrayF32 input, GrayF32 output, int radius, @Nullable FWorkArrays work) {
		InputSanityCheck.checkSameShape(input , output );

		Kernel1D_F32 kernel = FactoryKernel.table1D_F32(radius,false);
		ConvolveJustBorder_General_SB.vertical(kernel,ImageBorderValue.wrap(input,0),output);
		if(BoofConcurrency.USE_CONCURRENT ) {
			ImplConvolveBox_MT.vertical(input, output, radius, work);
		} else {
			ImplConvolveBox.vertical(input, output, radius,work);
		}
	}
54300
private void paintDraggedArea(SeaGlassContext context, Graphics g, int rMin, int rMax, TableColumn draggedColumn, int distance) {
        int draggedColumnIndex = viewIndexForColumn(draggedColumn);

        Rectangle minCell = table.getCellRect(rMin, draggedColumnIndex, true);
        Rectangle maxCell = table.getCellRect(rMax, draggedColumnIndex, true);

        Rectangle vacatedColumnRect = minCell.union(maxCell);

        // Paint a gray well in place of the moving column.
        g.setColor(table.getParent().getBackground());
        g.fillRect(vacatedColumnRect.x, vacatedColumnRect.y, vacatedColumnRect.width, vacatedColumnRect.height);

        // Move to the where the cell has been dragged.
        vacatedColumnRect.x += distance;

        // Fill the background.
        g.setColor(context.getStyle().getColor(context, ColorType.BACKGROUND));
        g.fillRect(vacatedColumnRect.x, vacatedColumnRect.y, vacatedColumnRect.width, vacatedColumnRect.height);

        SynthGraphicsUtils synthG = context.getStyle().getGraphicsUtils(context);

        // Paint the vertical grid lines if necessary.
        if (table.getShowVerticalLines()) {
            g.setColor(table.getGridColor());
            int x1 = vacatedColumnRect.x;
            int y1 = vacatedColumnRect.y;
            int x2 = x1 + vacatedColumnRect.width - 1;
            int y2 = y1 + vacatedColumnRect.height - 1;
            // Left
            synthG.drawLine(context, "Table.grid", g, x1 - 1, y1, x1 - 1, y2);
            // Right
            synthG.drawLine(context, "Table.grid", g, x2, y1, x2, y2);
        }

        for (int row = rMin; row <= rMax; row++) {
            // Render the cell value
            Rectangle r = table.getCellRect(row, draggedColumnIndex, false);

            r.x += distance;
            paintCell(context, g, r, row, draggedColumnIndex);

            // Paint the (lower) horizontal grid line if necessary.
            if (table.getShowHorizontalLines()) {
                g.setColor(table.getGridColor());
                Rectangle rcr = table.getCellRect(row, draggedColumnIndex, true);

                rcr.x += distance;
                int x1 = rcr.x;
                int y1 = rcr.y;
                int x2 = x1 + rcr.width - 1;
                int y2 = y1 + rcr.height - 1;

                synthG.drawLine(context, "Table.grid", g, x1, y2, x2, y2);
            }
        }
    }
1298114
public void drawRect(float x1, float y1, float width, float height) {
		float lineWidth = getLineWidth();
		
		drawLine(x1,y1,x1+width,y1);
		drawLine(x1+width,y1,x1+width,y1+height);
		drawLine(x1+width,y1+height,x1,y1+height);
		drawLine(x1,y1+height,x1,y1);
	}
1373297
def gradient_line(xs, ys, colormap_name='jet', ax=None):
  ''''''
  if ax is None:
    ax = plt.gca()
  cm = plt.get_cmap(colormap_name)
  npts = len(xs)-1
  colors = cm(np.linspace(0, 1, num=npts))
  if hasattr(ax, 'set_prop_cycle'):
    ax.set_prop_cycle(color=colors)
  else:
    ax.set_color_cycle(colors)
  for i in range(npts):
    ax.plot(xs[i:i+2],ys[i:i+2])
  return plt.show
16981
def draw(self):
        """"""

        row_start, row_stop = self.row_tb
        col_start, col_stop = self.col_rl
        tab_start, tab_stop = self.tab_fl

        for tab in xrange(tab_start, tab_stop):
            # Scale context to page extent
            # In order to keep the aspect ration intact use the maximum
            first_key = row_start, col_start, tab
            first_rect = self.get_cell_rect(*first_key)

            # If we have a merged cell then use the top left cell rect
            if first_rect is None:
                top, left, __, __ = self._get_merge_area(first_key)
                first_rect = self.get_cell_rect(top, left, tab)

            last_key = row_stop - 1, col_stop - 1, tab
            last_rect = self.get_cell_rect(*last_key)

            # If we have a merged cell then use the top left cell rect
            if last_rect is None:
                top, left, __, __ = self._get_merge_area(last_key)
                last_rect = self.get_cell_rect(top, left, tab)

            x_extent = last_rect[0] + last_rect[2] - first_rect[0]
            y_extent = last_rect[1] + last_rect[3] - first_rect[1]

            scale_x = (self.width - 2 * self.x_offset) / float(x_extent)
            scale_y = (self.height - 2 * self.y_offset) / float(y_extent)

            self.context.save()
            # Translate offset to o
            self.context.translate(first_rect[0], first_rect[1])

            # Scale to fit page, do not change aspect ratio
            scale = min(scale_x, scale_y)
            self.context.scale(scale, scale)

            # Translate offset
            self.context.translate(-self.x_offset, -self.y_offset)

            # TODO: Center the grid on the page

            # Render cells

            for row in xrange(row_start, row_stop):
                for col in xrange(col_start, col_stop):
                    key = row, col, tab
                    rect = self.get_cell_rect(row, col, tab)  # Rect
                    if rect is not None:
                        cell_renderer = GridCellCairoRenderer(
                            self.context,
                            self.code_array,
                            key,  # (row, col, tab)
                            rect,
                            self.view_frozen
                        )

                        cell_renderer.draw()

            # Undo scaling, translation, ...
            self.context.restore()

            self.context.show_page()
1320591
def onMargins(self, left=0.1, top=0.1, right=0.1, bottom=0.1):
        
        bconf = self.panel_bot.conf
        l, t, r, b = bconf.margins
        bconf.set_margins(left=left, top=t, right=right, bottom=b)
        bconf.canvas.draw()
1004380
def __init_vertical_plot(self):
        
        # clear the plot if lines have already been drawn on it
        if len(self.ax2.lines) > 0:
            self.ax2.cla()
        # set up the vertical profile plot
        self.ax2.set_ylabel(self.datalabel, fontsize=self.fontsize)
        self.ax2.set_xlabel(self.spectrumlabel, fontsize=self.fontsize)
        self.ax2.set_title('vertical point profiles', fontsize=self.fontsize)
        self.ax2.set_xlim([1, self.bands])
        # plot vertical line at the slider position
        self.vline = self.ax2.axvline(self.slider.value, color='black')
428168
function drawSteps(){
            let steps = svg.select('.chart-group').selectAll('.step').data(data);

            // Enter
            steps.enter()
              .append('rect')
                .classed('step', true)
                .attr('x', chartWidth) // Initially drawing the steps at the end of Y axis
                .attr('y', ({value}) => yScale(value))
                .attr('width', xScale.bandwidth())
                .attr('height', (d) => (chartHeight - yScale(d.value)))
                .on('mouseover', function(d) {
                    handleMouseOver(this, d, chartWidth, chartHeight);
                })
                .on('mousemove', function(d) {
                    handleMouseMove(this, d, chartWidth, chartHeight);
                })
                .on('mouseout', function(d) {
                    handleMouseOut(this, d, chartWidth, chartHeight);
                })
              .merge(steps)
                .transition()
                .ease(ease)
                .attr('x', ({key}) => xScale(key))
                .attr('y', function(d) {
                    return yScale(d.value);
                })
                .attr('width', xScale.bandwidth())
                .attr('height', function(d) {
                    return chartHeight - yScale(d.value);
                });

            // Exit
            steps.exit()
                .transition()
                .style('opacity', 0)
                .remove();
        }
731555
def make_gradients(dims=DEFAULT_DIMS):
    
    return np.meshgrid(
        np.linspace(0.0, 1.0, dims[0]),
        np.linspace(0.0, 1.0, dims[1])
    )
222000
def _bar(s, align, colors, width=100, vmin=None, vmax=None):
        
        # Get input value range.
        smin = s.min() if vmin is None else vmin
        if isinstance(smin, ABCSeries):
            smin = smin.min()
        smax = s.max() if vmax is None else vmax
        if isinstance(smax, ABCSeries):
            smax = smax.max()
        if align == 'mid':
            smin = min(0, smin)
            smax = max(0, smax)
        elif align == 'zero':
            # For "zero" mode, we want the range to be symmetrical around zero.
            smax = max(abs(smin), abs(smax))
            smin = -smax
        # Transform to percent-range of linear-gradient
        normed = width * (s.values - smin) / (smax - smin + 1e-12)
        zero = -width * smin / (smax - smin + 1e-12)

        def css_bar(start, end, color):
            """
            Generate CSS code to draw a bar from start to end.
            """
            css = 'width: 10em; height: 80%;'
            if end > start:
                css += 'background: linear-gradient(90deg,'
                if start > 0:
                    css += ' transparent {s:.1f}%, {c} {s:.1f}%, '.format(
                        s=start, c=color
                    )
                css += '{c} {e:.1f}%, transparent {e:.1f}%)'.format(
                    e=min(end, width), c=color,
                )
            return css

        def css(x):
            if pd.isna(x):
                return ''

            # avoid deprecated indexing `colors[x > zero]`
            color = colors[1] if x > zero else colors[0]

            if align == 'left':
                return css_bar(0, x, color)
            else:
                return css_bar(min(x, zero), max(x, zero), color)

        if s.ndim == 1:
            return [css(x) for x in normed]
        else:
            return pd.DataFrame(
                [[css(x) for x in row] for row in normed],
                index=s.index, columns=s.columns
            )
128380
def gradient(self, P, Q, Y, i):
        """"""

        return 4 * sum([
            (P[i, j] - Q[i, j]) * (Y[i] - Y[j]) * (1 + np.linalg.norm(Y[i] - Y[j]) ** 2) ** -1 \
            for j in range(Y.shape[0])
        ])
364171
void draw(GLShader shader, InternalTransform xform, int tint,
            float dx, float dy, float dw, float dh) {
    draw(shader, xform, tint, dx, dy, dw, dh,
         0, 0, (repeatX ? dw : width()), (repeatY ? dh : height()));
  }