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
评论列表
文章目录