From a9eed4f96c5ed458be95349705fe137a1e7bd0f4 Mon Sep 17 00:00:00 2001 From: WIPocket Date: Mon, 4 Apr 2022 11:35:08 +0200 Subject: [PATCH] At function --- lib.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib.py b/lib.py index fc74b16..69a64ee 100644 --- a/lib.py +++ b/lib.py @@ -58,6 +58,12 @@ class Picture: assert result.h == ht return result + def at(x, y): + return self.pixels[ + int(max(0, min(self.h - 1, y))), + int(max(0, min(self.w - 1, x))), + ] + def _to_pil(self): # Create int iterable # TODO: If this is slow, we should use a generator.