Replaces drawn rect if the one provided by wx is incorrect

        This handles merged rects including those that are partly off screen.
168910
def _get_drawn_rect(self, grid, key, rect):
        

        rect = self.get_merged_rect(grid, key, rect)
        if rect is None:
            # Merged cell is drawn
            if grid.is_merged_cell_drawn(key):
                # Merging cell is outside view
                row, col, __ = key = self.get_merging_cell(grid, key)
                rect = grid.CellToRect(row, col)
                rect = self.get_merged_rect(grid, key, rect)
            else:
                return

        return rect
287090
public void drawRect(double[] topLeft, double[] rightBottom) {
        if (!(projection instanceof Projection2D)) {
            throw new UnsupportedOperationException("Only 2D graphics supports drawing rectangles.");
        }

        int[] sc = projection.screenProjection(topLeft);
        int[] sc2 = projection.screenProjection(rightBottom);

        g2d.drawRect(sc[0], sc[1], sc2[0] - sc[0], sc2[1] - sc[1]);
    }
711335
function (renderer, rect) {
            var renderable = this.renderable;
            if (renderable instanceof me.Renderable) {
                // predraw (apply transforms)
                renderable.preDraw(renderer);

                // draw the object
                renderable.draw(renderer, rect);

                // postdraw (clean-up);
                renderable.postDraw(renderer);
            }
        }
397865
def _repaint(self, drawing_context):
        """"""

        # canvas size
        canvas_width = self.canvas_size[1]
        canvas_height = self.canvas_size[0]

        # draw background
        if self.background_color:
            with drawing_context.saver():
                drawing_context.begin_path()
                drawing_context.move_to(0,0)
                drawing_context.line_to(canvas_width,0)
                drawing_context.line_to(canvas_width,canvas_height)
                drawing_context.line_to(0,canvas_height)
                drawing_context.close_path()
                drawing_context.fill_style = self.background_color
                drawing_context.fill()

        # draw the data, if any
        if (self.data is not None and len(self.data) > 0):

            # draw the histogram itself
            with drawing_context.saver():
                drawing_context.begin_path()
                binned_data = Image.rebin_1d(self.data, int(canvas_width), self.__retained_rebin_1d) if int(canvas_width) != self.data.shape[0] else self.data
                for i in range(canvas_width):
                    drawing_context.move_to(i, canvas_height)
                    drawing_context.line_to(i, canvas_height * (1 - binned_data[i]))
                drawing_context.line_width = 1
                drawing_context.stroke_style = "#444"
                drawing_context.stroke()
1336661
function(r,rectMode){
		if(rectMode === undefined){
			rectMode = this.app.CORNER;
		}
		if(rectMode === this.app.CORNER){
			this.gfx.rect(r.x,r.y,r.width,r.height);
		} else if(rectMode === this.app.CORNERS){
			this.gfx.rect(r.x,r.y,r.x+r.width,r.y+r.height);
		} else if(rectMode === this.app.CENTER){
			this.gfx.rect(r.x+r.widt*0.5,r.y+r.height*0.5,r.width,r.height);
		} else if(rectMode === this.app.RADIUS){
			var rw = r.width * 0.5,
				rh = r.height *0.5;
			this.gfx.rect(r.x+rw,r.y+rh,rw,rh);
		}
	}
74658
function(ctx, noTransform) {
      ctx.save();
      var m = this.transformMatrix;
      this._resetWidthHeight();
      if (this.group) {
        ctx.translate(-this.group.width/2 + this.width/2, -this.group.height/2 + this.height/2);
      }
      if (m) {
        ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
      }
      if (!noTransform) {
        this.transform(ctx);
      }
      this._render(ctx);
      if (this.active && !noTransform) {
        this.drawBorders(ctx);
        this.hideCorners || this.drawCorners(ctx);
      }
      ctx.restore();
    }
232885
def redraw(self):
        ''''''
        state = self.state

        if self.img is None:
            self.mainSizer.Fit(self)
            self.Refresh()
            state.frame.Refresh()
            self.SetFocus()
            return

        # get the current size of the containing window frame
        size = self.frame.GetSize()
        (width, height) = (self.img.GetWidth(), self.img.GetHeight())

        rect = wx.Rect(self.dragpos.x, self.dragpos.y, int(size.x/self.zoom), int(size.y/self.zoom))

        #print("redraw", self.zoom, self.dragpos, size, rect);

        if rect.x > width-1:
            rect.x = width-1
        if rect.y > height-1:
            rect.y = height-1
        if rect.width > width - rect.x:
            rect.width = width - rect.x
        if rect.height > height - rect.y:
            rect.height = height - rect.y

        scaled_image = self.img.Copy()
        scaled_image = scaled_image.GetSubImage(rect);
        scaled_image = scaled_image.Rescale(int(rect.width*self.zoom), int(rect.height*self.zoom))
        if state.brightness != 1.0:
            try:
                from PIL import Image
                pimg = mp_util.wxToPIL(scaled_image)
                pimg = Image.eval(pimg, lambda x: int(x * state.brightness))
                scaled_image = mp_util.PILTowx(pimg)
            except Exception:
                if not self.done_PIL_warning:
                    print("Please install PIL for brightness control")
                    self.done_PIL_warning = True
                # ignore lack of PIL library
                pass
        self.imagePanel.set_image(scaled_image)
        self.need_redraw = False

        self.mainSizer.Fit(self)
        self.Refresh()
        state.frame.Refresh()
        self.SetFocus()
        '''
        from guppy import hpy
        h = hpy()
        print h.heap()
        '''
133694
def fill_rect(self, rect):
        
        check_int_err(lib.SDL_RenderFillRect(self._ptr, rect._ptr))
474790
@Override protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    if (noxItemCatalog == null) {
      wasInvalidatedBefore = false;
      return;
    }
    updateShapeOffset();
    for (int i = 0; i < noxItemCatalog.size(); i++) {
      if (shape.isItemInsideView(i)) {
        loadNoxItem(i);
        float left = shape.getXForItemAtPosition(i);
        float top = shape.getYForItemAtPosition(i);
        drawNoxItem(canvas, i, left, top);
      }
    }
    canvas.restore();
    wasInvalidatedBefore = false;
  }
836562
def draw_rect(
            self, x:float, y:float, w:float, h:float, *,
            stroke:Color=None,
            stroke_width:float=1,
            stroke_dash:typing.Sequence=None,
            fill:Color=None
            ) -> None:
        """"""
        pass
523359
def select_rect(action, action_space, select_add, screen, screen2):
  """"""
  select = spatial(action, action_space).unit_selection_rect
  out_rect = select.selection_screen_coord.add()
  screen_rect = point.Rect(screen, screen2)
  screen_rect.tl.assign_to(out_rect.p0)
  screen_rect.br.assign_to(out_rect.p1)
  select.selection_add = bool(select_add)
28994
def _updateCanvasDraw(self):
        
        fn = self.canvas.draw
        def draw2(*a,**k):
            self._updateGridSpec()
            return fn(*a,**k)
        self.canvas.draw = draw2
906712
def copy_rect(self, x0, y0, x1, y1, dx, dy, destination):
        """"""
        x0, y0, x1, y1 = self.rect_helper(x0, y0, x1, y1)
        dx, dy = force_int(dx, dy)

        for x in range(x0, x1 + 1):
            for y in range(y0, y1 + 1):
                d = destination._offset(dx + x - x0, dy + y - y0)
                o = self._offset(x, y)
                destination.canvas[d:d + 4] = self.canvas[o:o + 4]
1072199
def get_print_rect(self, grid_rect):
        """"""

        grid = self.grid

        rect_x = grid_rect.x - \
            grid.GetScrollPos(wx.HORIZONTAL) * grid.GetScrollLineX()
        rect_y = grid_rect.y - \
            grid.GetScrollPos(wx.VERTICAL) * grid.GetScrollLineY()

        return wx.Rect(rect_x, rect_y, grid_rect.width, grid_rect.height)
893448
def drawBackground(self, painter, rect):
        
        if not self.pixmap:
            return
        x1, y1, x2, y2 = rect.getCoords()
        width = x2 - x1 + 1
        height = y2 - y1 + 1

        # redraw the screen from backing pixmap
        rect = QtCore.QRect(x1, y1, width, height)
        painter.drawPixmap(rect, self.pixmap, rect)
691836
def draw_rect(self, rect):
        
        check_int_err(lib.SDL_RenderDrawRect(self._ptr, rect._ptr))
852541
def rect_helper(x0, y0, x1, y1):
        """"""
        x0, y0, x1, y1 = force_int(x0, y0, x1, y1)
        if x0 > x1:
            x0, x1 = x1, x0
        if y0 > y1:
            y0, y1 = y1, y0
        return x0, y0, x1, y1