bitlib_c  0.2.4
Classes | Typedefs | Enumerations | Functions
render.h File Reference
#include <cairo.h>

Go to the source code of this file.

Classes

struct  _bl_render_config
 

Typedefs

typedef struct _bl_render_config bl_render_config
 
typedef void(* bl_render_callback) (cairo_t *cr, double percent)
 

Enumerations

enum  bl_render_mode { IMAGE, GIF, VIDEO, SMALL_VIDEO }
 

Functions

void bl_render_gif (bl_render_config config, char *gif_name, int threads, bl_render_callback render)
 
void bl_render_video (bl_render_config config, char *mp4_name, int threads, bl_render_callback render)
 
void bl_render_image (double width, double height, char *png_file_name, bl_render_callback render)
 

Typedef Documentation

◆ 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.
doublepercent 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.

Enumeration Type Documentation

◆ 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 

Function Documentation

◆ bl_render_gif()

void bl_render_gif ( bl_render_config  config,
char *  gif_name,
int  threads,
bl_render_callback  render 
)

Renders multiple frames of an animation and saves them to an animated gif.

Parameters
bl_render_configconfig The configuration file for the animation.
char*gif_name The path of the output gif.
intthreads How many threads to use for rendering all the frames.
bl_render_callbackrender 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_configconfig The configuration file for the image.
char*png_file_name The path of the output png.
bl_render_callbackrender The callback function that will draw the image.

Examples

bl_render_image(config, "out.png", render);

◆ bl_render_video()

void bl_render_video ( bl_render_config  config,
char *  mp4_name,
int  threads,
bl_render_callback  render 
)

Renders multiple frames of an animation and saves them to an mp4 video file.

Parameters
bl_render_configconfig The configuration file for the animation.
char*mp4_name The path of the output video.
intthreads How many threads to use for rendering all the frames.
bl_render_callbackrender The callback function that will do the drawing for each frame.

Examples

bl_render_video(config, "out.mp4", 4, render);