from mysurface import Surface surface = Surface(name="Test") #line=Line.random() #segment=Segment.random() #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
#f1=Form([Point(*posAlea()) for i in range(5)],fill=True) #Obsolete #f1=f1.getSparse() f1 = Form.random(5, -10, 10) #f2=Form([Point(*posAlea()) for i in range(5)]) #f2=f2.getSparse() f2 = Form.random(5, -10, 10) #f1.points[0].color=(255,0,0) #f1.points[1].color=(255,0,0) while window.open: window.check() window.clear() window.show() window.control() f1.rotate(0.01, f1[0]) #f1.rotate(-0.01) f2.rotate(0.02, f1[1]) f2.rotate(-0.03) f1.show(window) f2.show(window) f1.center(color=(0, 255, 0)).show(window) f2.center(color=(0, 255, 0)).show(window) if f1 | f2: f1.color(RED) f2.color(RED) else: f1.color(WHITE) f2.color(WHITE) f1[0].show(window, color=(255, 0, 0))