Jul-06-2019, 02:01 PM
(This post was last modified: Jul-06-2019, 02:01 PM by DreamingInsanity.)
As for speeding it up - I now have this:
It is considerably faster than before, however, even with my image (1000x563) It still takes over 5 mins to draw it on the canvas.
What else can I do to speed it up?
EDIT: explanation
from PIL import Image from turtle import * image_path = "image.png" loaded_image = None x, y, old_x = 0, 0, 0 def convert_img(): image_file = Image.open(image_path) image_file = image_file.convert('L') image_file.save('bw_image.png') def get_pix_col(pixels, x, y): return pixels[x,y] def draw(img, pixels): global old_x, x ,y while x < img.size[0]: while y < img.size[1]: pendown() brightness = get_pix_col(pixels, x, y) color(brightness, brightness, brightness) if(x == old_x): goto((-img.size[0]/2) + x, (img.size[1]/2) - y) else: penup() goto((-img.size[0]/2) + x, (img.size[1]/2) - y) old_x = x y += 1 update() x += 1 y = 0 done() def main(): convert_img() loaded_image = Image.open('bw_image.png') pix = loaded_image.load() canvas_setup(loaded_image) draw(loaded_image, pix) def canvas_setup(img): colormode(255) setup(img.size[0], img.size[1]) bgcolor(0, 0, 0) tracer(0, 0) speed("fastest") penup() setposition(-img.size[0] / 2, img.size[1] / 2) main()All it does now is update the screen only once one line of the x has been completed. The auto screen refresh was disabled.
It is considerably faster than before, however, even with my image (1000x563) It still takes over 5 mins to draw it on the canvas.
What else can I do to speed it up?
EDIT: explanation