#include <cairo.h>
Go to the source code of this file.
◆ bl_render_callback
typedef void(* bl_render_callback) (cairo_t *cr, double percent) |
An interface for a render callback function.
Create a function conforming to this interface and pass it to bl_render_image
, bl_render_gif
or bl_render_video
. This function will get called once for an image, or once per frame for a gif or video.
For an image, the percent
value will always be 1. For animations it will interpolate between 0 and 1 for the first through the last frames. Use percent to alter the drawing code on each frame.
- Parameters
-
cairo_t | *cr The cairo context your render function will draw to. |
double | percent The percent of the way through the full animation. |
Examples
void render(cairo_t *cr, double percent) {
// draw to cr here
}
bl_render_gif(config, "out.gif", 4, render);
◆ bl_render_config
A struct to hold information about the render being done.
◆ bl_render_mode
An enum to specify the type of render (image, gif, video or small video) being done.
Enumerator |
---|
IMAGE | |
GIF | |
VIDEO | |
SMALL_VIDEO | |
◆ bl_render_gif()
Renders multiple frames of an animation and saves them to an animated gif.
- Parameters
-
bl_render_config | config The configuration file for the animation. |
char | *gif_name The path of the output gif. |
int | threads How many threads to use for rendering all the frames. |
bl_render_callback | render The callback function that will do the drawing for each frame. |
Examples
bl_render_gif(config, "out.gif", 4, render);
◆ bl_render_image()
void bl_render_image |
( |
double |
width, |
|
|
double |
height, |
|
|
char * |
png_file_name, |
|
|
bl_render_callback |
render |
|
) |
| |
Renders an image and saves it as a png.
- Parameters
-
bl_render_config | config The configuration file for the image. |
char | *png_file_name The path of the output png. |
bl_render_callback | render The callback function that will draw the image. |
Examples
bl_render_image(config, "out.png", render);
◆ bl_render_video()
Renders multiple frames of an animation and saves them to an mp4 video file.
- Parameters
-
bl_render_config | config The configuration file for the animation. |
char | *mp4_name The path of the output video. |
int | threads How many threads to use for rendering all the frames. |
bl_render_callback | render The callback function that will do the drawing for each frame. |
Examples
bl_render_video(config, "out.mp4", 4, render);