Set the rectangle for the selection.
        :param rectangle:
        :return:
437566
def set_rectangle(self, rectangle):
        
        if rectangle == self.rectangle():
            return False

        if rectangle is None:
            self.reset()
        else:
            self.start_point = QgsPointXY(
                rectangle.xMinimum(), rectangle.yMinimum())
            self.end_point = QgsPointXY(
                rectangle.xMaximum(), rectangle.yMaximum())
            self.show_rectangle(self.start_point, self.end_point)
        return True
345553
def _as_parameter_(self):
        
        return RECT(self.left, self.top, self.right, self.bottom)
1120785
def drag_rectangle_on_map_canvas(self):
        """"""

        self.hide()
        self.rectangle_map_tool.reset()
        self.canvas.unsetMapTool(self.pan_tool)
        self.canvas.setMapTool(self.rectangle_map_tool)
723157
def fill_rect(self, x, y, width, height, color):
        """"""
        # pylint: disable=too-many-arguments, too-many-boolean-expressions
        self.rect(x, y, width, height, color, fill=True)
1095130
public Img cut(Rectangle rectangle) {
		final BufferedImage srcImage = getValidSrcImg();
		rectangle = fixRectangle(rectangle, srcImage.getWidth(), srcImage.getHeight());

		final ImageFilter cropFilter = new CropImageFilter(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
		final Image image = Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(srcImage.getSource(), cropFilter));
		this.targetImage = ImgUtil.toBufferedImage(image);
		return this;
	}
1202428
def add_rect(self, width, height, rid=None):
        
        assert(width > 0 and height > 0)
        if width > max(self.width, self.height) or\
            height > max(self.height, self.width):
            return None

        rect = None
        # If Waste managment is enabled, first try to place the rectangle there
        if self._waste_management:
            rect = self._waste.add_rect(width, height, rid)

        # Get best possible rectangle position
        if not rect:
            rect, _ = self._select_position(width, height)
            if rect:
                self._add_skyline(rect)

        if rect is None:
            return None
        
        # Store rectangle, and recalculate skyline
        rect.rid = rid
        self.rectangles.append(rect)
        return rect
91412
function (x, y, width, height) {
        this._rect = new BoundingRect(x, y, width, height);
        return this._rect;
    }
1139981
public void moveRectangleTo(Rectangle rect, float x, float y) {
		float width = rect.getWidth();
		float height = rect.getHeight();
		rect.setLeft(x);
		rect.setBottom(y);
		rect.setRight(rect.getLeft() + width);
		rect.setTop(rect.getBottom() + height);
	}
1371859
def rectangle(self, rect, attr=None, fill=u' '):
        '''
        oldtop = self.WindowTop
        oldpos = self.pos()
        #raise NotImplementedError
        x0, y0, x1, y1 = rect
        if attr is None:
            attr = self.attr
        if fill:
            rowfill = fill[:1] * abs(x1 - x0)
        else:
            rowfill = u' ' * abs(x1 - x0)
        for y in range(y0, y1):
                System.Console.SetCursorPosition(x0, y)
                self.write_color(rowfill, attr)
        self.pos(*oldpos)
361265
def rectangle(self):
        
        if self.start_point is None or self.end_point is None:
            return QgsRectangle()
        elif self.start_point.x() == self.end_point.x() or \
                self.start_point.y() == self.end_point.y():
            return QgsRectangle()

        return QgsRectangle(self.start_point, self.end_point)
485327
public Rectangle rectangle(float top, float bottom) {
		Rectangle tmp = new Rectangle(this);
		if (getTop() > top) {
			tmp.setTop(top);
			tmp.disableBorderSide(TOP);
		}
		if (getBottom() < bottom) {
			tmp.setBottom(bottom);
			tmp.disableBorderSide(BOTTOM);
		}
		return tmp;
	}
94758
def setRect(self, *args):
        
        if len(args) == 1:
            if isinstance(args[0], tuple):
                x, y, w, h = args[0]
            elif isinstance(args[0], Region):
                x = Region.getX()
                y = Region.getY()
                w = Region.getW()
                h = Region.getH()
            else:
                raise TypeError("Unrecognized arguments for setRect")
        elif len(args) == 4:
            x, y, w, h = args
        else:
            raise TypeError("Unrecognized arguments for setRect")
        self.setX(x)
        self.setY(y)
        self.setW(w)
        self.setH(h)
        return self
419565
public void variableRectangle(Rectangle rect) {
        float t = rect.getTop();
        float b = rect.getBottom();
        float r = rect.getRight();
        float l = rect.getLeft();
        float wt = rect.getBorderWidthTop();
        float wb = rect.getBorderWidthBottom();
        float wr = rect.getBorderWidthRight();
        float wl = rect.getBorderWidthLeft();
        Color ct = rect.getBorderColorTop();
        Color cb = rect.getBorderColorBottom();
        Color cr = rect.getBorderColorRight();
        Color cl = rect.getBorderColorLeft();
        saveState();
        setLineCap(PdfContentByte.LINE_CAP_BUTT);
        setLineJoin(PdfContentByte.LINE_JOIN_MITER);
        float clw = 0;
        boolean cdef = false;
        Color ccol = null;
        boolean cdefi = false;
        Color cfil = null;
        // draw top
        if (wt > 0) {
            setLineWidth(clw = wt);
            cdef = true;
            if (ct == null)
                resetRGBColorStroke();
            else
                setColorStroke(ct);
            ccol = ct;
            moveTo(l, t - wt / 2f);
            lineTo(r, t - wt / 2f);
            stroke();
        }

        // Draw bottom
        if (wb > 0) {
            if (wb != clw)
                setLineWidth(clw = wb);
            if (!cdef || !compareColors(ccol, cb)) {
                cdef = true;
                if (cb == null)
                    resetRGBColorStroke();
                else
                    setColorStroke(cb);
                ccol = cb;
            }
            moveTo(r, b + wb / 2f);
            lineTo(l, b + wb / 2f);
            stroke();
        }

        // Draw right
        if (wr > 0) {
            if (wr != clw)
                setLineWidth(clw = wr);
            if (!cdef || !compareColors(ccol, cr)) {
                cdef = true;
                if (cr == null)
                    resetRGBColorStroke();
                else
                    setColorStroke(cr);
                ccol = cr;
            }
            boolean bt = compareColors(ct, cr);
            boolean bb = compareColors(cb, cr);
            moveTo(r - wr / 2f, bt ? t : t - wt);
            lineTo(r - wr / 2f, bb ? b : b + wb);
            stroke();
            if (!bt || !bb) {
                cdefi = true;
                if (cr == null)
                    resetRGBColorFill();
                else
                    setColorFill(cr);
                cfil = cr;
                if (!bt) {
                    moveTo(r, t);
                    lineTo(r, t - wt);
                    lineTo(r - wr, t - wt);
                    fill();
                }
                if (!bb) {
                    moveTo(r, b);
                    lineTo(r, b + wb);
                    lineTo(r - wr, b + wb);
                    fill();
                }
            }
        }

        // Draw Left
        if (wl > 0) {
            if (wl != clw)
                setLineWidth(wl);
            if (!cdef || !compareColors(ccol, cl)) {
                if (cl == null)
                    resetRGBColorStroke();
                else
                    setColorStroke(cl);
            }
            boolean bt = compareColors(ct, cl);
            boolean bb = compareColors(cb, cl);
            moveTo(l + wl / 2f, bt ? t : t - wt);
            lineTo(l + wl / 2f, bb ? b : b + wb);
            stroke();
            if (!bt || !bb) {
                if (!cdefi || !compareColors(cfil, cl)) {
                    if (cl == null)
                        resetRGBColorFill();
                    else
                        setColorFill(cl);
                }
                if (!bt) {
                    moveTo(l, t);
                    lineTo(l, t - wt);
                    lineTo(l + wl, t - wt);
                    fill();
                }
                if (!bb) {
                    moveTo(l, b);
                    lineTo(l, b + wb);
                    lineTo(l + wl, b + wb);
                    fill();
                }
            }
        }
        restoreState();
    }
951362
def draw_rectangle(x, y, width, height)
      @context.drawRect(x, y, width, height)
    end
236356
function () {
      if (!selection.isSelected()) {
        return;
      }
      var corners = grid.getCornerCoords([priv.selStart, selection.end()]);
      var r, c, changes = [];
      for (r = corners.TL.row; r <= corners.BR.row; r++) {
        for (c = corners.TL.col; c <= corners.BR.col; c++) {
          if (self.getCellMeta(r, c).isWritable) {
            changes.push([r, datamap.colToProp(c), '']);
          }
        }
      }
      self.setDataAtCell(changes);
    }
212938
function(rectangle) {
        return $.Rect.fromSummits(
            this.pointFromPixel(rectangle.getTopLeft(), true),
            this.pointFromPixel(rectangle.getTopRight(), true),
            this.pointFromPixel(rectangle.getBottomLeft(), true)
        );
    }
467748
def set(self, shape):
        
        self.bottom, self.left = shape.bottom, shape.left
        self.width, self.height = shape.width, shape.height
        return self