def paintEvent(self, event: QPaintEvent): painter = QPainter(self) bg_color = bg_color_for_object_set(self.object_set, 0) painter.setBrush(QBrush(bg_color)) painter.drawRect(QRect(QPoint(0, 0), self.size())) pattern_table = PatternTable(self.object_set) palette = load_palette(self.object_set, 0) tsa_data = ROM.get_tsa_data(self.object_set) horizontal = self.sprites_horiz block_length = Block.WIDTH * self.zoom for i in range(self.sprites): block = Block(i, palette, pattern_table, tsa_data) x = (i % horizontal) * block_length y = (i // horizontal) * block_length block.draw(painter, x, y, block_length) return
def _draw_background(self, painter: QPainter, level: Level): painter.save() bg_color = bg_color_for_object_set(level.object_set_number, level.header.object_palette_index) painter.fillRect(level.get_rect(self.block_length), bg_color) painter.restore()
def _draw_background(self, painter: QPainter, level: Level): painter.save() if level.object_set_number == CLOUDY_OBJECT_SET: bg_color = QColor( *NESPalette[load_palette_group(level.object_set_number, level.header.object_palette_index)[3][2]] ) else: bg_color = bg_color_for_object_set(level.object_set_number, level.header.object_palette_index) painter.fillRect(level.get_rect(self.block_length), bg_color) painter.restore()
def as_image(self) -> QImage: self.rendered_base_x = 0 self.rendered_base_y = 0 image = QImage( QSize(self.rendered_width * Block.SIDE_LENGTH, self.rendered_height * Block.SIDE_LENGTH), QImage.Format_RGB888, ) bg_color = bg_color_for_object_set(self.object_set.number, 0) image.fill(bg_color) painter = QPainter(image) self.draw(painter, Block.SIDE_LENGTH, True) return image