c64_painter.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:Pythonista-C64-Painter 作者: superrune 项目源码 文件源码
def draw_index_array(self, img, indexArray, drawColor=False, noCheck=False):
        with ui.ImageContext(self.width, self.height) as ctx:
            img.draw()
            for i in indexArray:
                # Drawing negative indices will mess up the image, so only indices from 0 and up
                if i >= 0:
                    # Skip checks and undos and just draw the pixels
                    if noCheck==True:
                        p = self.pixels[i]
                        if drawColor != False:
                            p.color = drawColor
                        ui.set_color(p.color)
                        pixel_path = ui.Path.rect(p.rect[0],p.rect[1],p.rect[2],p.rect[3])
                        pixel_path.line_width = 0.0
                        pixel_path.fill()
                        pixel_path.stroke()
                    else:
                        if self.pixels[i].color != self.current_color:
                            if self.checkDither(self.pixels[i].position):
                                self.store_undo_stroke(i)
                                p = self.pixels[i]
                                if drawColor != False:
                                    p.color = drawColor
                                ui.set_color(p.color)
                                #  Path.rect(x, y, width, height)
                                pixel_path = ui.Path.rect(p.rect[0],p.rect[1],p.rect[2],p.rect[3])
                                pixel_path.line_width = 0.0
                                pixel_path.fill()
                                pixel_path.stroke()
            img = ctx.get_image()
        return img

    # Main pixel action function!
    # Called by 'touch_began', touch_moved and touch_ended
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号