Picasso API  2.9
Functions
XSvg Functions

Functions

PEXPORT psx_result PICAPI psx_svg_init (void)
 Initialze the library and load resources. More...
 
PEXPORT void PICAPI psx_svg_shutdown (void)
 Release resources and shutdown. More...
 
PEXPORT psx_svg *PICAPI psx_svg_load (const char *file_name, psx_result *err_code)
 Create a new psx_svg object and load from file. More...
 
PEXPORT psx_svg *PICAPI psx_svg_load_from_memory (const ps_byte *data, size_t length, psx_result *err_code)
 Create a new psx_svg object and load data from memory. More...
 
PEXPORT void PICAPI psx_svg_destroy (psx_svg *doc)
 Destroy the psx_svg object and release resources. More...
 
PEXPORT void PICAPI psx_svg_render_destroy (psx_svg_render *render)
 Destroy the psx_svg_render object and release resources. More...
 
PEXPORT psx_result PICAPI psx_svg_render_draw (ps_context *ctx, const psx_svg_render *render)
 Draws an psx_svg_render object into the given context. More...
 
PEXPORT psx_svg_player *PICAPI psx_svg_player_create (const psx_svg *root, psx_result *err)
 Create a new animation player from an already-parsed SVG document. More...
 
PEXPORT void PICAPI psx_svg_player_destroy (psx_svg_player *p)
 Destroy the psx_svg_player object and release resources. More...
 
PEXPORT void PICAPI psx_svg_player_set_loop (psx_svg_player *p, bool loop)
 Set whether the animation should loop when it reaches the end. More...
 
PEXPORT bool PICAPI psx_svg_player_get_loop (const psx_svg_player *p)
 Return whether the animation looping is enabled. More...
 
PEXPORT void PICAPI psx_svg_player_set_dpi (psx_svg_player *p, int32_t dpi)
 Set the DPI (dots per inch) used for unit conversion. More...
 
PEXPORT int32_t PICAPI psx_svg_player_get_dpi (const psx_svg_player *p)
 Return the current DPI value. More...
 
PEXPORT void PICAPI psx_svg_player_play (psx_svg_player *p)
 Start or resume playback of the animation. More...
 
PEXPORT void PICAPI psx_svg_player_pause (psx_svg_player *p)
 Pause the animation at the current time. More...
 
PEXPORT void PICAPI psx_svg_player_stop (psx_svg_player *p)
 Stop the animation and seek to time 0. More...
 
PEXPORT void PICAPI psx_svg_player_seek (psx_svg_player *p, float seconds)
 Seek the animation to an absolute time position. More...
 
PEXPORT void PICAPI psx_svg_player_tick (psx_svg_player *p, float delta_seconds)
 Advance the animation by a relative time delta. More...
 
PEXPORT float PICAPI psx_svg_player_get_time (const psx_svg_player *p)
 Return the current playback time in seconds. More...
 
PEXPORT float PICAPI psx_svg_player_get_duration (const psx_svg_player *p)
 Return the total duration of the animation. More...
 
PEXPORT psx_svg_player_state PICAPI psx_svg_player_get_state (const psx_svg_player *p)
 Return the current playback state of the player. More...
 
PEXPORT void PICAPI psx_svg_player_draw (psx_svg_player *p, ps_context *ctx)
 Draw the current animation frame into the provided Picasso context. More...
 
PEXPORT void PICAPI psx_svg_player_set_event_callback (psx_svg_player *p, psx_svg_anim_event_cb cb, void *user)
 Set a callback to receive animation events (begin, end, repeat). More...
 
PEXPORT void PICAPI psx_svg_player_trigger (psx_svg_player *p, const char *target_id, const char *event_name)
 Send an external event trigger to the player. More...
 
PEXPORT void PICAPI psx_svg_player_send_key (psx_svg_player *p, char key)
 Forward a keyboard event to the player. More...
 

Detailed Description

Function Documentation

◆ psx_svg_destroy()

void psx_svg_destroy ( psx_svg doc)

Destroy the psx_svg object and release resources.

Parameters
docPointer to an existing psx_svg object.
See also
psx_svg_load psx_svg_load_from_memory

◆ psx_svg_init()

psx_result psx_svg_init ( void  )

Initialze the library and load resources.

Returns
Result code returned.
See also
psx_svg_shutdown

◆ psx_svg_load()

psx_svg * psx_svg_load ( const char *  file_name,
psx_result err_code 
)

Create a new psx_svg object and load from file.

Parameters
file_nameThe svg file path which will be loaded, which is encoded by utf8.
err_codePointer to a value to receiving the result code. can be NULL.
Returns
If successs, the return value is the pointer to new psx_svg object. If fails, the return value is NULL, and result will be return by err_code.
See also
psx_svg_destroy psx_svg_load_from_memory

◆ psx_svg_load_from_memory()

psx_svg * psx_svg_load_from_memory ( const ps_byte data,
size_t  length,
psx_result err_code 
)

Create a new psx_svg object and load data from memory.

Parameters
dataPointer to data buffer in memeory.
lengthData length bytes.
err_codePointer to a value to receiving the result code. can be NULL.
Returns
If successs, the return value is the pointer to new psx_svg object. If fails, the return value is NULL, and result will be return by err_code.
See also
psx_svg_destroy psx_svg_load

◆ psx_svg_player_create()

psx_svg_player * psx_svg_player_create ( const psx_svg root,
psx_result err 
)

Create a new animation player from an already-parsed SVG document.

The player internally builds a render list once and reuses it each frame.

Parameters
rootPointer to an existing psx_svg object.
errPointer to a value to receiving the result code. Can be NULL.
Returns
If success, the return value is the pointer to new psx_svg_player object. If fails, the return value is NULL, and result will be returned by err.
See also
psx_svg_player_destroy

◆ psx_svg_player_destroy()

void psx_svg_player_destroy ( psx_svg_player p)

Destroy the psx_svg_player object and release resources.

Parameters
pPointer to an existing psx_svg_player object.
See also
psx_svg_player_create

◆ psx_svg_player_draw()

void psx_svg_player_draw ( psx_svg_player p,
ps_context ctx 
)

Draw the current animation frame into the provided Picasso context.

Parameters
pPointer to an existing psx_svg_player object.
ctxPointer to an existing ps_context object.
See also
psx_svg_player_seek psx_svg_player_tick

◆ psx_svg_player_get_dpi()

int32_t psx_svg_player_get_dpi ( const psx_svg_player p)

Return the current DPI value.

Parameters
pPointer to an existing psx_svg_player object.
Returns
The current DPI value.
See also
psx_svg_player_set_dpi

◆ psx_svg_player_get_duration()

float psx_svg_player_get_duration ( const psx_svg_player p)

Return the total duration of the animation.

Parameters
pPointer to an existing psx_svg_player object.
Returns
The duration in seconds, or -1 for indefinite/unknown.
See also
psx_svg_player_get_time

◆ psx_svg_player_get_loop()

bool psx_svg_player_get_loop ( const psx_svg_player p)

Return whether the animation looping is enabled.

Parameters
pPointer to an existing psx_svg_player object.
Returns
True if looping is enabled, otherwise False.
See also
psx_svg_player_set_loop

◆ psx_svg_player_get_state()

psx_svg_player_state psx_svg_player_get_state ( const psx_svg_player p)

Return the current playback state of the player.

Parameters
pPointer to an existing psx_svg_player object.
Returns
The current player state.
See also
psx_svg_player_play psx_svg_player_pause psx_svg_player_stop

◆ psx_svg_player_get_time()

float psx_svg_player_get_time ( const psx_svg_player p)

Return the current playback time in seconds.

Parameters
pPointer to an existing psx_svg_player object.
Returns
The current time in seconds.
See also
psx_svg_player_seek psx_svg_player_tick

◆ psx_svg_player_pause()

void psx_svg_player_pause ( psx_svg_player p)

Pause the animation at the current time.

Parameters
pPointer to an existing psx_svg_player object.
See also
psx_svg_player_play psx_svg_player_stop psx_svg_player_get_state

◆ psx_svg_player_play()

void psx_svg_player_play ( psx_svg_player p)

Start or resume playback of the animation.

Parameters
pPointer to an existing psx_svg_player object.
See also
psx_svg_player_pause psx_svg_player_stop psx_svg_player_get_state

◆ psx_svg_player_seek()

void psx_svg_player_seek ( psx_svg_player p,
float  seconds 
)

Seek the animation to an absolute time position.

Parameters
pPointer to an existing psx_svg_player object.
secondsThe target time in seconds.
See also
psx_svg_player_tick psx_svg_player_get_time

◆ psx_svg_player_send_key()

void psx_svg_player_send_key ( psx_svg_player p,
char  key 
)

Forward a keyboard event to the player.

Used for animations with begin="accessKey(x)" style timing.

Parameters
pPointer to an existing psx_svg_player object.
keyThe character key pressed.
See also
psx_svg_player_trigger

◆ psx_svg_player_set_dpi()

void psx_svg_player_set_dpi ( psx_svg_player p,
int32_t  dpi 
)

Set the DPI (dots per inch) used for unit conversion.

Parameters
pPointer to an existing psx_svg_player object.
dpiThe DPI value. Default is 96.
See also
psx_svg_player_get_dpi

◆ psx_svg_player_set_event_callback()

void psx_svg_player_set_event_callback ( psx_svg_player p,
psx_svg_anim_event_cb  cb,
void *  user 
)

Set a callback to receive animation events (begin, end, repeat).

Parameters
pPointer to an existing psx_svg_player object.
cbThe callback function, or NULL to clear.
userUser data pointer passed to the callback.
See also
psx_svg_anim_event_cb psx_svg_anim_event_type

◆ psx_svg_player_set_loop()

void psx_svg_player_set_loop ( psx_svg_player p,
bool  loop 
)

Set whether the animation should loop when it reaches the end.

Parameters
pPointer to an existing psx_svg_player object.
loopTrue to enable looping, False to disable.
See also
psx_svg_player_get_loop

◆ psx_svg_player_stop()

void psx_svg_player_stop ( psx_svg_player p)

Stop the animation and seek to time 0.

Parameters
pPointer to an existing psx_svg_player object.
See also
psx_svg_player_play psx_svg_player_pause psx_svg_player_get_state

◆ psx_svg_player_tick()

void psx_svg_player_tick ( psx_svg_player p,
float  delta_seconds 
)

Advance the animation by a relative time delta.

Parameters
pPointer to an existing psx_svg_player object.
delta_secondsThe time increment in seconds since the last tick.
See also
psx_svg_player_seek psx_svg_player_get_time

◆ psx_svg_player_trigger()

void psx_svg_player_trigger ( psx_svg_player p,
const char *  target_id,
const char *  event_name 
)

Send an external event trigger to the player.

Used for animations with begin="id.event" style timing.

Parameters
pPointer to an existing psx_svg_player object.
target_idThe target element id, or NULL for untargeted events.
event_nameThe event name (e.g. "click").
See also
psx_svg_player_send_key

◆ psx_svg_render_destroy()

void psx_svg_render_destroy ( psx_svg_render render)

Destroy the psx_svg_render object and release resources.

Parameters
renderPointer to an existing psx_svg_render object.
See also
psx_svg_render_draw psx_svg_render_create psx_svg_render_get_size

◆ psx_svg_render_draw()

psx_result PICAPI psx_svg_render_draw ( ps_context ctx,
const psx_svg_render render 
)

Draws an psx_svg_render object into the given context.

Parameters
ctxPointer to an existing context object.
renderPointer to an existing psx_svg_render object.
Returns
Result code returned.
See also
psx_svg_render_destroy psx_svg_render_create psx_svg_render_get_size

◆ psx_svg_shutdown()

void psx_svg_shutdown ( void  )

Release resources and shutdown.

See also
psx_svg_init