From f6be7ba070764b816ff6d7c30bb1fd911798ccb4 Mon Sep 17 00:00:00 2001 From: Jerry Date: Fri, 10 Mar 2023 17:29:43 +0800 Subject: [PATCH] a --- a.py | 4 +++- draw-gen3.py | 11 ++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/a.py b/a.py index 5e3b0d9..3d1c318 100644 --- a/a.py +++ b/a.py @@ -4,6 +4,7 @@ parser.add_argument('--skip', type=int, default=0, help="skip x lines (unused)") parser.add_argument('--drawfirst', action='store_true', help="draw image first (unused)") parser.add_argument('--slp', type=float, default=0.0001, help="sleep x seconds after each ping") parser.add_argument('--slp1', type=float, default=0.5, help="sleep x seconds after each frame") +parser.add_argument('--rotate', type=int, default=0, help="rotate image for x deg") parser.add_argument('-i', '--image', type=str, default='1.png', help="input image") args = parser.parse_args() skip, slp, slp1, draw_img = args.skip, args.slp, args.slp1, args.drawfirst @@ -72,7 +73,8 @@ from PIL import Image imgdvd = Image.open('dvd.png') imgdvd = imgdvd.convert('RGBA') -#imgdvd = imgdvd.rotate(180) +if args.rotate == 180: + imgdvd = imgdvd.rotate(args.rotate) icmp6pkt = ICMP6(None, 0xad, 0, b'')._create_packet() import concurrent.futures diff --git a/draw-gen3.py b/draw-gen3.py index a22b269..e9152ad 100644 --- a/draw-gen3.py +++ b/draw-gen3.py @@ -4,8 +4,10 @@ import argparse parser = argparse.ArgumentParser() parser.add_argument('--skip', type=int, default=0, help="skip x lines (unused)") parser.add_argument('--drawfirst', action='store_true', help="draw image first (unused)") +parser.add_argument('--keepdrawing', action='store_true', help="keepdrawing, sleep for slp1") parser.add_argument('--slp', type=float, default=0.0001, help="sleep x seconds after each ping") parser.add_argument('--slp1', type=float, default=0.5, help="sleep x seconds after each frame") +parser.add_argument('--rotate', type=int, default=0, help="rotate image for x deg") parser.add_argument('-i', '--image', type=str, default='1.png', help="input image") args = parser.parse_args() skip, slp, slp1, draw_img = args.skip, args.slp, args.slp1, args.drawfirst @@ -155,6 +157,9 @@ def draw(img): print(f"{1000*(end-start):.1f}ms {1000*(end-startsend):.1f}ms") LANCZOS = Image.Resampling.LANCZOS if getattr(Image, 'Resampling', None) else Image.LANCZOS -ldraw = img.copy() -draw(Image.open(args.image).convert('RGBA').resize((X, Y), LANCZOS)) -print('success') +to_draw = Image.open(args.image).convert('RGBA').rotate(args.rotate).resize((X, Y), LANCZOS) +while True: + ldraw = img.copy() + draw(to_draw) + if not args.keepdrawing: + break