@@ -3,24 +3,24 @@ import numpy as np
33
44
55data Point(x, y):
6- def __add__(self, other is Point) = Point(self.x + other.x, self.y + other.y)
6+ def __add__(self, Point(other) ) = Point(self.x + other.x, self.y + other.y)
77
88
99# This function is necessary, because negative indices wrap around the
1010# array in Coconut.
11- def inbounds(canvas_shape, location is Point) =
11+ def inbounds(canvas_shape, Point(location) ) =
1212 min(location) >= 0 and location.x < canvas_shape[0] and location.y < canvas_shape[1]
1313
1414
15- def find_neighbours(canvas, location is Point, old_value):
15+ def find_neighbours(canvas, Point(location) , old_value):
1616 possible_neighbours = ((Point(0, 1), Point(1, 0), Point(0, -1), Point(-1, 0))
1717 |> map$(location.__add__))
1818
1919 yield from possible_neighbours |> filter$(x -> (inbounds(canvas.shape, x)
2020 and canvas[x] == old_value))
2121
2222
23- def stack_fill(canvas, location is Point, old_value, new_value):
23+ def stack_fill(canvas, Point(location) , old_value, new_value):
2424 if new_value == old_value or not inbounds(canvas.shape, location):
2525 return
2626
@@ -33,7 +33,7 @@ def stack_fill(canvas, location is Point, old_value, new_value):
3333 stack.extend(find_neighbours(canvas, current_location, old_value))
3434
3535
36- def queue_fill(canvas, location is Point, old_value, new_value):
36+ def queue_fill(canvas, Point(location) , old_value, new_value):
3737 if new_value == old_value or not inbounds(canvas.shape, location):
3838 return
3939
@@ -49,7 +49,7 @@ def queue_fill(canvas, location is Point, old_value, new_value):
4949 queue.append(neighbour)
5050
5151
52- def recursive_fill(canvas, location is Point, old_value, new_value):
52+ def recursive_fill(canvas, Point(location) , old_value, new_value):
5353 if new_value == old_value or not inbounds(canvas.shape, location):
5454 return
5555
0 commit comments