1. fieldanimation
Package¶
fieldanimation classes:

-
fieldanimation.
glInfo
()[source]¶ Return OpenGL information dict WARNING: OpenGL context MUST be initialized !!!
Parameters: None – Returns: OpenGL information dict
-
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 instanceReturns: ( 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.
modulus
(field)[source]¶ Return normalized modulus of 2D field image
Returns: normalized modulus of 2D field image (i.e. scaled in [0, 1.])
-
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) –
-
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
-
tracersCount
¶ Return tracers count
Returns: number of tracers
-
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
1.1. shader
Module¶
shader classes:

-
class
fieldanimation.shader.
Shader
(path=None, **kargs)[source]¶ Bases:
object
Base shader class
-
addUniform
(uniform, utype=None)[source]¶ Add a uniform variable to the shader. If utype is not none it defines the setter function. Valid utypes are i, b, f, 2f, 4fv
-
unbind
()[source]¶ Unbind whatever program is currently bound - not necessarily this program, so this should probably be a class method instead.
-
1.2. texture
Module¶
texture classes:
