From 2c4988b86c2d713286f9112df2edb341eafc600f Mon Sep 17 00:00:00 2001 From: dahanzimin <353767514@qq.com> Date: Thu, 29 May 2025 18:24:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0uframebuf=20=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E6=96=B9=E6=B3=95=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../micropython/origin/build/lib/uframebuf.py | 47 ++++--------------- 1 file changed, 10 insertions(+), 37 deletions(-) diff --git a/boards/default_src/micropython/origin/build/lib/uframebuf.py b/boards/default_src/micropython/origin/build/lib/uframebuf.py index 2cc6b742..b12b9163 100644 --- a/boards/default_src/micropython/origin/build/lib/uframebuf.py +++ b/boards/default_src/micropython/origin/build/lib/uframebuf.py @@ -168,53 +168,26 @@ class FrameBuffer_Base(FrameBuffer): def write(self): self.show() - def shift(self, x, y, rotate=False, sync=True): + def shift(self, x, y, sync=True): """Shift pixels by x and y""" - if x > 0: # Shift Right - for _ in range(x): - for row in range(0, self.height): - last_pixel = super().pixel(self.width - 1, row) if rotate else 0 - for col in range(self.width - 1, 0, -1): - super().pixel(col, row, super().pixel(col - 1, row)) - super().pixel(0, row, last_pixel) - elif x < 0: # Shift Left - for _ in range(-x): - for row in range(0, self.height): - last_pixel = super().pixel(0, row) if rotate else 0 - for col in range(0, self.width - 1): - super().pixel(col, row, super().pixel(col + 1, row)) - super().pixel(self.width - 1, row, last_pixel) - if y > 0: # Shift Up - for _ in range(y): - for col in range(0, self.width): - last_pixel = super().pixel(col, self.height - 1) if rotate else 0 - for row in range(self.height - 1, 0, -1): - super().pixel(col, row, super().pixel(col, row - 1)) - super().pixel(col, 0, last_pixel) - elif y < 0: # Shift Down - for _ in range(-y): - for col in range(0, self.width): - last_pixel = super().pixel(col, 0) if rotate else 0 - for row in range(0, self.height - 1): - super().pixel(col, row, super().pixel(col, row + 1)) - super().pixel(col, self.height - 1, last_pixel) + super().scroll(x, y) if sync: self.show() - def shift_right(self, num, rotate=False): + def shift_right(self, num, sync=True): """Shift all pixels right""" - self.shift(num, 0, rotate) + self.shift(num, 0, sync) - def shift_left(self, num, rotate=False): + def shift_left(self, num, sync=True): """Shift all pixels left""" - self.shift(-num, 0, rotate) + self.shift(-num, 0, sync) - def shift_up(self, num, rotate=False): + def shift_up(self, num, sync=True): """Shift all pixels up""" - self.shift(0, -num, rotate) + self.shift(0, -num, sync) - def shift_down(self, num, rotate=False): + def shift_down(self, num, sync=True): """Shift all pixels down""" - self.shift(0, num, rotate) + self.shift(0, num, sync) def map_invert(self, own): """Graph invert operation"""