Exemple #1
0
    print("Output name is", sys.argv[2])


##################################################
# plot simple animation of phases


def myplot(frame, fig):

    ax = fig.add_subplot(111)

    plot.cells(frame, ax)
    plot.solidarea(frame, ax)
    plot.shape(frame, ax)
    plot.velocity(frame, ax)
    plot.pressure_force(frame, ax)
    plot.walls(frame, ax)

    ax.axes.set_aspect('equal', adjustable='box')
    ax.set_xlim([0, frame.parameters['Size'][0]-1])
    ax.set_ylim([0, frame.parameters['Size'][1]-1])
    ax.axis('off')


if len(oname) == 0:
    animation.animate(ar, myplot, show=True)
    exit(0)
else:
    an = animation.animate(ar, myplot, show=False)
    animation.save(an, oname+'.mp4', 5)
Exemple #2
0
    # Set animation parameters according to either input values or default
    # values
    # Repetitions
    if "REPEAT" in parsed_args:
        repeat = \
            parsed_args["REPEAT"].upper() == "TRUE" or \
            parsed_args["REPEAT"].upper() == "T" or \
            parsed_args["REPEAT"].upper() == "1"
    else:
        repeat = co.ANIMATION_REPEAT

    # Interval
    if "INTERVAL" in parsed_args:
        interval = int(parsed_args["INTERVAL"])
    else:
        interval = co.ANIMATION_INTERVAL

    # Run simulation animation
    animation = Animation(my_car, my_trailer, my_controller.state_points)
    simulation = FuncAnimation(fig, animation.update, interval=interval,
                               frames=len(my_controller.state_points),
                               repeat=repeat, blit=True)

    # Save simulation to a file
    if "SAVE" in parsed_args:
        save(simulation, parsed_args["SAVE"])

    # Show animation on screen
    animation.show()