Example #1
0
    corners=[-1,-1,1,1]
    cs=[Circle.random(corners,color=mycolors.random()) for i in range(10)]

    fill=False
    c1_border_color=mycolors.random()
    c2_border_color=mycolors.random()
    c1_area_color=mycolors.random()
    c2_area_color=mycolors.random()

    while surface.open:
        surface.check()
        surface.control()
        surface.clear()
        surface.show()

        x,y=surface.point()
        c1.setPosition(x,y)
        if c1.crossCircle(c2):
            fill=False
            c1_border_color=mycolors.random()
            c2_border_color=mycolors.random()
        else:
            fill=True
            c1_area_color=mycolors.random()
            c2_area_color=mycolors.random()

        vector=Vector.createFromTwoPoints(c1.center,c2.center)
        vector.show(surface,c1.center,color=mycolors.GREEN)

        c1.show(surface,border_color=c1_border_color,area_color=c1_area_color,fill=fill)
        c1.showText(surface,"C1")
Example #2
0
#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

    h.show(surface)
    f.show(surface)
    surface.flip()
p3=Point(0,1)

s1=Segment(p1,p2,width=3)
s2=Segment(p2,p3,width=3)

e=10e-10

surface=Surface()

while surface.open:
    surface.check()
    surface.control()
    surface.clear()
    surface.show()

    p=Point(list(surface.point()))
    #if p in surface:
    s1.p2=p
    if s1.crossSegment(s2):
        s1.color=mycolors.RED
        s2.color=mycolors.RED
    else:
        s1.color=mycolors.WHITE
        s2.color=mycolors.WHITE
    l1=s1.getLine()
    l2=s2.getLine()
    l1.color=mycolors.GREEN
    l1.width=1
    l2.color=mycolors.GREEN
    l2.width=1
    l1.show(surface)