def paintEvent(self, event): # noinspection PyNoneFunctionAssignment images = self.images() size = self.size() w = size.width() h = size.height() painter = QPainter(self) painter.drawImage(QPoint(-10, -10), images.nw.qimage) painter.drawImage(QRect(30, -10, w - 60, -10), images.n.qimage) painter.drawImage(QPoint(w - 30, -10), images.ne.qimage) painter.drawImage(QRect(w - 10, 30, -10, h - 60), images.e.qimage) painter.drawImage(QPoint(w - 30, h - 30), images.se.qimage) painter.drawImage(QRect(30, h - 10, w - 60, -10), images.s.qimage) painter.drawImage(QPoint(-10, h - 30), images.sw.qimage) painter.drawImage(QRect(-10, 30, -10, h - 60), images.w.qimage)
def paintEvent(self, event): # noinspection PyNoneFunctionAssignment images = self.images() w = self.width() h = self.height() from fsui.qt import QPainter, QPoint, QRect painter = QPainter(self) painter.drawImage(QPoint(0, 0), images.nw.qimage) painter.drawImage(QRect(40, 0, w - 80, 20), images.n.qimage) painter.drawImage(QPoint(w - 40, 0), images.ne.qimage) painter.drawImage(QRect(w - 20, 40, 20, h - 80), images.e.qimage) painter.drawImage(QPoint(w - 40, h - 40), images.se.qimage) painter.drawImage(QRect(40, h - 20, w - 80, 20), images.s.qimage) painter.drawImage(QPoint(0, h - 40), images.sw.qimage) painter.drawImage(QRect(0, 40, 20, h - 80), images.w.qimage)
def clear(self, color=None): # assuming here that the operations are clipped anyway, so just # using an larger-than-expected size rect = QRect(0, 0, 3000, 2000) if color is not None: self.qpainter.fillRect(rect, QBrush(color)) else: self.qpainter.eraseRect(rect)
def paintEvent(self, event): painter = QPainter(self) painter.setRenderHints(QPainter.Antialiasing) pen = QPen(QColor(0x80, 0x80, 0x80)) pen.setWidth(2) painter.setPen(pen) painter.setBrush(QBrush(Qt.white)) x = 1 y = 1 w = self.width() - 2 h = self.height() - 2 rect = QRect(x, y, w, h) painter.drawEllipse(rect) cx = x + w / 2 cy = y + h / 2 a = w / 2 * 0.85 b = h / 2 * 0.85 pen.setWidth(0) painter.setPen(pen) painter.setBrush(QBrush(Qt.black)) for i in range(12): px = cx + a * math.cos(2 * math.pi * i / 12) py = cy + b * math.sin(2 * math.pi * i / 12) painter.drawEllipse(px - 3, py - 3, 6, 6) hours, minutes, seconds = self.time[3:] minutes += seconds / 60.0 hours += minutes / 60.0 a = w / 2 * 0.6 b = h / 2 * 0.6 pen.setWidth(4) painter.setPen(pen) self.draw_hand_line(painter, w, h, cx, cy, a, b, 2.0 * math.pi * hours / 12) a = w / 2 * 0.8 b = h / 2 * 0.8 pen.setWidth(3) painter.setPen(pen) self.draw_hand_line(painter, w, h, cx, cy, a, b, 2.0 * math.pi * minutes / 60) pen = QPen(QColor(0xFF, 0x00, 0x00)) pen.setWidth(2) painter.setPen(pen) self.draw_hand_line(painter, w, h, cx, cy, a, b, 2.0 * math.pi * seconds / 60)
def create_retroarch_layout(self): if self.stretching() == self.STRETCH_FILL_SCREEN or not self.bezel(): return if not self.use_fullscreen(): return # FIXME: file cmp? paths = self.prepare_emulator_skin() print(paths) # FIXME: SUPPORT frame = 0 ( bezel = 0) option # FIXME: With no bezel, we should still use a black bezel to # hide screen stretching screen_width, screen_height = self.screen_size() # dst_x = 0 dst_y = 0 # dst_w = 0 # dst_w = 160 dst_h = screen_height # Bezel size is normalized against 1080 (height) scale = screen_height / 1080 # Bezel width: 160 dst_w = round(160 * scale) game_x, game_y, game_w, game_h = self.display_rect_fullscreen() from fsui.qt import Qt, QImage, QPainter, QRect, QSize image = QImage(QSize(screen_width, screen_height), QImage.Format_RGBA8888) image.fill(Qt.transparent) # painter = image.paintEngine() painter = QPainter(image) dst_x = game_x - dst_w left = QImage(paths["left"]) painter.drawImage(QRect(dst_x, dst_y, dst_w, dst_h), left) dst_x = game_x + game_w right = QImage(paths["right"]) painter.drawImage(QRect(dst_x, dst_y, dst_w, dst_h), right) painter.end() overlay_png_file = self.temp_file("overlay.png").path image.save(overlay_png_file) # noinspection SpellCheckingInspection overlay_config = """overlays = 1 overlay0_overlay = {overlay} overlay0_full_screen = true overlay0_rect = "0.0,0.0,1.0,1.0" overlay0_descs = 0 """.format(overlay=overlay_png_file) # overlay_config = ( # """overlays = 2 # overlay0_overlay = {left} # overlay0_full_screen = true # overlay0_rect = "0.0,0.0,0.12,1.0" # overlay0_descs = 0 # overlay1_overlay = {right} # overlay1_full_screen = true # overlay1_rect = "0.8,0.0,0.2,1.0" # overlay1_descs = 0 # # """.format(left=paths["left"], right=paths["right"])) overlay_config_file = self.temp_file("overlay.cfg") with open(overlay_config_file.path, "w") as f: f.write(overlay_config) return overlay_config_file.path