from PIL import Image

def is_point_in_path(x: int, y: int, poly: list[tuple[int, int]]) -> bool:
    """Determine if the point is on the path, corner, or boundary of the polygon

    Args:
      x -- The x coordinates of point.
      y -- The y coordinates of point.
      poly -- a list of tuples [(x, y), (x, y), ...]

    Returns:
      True if the point is in the path or is a corner or on the boundary"""
    c = False
    for i in range(len(poly)):
        ax, ay = poly[i]
        bx, by = poly[i - 1]
        if (x == ax) and (y == ay):
            # point is a corner
            return True
        if (ay > y) != (by > y):
            slope = (x - ax) * (by - ay) - (bx - ax) * (y - ay)
            if slope == 0:
                # point is on boundary
                return True
            if (slope < 0) != (by < ay):
                c = not c
    return c

star = [(80,0), (102,56), (160,60), (116,93), (131,143), (84,115), (35,143), (49,93), (0,62), (63,57)]

image = Image.new(mode="RGB", size=(160,143))

for y in range(0,143):
	for x in range(0,160):
		o = is_point_in_path(x, y, star);
		if o == True:
			image.putpixel((x,y), (0,0,0))
		else:
			image.putpixel((x,y), (255,255,255))

image.save("vector.png")
