def draw(self, context): """ Draws a rectangle around the selected tiles """ x, y, w, h = rectangleSelect(self.selectX1, self.selectY1, self.selectX2, self.selectY2, self.getController().mapTileSize()) # semi-transparent square fc = graphics.getHighlightColor() hc = graphics.getBackgroundColor() context.set_source_rgba(fc.r, fc.g, fc.b, 0.5) context.rectangle(x, y, w, h) context.fill() context.rectangle(x + 0.5, y + 0.5, w, h) context.set_source_rgba(fc.r, fc.g, fc.b, 1.0) context.set_line_width(3.0) context.stroke() context.rectangle(x + 0.5, y + 0.5, w, h) context.set_source_rgba(hc.r, hc.g, hc.b, 1.0) context.set_line_width(1.0) context.stroke()
def draw(self, context): if self.__brush is None or self.getPointer() == False: return ts = self.getController().mapTileSize() if self.buttonDown: x, y, w, h = rectangleSelect(self.selectX1, self.selectY1, self.selectX2, self.selectY2, ts) pattern = cairo.SurfacePattern(self.__brush) pattern.set_extend(cairo.EXTEND_REPEAT) matrix = cairo.Matrix() matrix.translate(-x, -y) pattern.set_matrix(matrix) context.set_source(pattern) context.rectangle(x, y, w, h) context.fill() else: x = self.lastX * ts y = self.lastY * ts context.set_source_surface(self.__brush, x, y) w = (abs(self.selectionX2 - self.selectionX1) + 1) * ts h = (abs(self.selectionY2 - self.selectionY1) + 1) * ts context.rectangle(x, y, w, h) context.fill() fc = graphics.getHighlightColor() hc = graphics.getBackgroundColor() context.set_source_rgba(fc.r, fc.g, fc.b, 0.5) context.rectangle(x, y, w, h) context.fill() context.rectangle(x + 0.5, y + 0.5, w, h) context.set_source_rgba(fc.r, fc.g, fc.b, 1.0) context.set_line_width(3.0) context.stroke() context.rectangle(x + 0.5, y + 0.5, w, h) context.set_source_rgba(hc.r, hc.g, hc.b, 1.0) context.set_line_width(1.0) context.stroke()