-
Notifications
You must be signed in to change notification settings - Fork 0
API. Scripting
Some quick and dirty notes about scripting and high-level interfaces.
Rationale: high-level easy-to-use interface for rapid prototyping of simple interactive visualizations. Useful tool for teaching Python, programming languages, computer notions, simple graphics, mathematics, colors, fractals, data structures, simple video games, etc. Generate simple visualizations that can be easily converted to pure Javascript (offline) thanks to the Functional interface.
We provide a toolbox of simple high-level functions that wrap visuals, colors, paths, interactivity, functions, etc. These components can be easily combined for creative purposes. This toolbox is extendable using Vispy's core layers (visuals, transforms, shaders, etc.).
Similar ideas:
I think there's a huge demand for this, especially from teachers. It would make quite some publicity for Vispy. The fact that those Python scripts can be converted in HTML/JS and run in the browser would be a huge advantage.
Examples:
-
disc()
displays a disc at the center. -
disc(position=(.5, .5))
displays a disc at the top right. -
disc(position=mouse_position)
displays a disc at the mouse position. -
disc(position=(mouse_position.x, 0)
displays a disc at the mouse x position, fixed on a horizontal line. -
disc(fill='red')
displays a red disc.
Animations:
- A disc that moves from A to B in 2 second.
d = disc()
d.position = interpolate((-.5, 0), (.5, 0), duration=2)
- A disc that changes color from red to blue.
d = disc()
d.color = interpolate((1, 0, 0), (0, 0, 1), duration=2)
- A disc that moves from A to mouse position in 2 second when I click.
d = disc()
@on_click
def go(e):
d.position = interpolate((-.5, 0), mouse_position, duration=2)
- A disc that moves continuously on a circle.
d = disc()
d.position = repeat(circular(center=(0, 0), radius=.5))
- A disc that moves linearly and bounces off the walls.
d = disc()
d.position = bounce_walls(ray(origin=(0,0), direction=(.5, .5)))
These examples are extremely simple. We can easily come up with examples that make better use of the GPU (with many objects, shader effects, particle systems, 3D, etc.).