Пример #1
0
    o = Point.origin()

    random_force = Force.random()
    # print(random_force)
    random_force += gravity
    # print(random_force)

    result = Force.sum([gravity, propulsion, random_force])
    # print("Force.sum:",result)

    x, y = result
    # print(x,y) #Unpacking is compatible for vectors

    f = gravity
    print(result)

    from mycontext import Context

    context = Context()
    position = (0, 0)
    while context.open:
        context.check()
        context.control()
        context.clear()
        context.show()
        position = context.point()
        f.components = list(position)
        f.show(context, o)
        context.flip()
        # context.wait(0.1)
Пример #2
0
    def showBar(self, context, t, l):
        """Show the bar."""
        v = self.getVector()
        v *= l
        p = self(t)
        v.rotate(math.pi / 2)
        p1 = v(p)
        v.rotate(math.pi)
        p2 = v(p)
        s = Segment(p1, p2)
        s.color = self.color
        s.show(context)


if __name__ == "__main__":
    from mycontext import Context

    surface = Context()
    o = Point.origin()
    s = Step.random()
    print(s)
    while surface.open:
        surface.check()
        surface.control()
        surface.clear()
        surface.show()
        s.rotate(0.001, o)
        o.show(surface)
        s.show(surface)
        surface.flip()