def show(self, surface, position): """Show the pixel on screen.""" x, y = position sx, sy = self.size p1 = Point(x, y) p2 = Point(x + sx, y) p3 = Point(x + sx, y + sy) p4 = Point(x, y + sy) points = [p1, p2, p3, p4] form = Form(points, fill=True, area_color=self.color, point_show=False) form.show(surface)
#print(line|segment) import mycolors import math ps = [Point(-1, -1), Point(1, -1), Point(1, 1), Point(-1, 1)] f = Form(ps) while surface.open: surface.check() surface.control() surface.clear() surface.show() position = tuple(surface.point()) p = Point(*position) h = HalfLine(p, 0) ps = f.crossHalfLine(h) print(ps) f.color = mycolors.WHITE if p in f: f.color = mycolors.RED if len(ps) % 2 == 1: f.color = mycolors.ORANGE h.show(surface) f.show(surface) surface.flip()