예제 #1
0
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:
예제 #2
0
    p2 = Point(-2, 4)
    p3 = Point(8, 5)
    p4 = Point(4, 4, color=(0, 255, 0))
    points = [p1, p3, p2, p4]
    f = Form([
        Point(random.randint(-10, 10), random.randint(-10, 10))
        for i in range(10)
    ])
    #f.show(window)
    f2 = f.getSparse()
    p1.show(window)
    p2.show(window)
    v1 = Vector(p2[0] - p1[0], p2[1] - p1[1], color=(255, 0, 0))

    while window.open:
        window.check()
        window.clear()
        window.draw.control()
        v1.rotate(0.1)
        v2 = v1 % (pi / 2)
        v2.color = GREEN
        v2.rotate(0.1)
        f2.rotate(0.1)
        center = f2.center()
        center.color = BLUE
        #center.radius=0.1
        A = v1(center)
        window.draw.show()
        center.show(window)
        v1.show(center, window)
        v2.show(A, window)