changed the way to call Point2D functions.
Added missing point array generation code
This commit is contained in:
parent
3a9be4e4ea
commit
d35fc3b1ea
2 changed files with 26 additions and 11 deletions
|
|
@ -77,6 +77,21 @@ def generate_point_array_from_image(image):
|
|||
|
||||
if image_hash in cached_point_arrays:
|
||||
return [Point2D(point["x"], point["y"], tuple(point["color"])) for point in cached_point_arrays[image_hash]]
|
||||
|
||||
width, height = image.size
|
||||
pixel_array = []
|
||||
|
||||
for y in range(height):
|
||||
for x in range(width):
|
||||
pixel = image.getpixel((x, y))
|
||||
if pixel != (0, 0, 0): # any non-white pixels
|
||||
point = {"x": x, "y": y, "color": pixel}
|
||||
pixel_array.append(point)
|
||||
|
||||
cached_point_arrays[image_hash] = pixel_array
|
||||
save_cached_point_arrays(cached_point_arrays)
|
||||
|
||||
return [Point2D(point["x"], point["y"], tuple(point["color"])) for point in pixel_array]
|
||||
|
||||
|
||||
def generate_image_from_point_array(points: list[Point2D], width: int, height: int) -> Image:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue