fieldanimation
package reference¶

-
class
fieldanimation.
FieldAnimation
(width, height, field, computeSahder=False, image=None)[source]¶ Bases:
object
Field Animation with OpenGL
- draw the modulus of the vector field or a user defined image
if requested;
- set a framebuffer texture (screen texture) as the main
- rendering target:
draw the background texture on the screen texture with a fixed opacity;
decode the particles positions from the currentTracersPosition texture and draw them on the screen texture;
set the rendering target to the active window;
draw screen texture on the active window;
swap screen texture and background texture;
- calculate the new particles positions
(in the update shader) and encode them in the nextTracersPosition texture;
- swap nextTracersPosition texture and
currentTracersPosition texture;
-
__init__
(width, height, field, computeSahder=False, image=None)[source]¶ Animate 2D vector field
- Parameters
width (int) – width in pixels
height (int) – height in pixels
field (np.ndarray) – 2D vector field
= True selects the compute shader version (cs) –
= Optional background image (image) –
-
draw
()[source]¶ Render the OpenGL scene. This method is called automatically when the scene has to be rendered and is responsible for the animation.
-
drawModulus
(opacity)[source]¶ Draw the modulus texture.
- Parameters
opacity (float) – opacity (alpha) of the texture: 0 –> transparent 1 –> opaque
-
drawTexture
(texture, opacity)[source]¶ Draw texture on the screen.
- Parameters
( (texture) – class:Texture): texture instance
opacity (float) – opacity (alpha) of the texture 0 –> transparent 1 –> opaque
-
setField
(field)[source]¶ Set the 2D vector field. Must be called every time a new vetor field is selected.
- Parameters
field (np.ndarray) – 2D vector field
-
setRenderingTarget
(texture)[source]¶ Set texture as rendering target
- Parameters
(class (texture) – texture instance): 2D vector field
-
setSize
(width, height)[source]¶ Set instance size. Must be called when the window is resized.
- Parameters
width (int) – window width in pixels
height (int) – window height in pixels
-
property
tracersCount
¶ Return tracers count
- Returns
number of tracers
-
fieldanimation.
field2RGB
(field)[source]¶ Return 2D field converted to uint8 RGB image (i.e. scaled in [0, 255])
- Parameters
field (
numpy.ndarray
) – (u, v) 2D vector field instance- Returns
( rgb (
numpy.ndarray
): uint8 RGB image, uMin (float): u min, uMax (float): u max, vMin (float): v min, vMax (float): v max, ) (tuple): Return value
-
fieldanimation.
glInfo
()[source]¶ Return OpenGL information dict WARNING: OpenGL context MUST be initialized !!!
- Parameters
None –
- Returns
OpenGL information dict
-
fieldanimation.
modulus
(field)[source]¶ Return normalized modulus of 2D field image
- Returns
normalized modulus of 2D field image (i.e. scaled in [0, 1.])
fieldanimation.shader
¶

fieldanimation.texture
Module¶
