Bases: Boost.Python.instance
A Canvas is a tree of nodes. It is the place where a scenegraph is displayed. In a libavg session, there is one main canvas that corresponds to the screen and zero or more canvases that are rendered offscreen.
Returns the element in the canvas’s tree that has the id given.
Returns the image the canvas has last rendered as Bitmap. For the main canvas, this is a real screenshot. For offscreen canvases, this is the image rendered offscreen.
Returns the root of the scenegraph. For the main canvas, this is an AVGNode. For an offscreen canvas, this is a CanvasNode.
Bases: libavg.avg.Canvas
An OffscreenCanvas is a Canvas that is rendered to a texture. It can be referenced in the href attribute of an image node. See https://www.libavg.de/wiki/index.php/Offscreen_Rendering for an in-depth explanation of using offscreen rendering. Offscreen canvases are created by calling Player.loadCanvasFile() and Player.loadCanvasString().
Turns autorendering on or off. Default is True.
True if events that arrive at an image node that is displaying this canvas are routed to the offscreen canvas. Read-only.
True if mipmaps are generated and used for the canvas. This is used instead of RasterNode.mipmap for images that render the canvas. Read-only.
Number of samples per pixel to use for multisampling. Setting this to 1 disables multisampling. Read-only.
Returns the id of the canvas. This is the same as calling canvas.getRootNode().getID().
Returns the number of canvases that reference this canvas. Used mainly for unit tests.
Forces an immediate redraw of the offscreen canvas. This makes sure that following calls to screenshot() get a current version of the canvas and is usually used in combination with autorender=False.
True if the machine’s OpenGL implementation supports offscreen multisampling.
Bases: Boost.Python.instance
The class used to load and play avg files and the main interface to the avg renderer. Player is a singleton. There is only one instance, accessed by get().
A colon-separated list of directories where the player searches for plugins when loadPlugin() is called.
Total audio playback volume. 0 is silence, 1 passes media file volume through unchanged. Values higher than 1 can be used to amplify playback. A limiter prevents distortion when the volume is set to high.
Adds a camera-based multitouch tracker to the avg player. The tracker can be configured using the avgtrackerrc file and immediately starts reporting events.
Note that there are currently two distinct methods of enabling multitouch: addTracker() enables the internal tracker. To enable the newer tracker driver subsystem, call enableMultitouch().
Stops a timeout, an interval or an onFrameHandler from being called. Returns True if there was an interval with the given id, False if not.
| Parameters: |
|
|---|
Creates a new Node. This node can be used as parameter to DivNode.appendChild() and DivNode.insertChild(). This method will create any type of node, including <div> nodes with children.
| Parameters: |
|
|---|
Creates a new Node. This node can be used as parameter to DivNode.appendChild() and DivNode.insertChild(). This method will only create one node at a time.
| Parameters: |
|
|---|
Removes the canvas given by id from the player’s internal list of canvases. It is an error to delete a canvas that is still referenced by an image node.
Enables or disables audio playback. If audio playback is disabled, no nodes with sound can be created. Mainly used to speed up the test suite.
Enables the multitouch driver subsystem. This subsystem uses external drivers to generate multitouch events. Currently available are TUIO and Mac OS X Multitouch Trackpad drivers, with TUIO being the default. To choose the driver to use, set the environment variable AVG_MULTITOUCH_DRIVER to TUIO or APPLETRACKPAD.
To enable the internal tracker, don’t call enableMultitouch(). Call addTracker() instead.
Returns the offscreen canvas with the id given.
Returns the framerate that the player is actually achieving. The value returned is not averaged and reflects only the current frame.
Returns an element in the main avg tree.
| Parameters: |
|
|---|
Returns the last event hook set using setEventHook().
Returns the duration of the last frame in milliseconds.
Returns the current target framerate in frames per second. To get the actual framerate that the player is currently achieving, call getEffectiveFramerate().
Returns the number of milliseconds that have elapsed since playback has started. Honors FakeFPS. The time returned stays constant for an entire frame; it is the time of the last display update.
Returns the current modifier keys (shift, ctrl) pressed. The return value is several KeyModifier values or’ed together.
Returns the main canvas. This is the canvas loaded using loadFile() or loadString() and displayed on screen.
Returns the last mouse event generated.
Returns the outermost element in the main avg tree.
Returns a tracker previously created with addTracker().
Returns the current hardware video refresh rate in number of refreshes per second.
Loads the canvas file specified in filename and adds it to the registered offscreen canvases.
Parses avgString, loads the nodes it contains and adds the hierarchy to the registered offscreen canvases.
| Parameters: |
|
|---|
Loads the avg file specified in filename. Returns the canvas loaded. The canvas is the main canvas displayed onscreen.
Load a Plugin.
| Parameters: |
|
|---|
Parses avgString and loads the nodes it contains. Returns the canvas loaded. The canvas is the main canvas displayed onscreen.
| Parameters: |
|
|---|
Opens a playback window or screen and starts playback. play returns when playback has ended.
Returns the contents of the current screen as a bitmap.
Sets the mouse cursor to the bitmap given. The bitmap must have a size divisible by 8 and an RGBA pixel format. The cursor generated is binary black and white with a binary transparency channel. hotspot is the relative position of the actual pointing coordinate in the bitmap.
Set a callable which will receive all events before the standard event handlers receive them. If this callable returns True, the event is not propagated to the standard event handlers.
Generally, setEventHook() should be used as a last resort. In most cases, standard event handlers are a lot cleaner. Also, setting several event hooks is not supported by libavg. To get around this limitation, you can use getEventHook() to chain event hook functions.
Note that event.node is not set in the callback, since the system hasn’t determined the node to send the event to at that point.
Sets a fixed number of virtual frames per second that are used as clock source for video playback, animations and other time-based actions. If a value of -1 is given as parameter, the real clock is used. setFakeFPS() can be used to get reproducible results for recordings or automated tests. Setting FakeFPS has the side-effect of disabling audio.
Sets the desired framerate for playback. Turns off syncronization to the vertical blanking interval.
Sets display gamma. This is a control for overall brightness and contrast that leaves black and white unchanged but adjusts greyscale values. 1.0 is identity, higher values give a brighter image, lower values a darker one.
Sets a python callable object that should be executed regularly. setInterval() returns an id that can be used to call clearInterval() to stop the function from being called. The callback is called at most once per frame.
| Parameters: |
|
|---|
Sets the position of the mouse cursor. Generates a mouse motion event.
Sets the number of samples per pixel to compute. This costs performance and smoothes the edges of polygons. A value of 1 turns multisampling (also knowna as FSAA - Full-Screen Antialiasing) off. Good values are dependent on the graphics driver and the performance of the graphics card.
Determines which OpenGL extensions to check for and use if possible. This method is mainly used for debugging purposes while developing libavg, but can also be used to work around buggy drivers. The values set here override those in the avgrc file. Note that with the exception of multiSampleSamples, fallbacks are always used - if a feature is specified that the system doesn’t support, a less demanding one will be used.
Must be called before play().
| Parameters: |
|
|---|
Sets a python callable object that should be executed once per frame. This is the same as setInterval(0, pyfunc). Returns an id that can be used to call clearInterval() to stop the function from being called.
| Parameters: |
|
|---|
Sets display engine parameters. Must be called before loadFile() or loadString().
| Parameters: |
|
|---|
Sets a python callable object that should be executed after a set amount of time. setTimeout() returns an id that can be used to call clearInterval() to stop the function from being called.
| Parameters: |
|
|---|
Sets the desired number of monitor refreshes before the next frame is displayed. The resulting framerate is determined by the monitor refresh rate divided by the rate parameter.
| Parameters: |
|
|---|
hasWindowFrame should be set to True if a non-fullscreen player should have a window frame. If set to False, the player runs with no title bar or window frame. Must be called before play() is called.
Sets the location of the player window. Must be called before loadFile or loadString.
Shows or hides the mouse cursor.
| Parameters: |
|
|---|
Stops playback and resets the video mode if necessary.
Toggles player stop upon escape keystroke. If stop is True (the default), if player will halt playback when Esc is pressed.
This method gives access to the player instance. If no player has been created yet, a player is created.