bitlib_c  0.2.4
Functions
drawing.h File Reference
#include <cairo.h>
#include <stdbool.h>
#include "bitlib.h"
#include "point.h"

Go to the source code of this file.

Functions

void cairo_plot (cairo_t *cr, double x, double y)
 
void cairo_line (cairo_t *cr, double x0, double y0, double x1, double y1)
 
void cairo_line_through (cairo_t *cr, double x0, double y0, double x1, double y1, double overlap)
 
void cairo_ray (cairo_t *cr, double x, double y, double angle, double offset, double length)
 
void cairo_stroke_rectangle (cairo_t *cr, double x, double y, double w, double h)
 
void cairo_fill_rectangle (cairo_t *cr, double x, double y, double w, double h)
 
void cairo_round_rectangle (cairo_t *cr, double x, double y, double w, double h, double r)
 
void cairo_stroke_round_rectangle (cairo_t *cr, double x, double y, double w, double h, double r)
 
void cairo_fill_round_rectangle (cairo_t *cr, double x, double y, double w, double h, double r)
 
void cairo_circle (cairo_t *cr, double x, double y, double r)
 
void cairo_stroke_circle (cairo_t *cr, double x, double y, double r)
 
void cairo_fill_circle (cairo_t *cr, double x, double y, double r)
 
void cairo_ellipse (cairo_t *cr, double x, double y, double xr, double yr)
 
void cairo_stroke_ellipse (cairo_t *cr, double x, double y, double xr, double yr)
 
void cairo_fill_ellipse (cairo_t *cr, double x, double y, double xr, double yr)
 
void cairo_path (cairo_t *cr, bl_point_list *path)
 
void cairo_stroke_path (cairo_t *cr, bl_point_list *path, bool close)
 
void cairo_fill_path (cairo_t *cr, bl_point_list *path)
 
void cairo_polygon (cairo_t *cr, double x, double y, double r, int sides, double rotation)
 
void cairo_stroke_polygon (cairo_t *cr, double x, double y, double r, int sides, double rotation)
 
void cairo_fill_polygon (cairo_t *cr, double x, double y, double r, int sides, double rotation)
 
void cairo_star (cairo_t *cr, double x, double y, double r0, double r1, int points, double rotation)
 
void cairo_stroke_star (cairo_t *cr, double x, double y, double r0, double r1, int points, double rotation)
 
void cairo_fill_star (cairo_t *cr, double x, double y, double r0, double r1, int points, double rotation)
 
void cairo_stroke_curve_to (cairo_t *cr, double x0, double y0, double x1, double y1, double x2, double y2)
 
void cairo_quad_curve_to (cairo_t *cr, double x0, double y0, double x1, double y1)
 
void cairo_stroke_quad_curve_to (cairo_t *cr, double x0, double y0, double x1, double y1)
 
void cairo_fill_text (cairo_t *cr, char *text, double x, double y)
 
void cairo_printf (cairo_t *cr, double x, double y, char *fmt,...)
 
void cairo_stroke_text (cairo_t *cr, char *text, double x, double y)
 
void cairo_splat (cairo_t *cr, double x, double y, int num_nodes, double radius, double inner_radius, double variation)
 
void cairo_stroke_splat (cairo_t *cr, double x, double y, int num_nodes, double radius, double inner_radius, double variation)
 
void cairo_fill_splat (cairo_t *cr, double x, double y, int num_nodes, double radius, double inner_radius, double variation)
 
void cairo_multi_loop (cairo_t *cr, bl_point_list *path)
 
void cairo_stroke_multi_loop (cairo_t *cr, bl_point_list *path)
 
void cairo_fill_multi_loop (cairo_t *cr, bl_point_list *path)
 
void cairo_multi_curve (cairo_t *cr, bl_point_list *path)
 
void cairo_stroke_multi_curve (cairo_t *cr, bl_point_list *path)
 
void cairo_fill_multi_curve (cairo_t *cr, bl_point_list *path)
 
void cairo_draw_points (cairo_t *cr, bl_point_list *path, double radius)
 
void cairo_fractal_line (cairo_t *cr, double x0, double y0, double x1, double y1, double roughness, int iterations)
 
void cairo_stroke_fractal_line (cairo_t *cr, double x0, double y0, double x1, double y1, double roughness, int iterations)
 
void cairo_heart (cairo_t *cr, double x, double y, double w, double h, double r)
 
void cairo_stroke_heart (cairo_t *cr, double x, double y, double w, double h, double r)
 
void cairo_fill_heart (cairo_t *cr, double x, double y, double w, double h, double r)
 
void cairo_grid (cairo_t *cr, double x, double y, double w, double h, double xres, double yres)
 
void cairo_hex_grid (cairo_t *cr, double x, double y, double w, double h, double res_0, double res_1)
 
void cairo_fill_hex_grid (cairo_t *cr, double x, double y, double w, double h, double res_0, double res_1)
 
void cairo_stroke_hex_grid (cairo_t *cr, double x, double y, double w, double h, double res_0, double res_1)
 

Function Documentation

◆ cairo_circle()

void cairo_circle ( cairo_t *  cr,
double  x,
double  y,
double  r 
)

Creates a circle.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the circle.
doubley The y position of the circle.
doubler The radius of the circle.

Examples

cairo_circle(cr, 100, 100, 50);

◆ cairo_draw_points()

void cairo_draw_points ( cairo_t *  cr,
bl_point_list path,
double  radius 
)

Draws a filled circle for each point in a list.

Parameters
cairo_t*cr The cairo context.
bl_point_list*path A linked list of bl_point objects.
doubleradius The radius of the circles drawn on each point.

Examples

bl_point_list *path = bl_make_point_list();
bl_add_point_xy(path, 100, 100);
bl_add_point_xy(path, 110, 200);
// add more points...
cairo_draw_points(cr, path);
bl_point_list_destroy(path);

◆ cairo_ellipse()

void cairo_ellipse ( cairo_t *  cr,
double  x,
double  y,
double  xr,
double  yr 
)

Creates an ellipse.

x and y will denote the center of the ellipse. The ellipse will be twice as wide as xr and twice as tall as yr.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the ellipse.
doubley The y position of the ellipse.
doublexr The x radius of the ellipse.
doubleyr The y radius of the ellipse.

Examples

cairo_ellipse(cr, 100, 100, 50, 75);

◆ cairo_fill_circle()

void cairo_fill_circle ( cairo_t *  cr,
double  x,
double  y,
double  r 
)

Draws a filled circle.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the circle.
doubley The y position of the circle.
doubler The radius of the circle.

Examples

cairo_fill_circle(cr, 100, 100, 50);

◆ cairo_fill_ellipse()

void cairo_fill_ellipse ( cairo_t *  cr,
double  x,
double  y,
double  xr,
double  yr 
)

Draws a filled ellipse.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the ellipse.
doubley The y position of the ellipse.
doublexr The x radius of the ellipse.
doubleyr The y radius of the ellipse.

Examples

cairo_fill_ellipse(cr, 100, 100, 50, 75);

◆ cairo_fill_heart()

void cairo_fill_heart ( cairo_t *  cr,
double  x,
double  y,
double  w,
double  h,
double  r 
)

Draws a filled heart shape.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the heart.
doubley The y position of the heart.
doublew The width of the heart.
doubleh The height of the heart.
doubler The rotation of the heart in radians.

Examples

cairo_fill_heart(cr, 100, 100, 50, 50, 0);

◆ cairo_fill_hex_grid()

void cairo_fill_hex_grid ( cairo_t *  cr,
double  x,
double  y,
double  w,
double  h,
double  res_0,
double  res_1 
)

Strokes a hexagonal grid.

Using a slightly smaller value for res_1 than res_0 draws all the hexagons spaced out from each other. This is especially useful when filling a hex grid.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the grid.
doubley The y position of the grid.
doublew The width of the grid.
doubleh The height of the grid.
doubleres_0 The resolution (hex radius) of the grid itself.
doubleres_1 The resolution (hex radius) of each individual drawn hexagon.

Examples

cairo_stroke_hex_grid(cr, 0, 0, 500, 500, 30, 28);

◆ cairo_fill_multi_curve()

void cairo_fill_multi_curve ( cairo_t *  cr,
bl_point_list path 
)

Draws a filled, open smooth curve through a list of points.

Parameters
cairo_t*cr The cairo context.

Examples

bl_point_list *path = bl_make_point_list();
bl_add_point_xy(path, 100, 100);
bl_add_point_xy(path, 110, 200);
// add more points...
cairo_fill_multi_curve(cr, path);
bl_point_list_destroy(path);

◆ cairo_fill_multi_loop()

void cairo_fill_multi_loop ( cairo_t *  cr,
bl_point_list path 
)

Draws a filled smooth closed curve through a list of points.

Parameters
cairo_t*cr The cairo context.
bl_point_list*path A linked list of bl_point objects.

Examples

bl_point_list *path = bl_make_point_list();
bl_add_point_xy(path, 100, 100);
bl_add_point_xy(path, 110, 200);
// add more points...
cairo_fill_multi_loop(cr, path);
bl_point_list_destroy(path);

◆ cairo_fill_path()

void cairo_fill_path ( cairo_t *  cr,
bl_point_list path 
)

Draws a filled path of connected points.

Use bl_make_point_list to create a list, and bl_add_point or pl_add_point_xy to add points to the list. Be sure to call bl_point_list_destroy when you are done with the list to avoid memory leaks.

Parameters
cairo_t*cr The cairo context.
bl_point_list*path A linked list of bl_point objects.

Examples

bl_point_list *path = bl_make_point_list();
bl_add_point_xy(path, 100, 100);
bl_add_point_xy(path, 110, 200);
// add more points...
cairo_fill_path(cr, path);
bl_point_list_destroy(path);

◆ cairo_fill_polygon()

void cairo_fill_polygon ( cairo_t *  cr,
double  x,
double  y,
double  r,
int  sides,
double  rotation 
)

Draws a filled regular polygon.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the polygon.
doubley The y position of the polygon.
doubler The radius of the polygon.
doublesides How many sides to the polygon.
doublerotation The rotation of the polygon in radians.

Examples

cairo_fill_polygon(cr, 100, 100, 50, 5, 0);

◆ cairo_fill_rectangle()

void cairo_fill_rectangle ( cairo_t *  cr,
double  x,
double  y,
double  w,
double  h 
)

Draws a filled rectangle.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the rectangle.
doubley The y position of the rectangle.
doublew The width of the rectangle.
doubleh The height of the rectangle.

Examples

cairo_fill_rectangle(cr, 100, 100, 200, 300);

◆ cairo_fill_round_rectangle()

void cairo_fill_round_rectangle ( cairo_t *  cr,
double  x,
double  y,
double  w,
double  h,
double  r 
)

Draws a filled rounded rectangle.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the rectangle.
doubley The y position of the rectangle.
doublew The width of the rectangle.
doubleh The height of the rectangle.
doubler The corner radius of the rectangle.

Examples

cairo_fill_round_rectangle(cr, 100, 100, 200, 300, 20);

◆ cairo_fill_splat()

void cairo_fill_splat ( cairo_t *  cr,
double  x,
double  y,
int  num_nodes,
double  radius,
double  inner_radius,
double  variation 
)

Draws a filled splat shape.

Parameters
cairo_t*cr The cairo context.
char*text The text to draw.
doublex The x position of the splat.
doubley The y position of the splat.
intnum_nodes How many blobs (nodes) in the splat.
doubleradius The outer radius of the splat.
doubleinner_radius The inner radius of the splat.
doublevariation How random the nodes will be.

Examples

cairo_fill_splat(cr, 200, 200, 6, 100, 20, 0.2);

◆ cairo_fill_star()

void cairo_fill_star ( cairo_t *  cr,
double  x,
double  y,
double  r0,
double  r1,
int  points,
double  rotation 
)

Draws a filled star.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the star.
doubley The y position of the star.
doubler0 The radius of one set of points of the star.
doubler1 The radius of the other set of points of the star.
doublesides How many points to the star.
doublerotation The rotation of the star in radians.

Examples

cairo_fill_star(cr, 100, 100, 60, 20, 5, 0);

◆ cairo_fill_text()

void cairo_fill_text ( cairo_t *  cr,
char *  text,
double  x,
double  y 
)

Draws the specified text with a fill.

Parameters
cairo_t*cr The cairo context.
char*text The text to draw.
doublex The x position of the text.
doubley The y position of the text.

Examples

cairo_fill_text(cr, "hello world", 100, 100);

◆ cairo_fractal_line()

void cairo_fractal_line ( cairo_t *  cr,
double  x0,
double  y0,
double  x1,
double  y1,
double  roughness,
int  iterations 
)

Creates a fractal line between two points.

This works by subdividing the initial line segment and offsetting the new point. The result looks like a mountain, coastline or lightning strike.

Parameters
cairo_t*cr The cairo context.
doublex0 The x value of the first point.
doubley0 The y value of the first point.
doublex0 The x value of the second point.
doubley0 The y value of the second point.
doubleroughness How much the points will be offset during iteration.
intiterations How many iterations to build the line.

Examples

cairo_fractal_line(cr, 100, 100, 200, 200, 0.4, 5);
cairo_stroke(cr);

◆ cairo_grid()

void cairo_grid ( cairo_t *  cr,
double  x,
double  y,
double  w,
double  h,
double  xres,
double  yres 
)

Draws a stroked grid.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the grid.
doubley The y position of the grid.
doublew The width of the grid.
doubleh The height of the grid.
doublexres The space between each line on the x-axis.
doubleyres The space between each line on the y-axis.

Examples

cairo_grid(0, 0, 500, 500, 10, 10);
cairo_stroke(cr);

◆ cairo_heart()

void cairo_heart ( cairo_t *  cr,
double  x,
double  y,
double  w,
double  h,
double  r 
)

Creates a heart shape.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the heart.
doubley The y position of the heart.
doublew The width of the heart.
doubleh The height of the heart.
doubler The rotation of the heart in radians.

Examples

cairo_heart(cr, 100, 100, 50, 50, 0);

◆ cairo_hex_grid()

void cairo_hex_grid ( cairo_t *  cr,
double  x,
double  y,
double  w,
double  h,
double  res_0,
double  res_1 
)

Creates a hexagonal grid.

Using a slightly smaller value for res_1 than res_0 draws all the hexagons spaced out from each other. This is especially useful when filling a hex grid.

It is recommended to use cairo_stroke_hex_grid or cairo_fill_hex_grid rather than this function, as the other two also apply a clipping rectangle to the specified grid area.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the grid.
doubley The y position of the grid.
doublew The width of the grid.
doubleh The height of the grid.
doubleres_0 The resolution (hex radius) of the grid itself.
doubleres_1 The resolution (hex radius) of each individual drawn hexagon.

Examples

cairo_hex_grid(cr, 0, 0, 500, 500, 30, 28);
cairo_fill(cr);

◆ cairo_line()

void cairo_line ( cairo_t *  cr,
double  x0,
double  y0,
double  x1,
double  y1 
)

Draws a line between two x, y points.

Same as cairo_move_to to the first point, cairo_line_to to the second point and then cairo_stroke.

Parameters
cairo_t*cr The cairo context.
doublex0 The x position of the first point.
doubley0 The y position of the first point.
doublex1 The x position of the second point.
doubley1 The y position of the second point.

Examples

cairo_line(cr, 100, 100, 200, 200);

◆ cairo_line_through()

void cairo_line_through ( cairo_t *  cr,
double  x0,
double  y0,
double  x1,
double  y1,
double  overlap 
)

Draws a line through two x, y points, overlapping each by a specified amount.

Instead of simply starting and ending on each point, the drawn line will extend beyond the points to the specified amount. Often you'll want to make the overlap large enough so that it is outside of the drawing area to make the line appear infinitely long.

Parameters
cairo_t*cr The cairo context.
doublex0 The x position of the first point.
doubley0 The y position of the first point.
doublex1 The x position of the second point.
doubley1 The y position of the second point.
doubleoverlap How far beyond each point to draw the line.

Examples

cairo_line_through(cr, 100, 100, 200, 200, 100);

◆ cairo_multi_curve()

void cairo_multi_curve ( cairo_t *  cr,
bl_point_list path 
)

Creates an open smooth curve through a list of points.

Parameters
cairo_t*cr The cairo context.
bl_point_list*path A linked list of bl_point objects.

Examples

bl_point_list *path = bl_make_point_list();
bl_add_point_xy(path, 100, 100);
bl_add_point_xy(path, 110, 200);
// add more points...
cairo_multi_curve(cr, path);
cairo_stroke(cr);
bl_point_list_destroy(path);

◆ cairo_multi_loop()

void cairo_multi_loop ( cairo_t *  cr,
bl_point_list path 
)

Creates a smooth, closed curve through a list of points.

The curve will not pass through each point. Instead, the points will be used as quadratic Bezier control points for each segment of the curve.

Parameters
cairo_t*cr The cairo context.
bl_point_list*path A linked list of bl_point objects.

Examples

bl_point_list *path = bl_make_point_list();
bl_add_point_xy(path, 100, 100);
bl_add_point_xy(path, 110, 200);
// add more points...
cairo_multi_loop(cr, path);
cairo_stroke(cr);
bl_point_list_destroy(path);

◆ cairo_path()

void cairo_path ( cairo_t *  cr,
bl_point_list path 
)

Creates a path by connecting a series of points.

Use bl_make_point_list to create a list, and bl_add_point or pl_add_point_xy to add points to the list. Be sure to call bl_point_list_destroy when you are done with the list to avoid memory leaks.

Parameters
cairo_t*cr The cairo context.
bl_point_list*path A linked list of bl_point objects.

Examples

bl_point_list *path = bl_make_point_list();
bl_add_point_xy(path, 100, 100);
bl_add_point_xy(path, 110, 200);
// add more points...
cairo_path(cr, path);
cairo_stroke(cr);
bl_point_list_destroy(path);

◆ cairo_plot()

void cairo_plot ( cairo_t *  cr,
double  x,
double  y 
)

Plots a single point.

Draws a single pixel rectangle.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the point.
doubley The y position of the point.

Examples

cairo_plot(cr, 100, 100);

◆ cairo_polygon()

void cairo_polygon ( cairo_t *  cr,
double  x,
double  y,
double  r,
int  sides,
double  rotation 
)

Creates a regular polygon with the specified number of sides.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the polygon.
doubley The y position of the polygon.
doubler The radius of the polygon.
doublesides How many sides to the polygon.
doublerotation The rotation of the polygon in radians.

Examples

cairo_polygon(cr, 100, 100, 50, 5, 0);

◆ cairo_printf()

void cairo_printf ( cairo_t *  cr,
double  x,
double  y,
char *  fmt,
  ... 
)

Draws text using a format string and variables.

This function works exactly like printf, and in fact uses the same underlying functions, but draws the resultant string to the cairo context.

Parameters
cairo_t*cr The cairo context.
char*text The text to draw.
doublex The x position of the text.
doubley The y position of the text.

Examples

cairo_printf(cr, 100, 100, "hello %s %d", "world", 2020);

◆ cairo_quad_curve_to()

void cairo_quad_curve_to ( cairo_t *  cr,
double  x0,
double  y0,
double  x1,
double  y1 
)

Creates a quadratic curve.

Parameters
cairo_t*cr The cairo context.
doublex0 The x value of the control point.
doubley0 The y value of the control point.
doublex2 The x value of the end point.
doubley2 The y value of the end point.

Examples

cairo_move_to(cr, 100, 100);
cairo_quad_curve_to(200, 0, 300, 100);
cairo_stroke();

◆ cairo_ray()

void cairo_ray ( cairo_t *  cr,
double  x,
double  y,
double  angle,
double  offset,
double  length 
)

Draws a line segment from an x, y point at a specified length and angle.

A ray is a line segment that extends from a point at a certain angle. This function also adds an offset so you can start the ray at a distance from the point.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the point.
doubley The y position of the point.
doubleangle The angle of the ray.
doubleoffset How far from the point to start drawing the ray.
doublelength The length of the ray.

Examples

cairo_ray(cr, 100, 100, PI / 2, 0, 100);

◆ cairo_round_rectangle()

void cairo_round_rectangle ( cairo_t *  cr,
double  x,
double  y,
double  w,
double  h,
double  r 
)

Creates a rectangle with rounded corners.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the rectangle.
doubley The y position of the rectangle.
doublew The width of the rectangle.
doubleh The height of the rectangle.
doubler The corner radius of the rectangle.

Examples

cairo_round_rectangle(cr, 100, 100, 200, 300, 20);

◆ cairo_splat()

void cairo_splat ( cairo_t *  cr,
double  x,
double  y,
int  num_nodes,
double  radius,
double  inner_radius,
double  variation 
)

Creates a splat shape.

This function draws a shape that looks like a drop of ink splashed on a surface. It's like a star with blobs instead of points. If variation is 0, it will be a perfect splat and look more like a flower. As variation increases, the blobs become more random.

Parameters
cairo_t*cr The cairo context.
char*text The text to draw.
doublex The x position of the splat.
doubley The y position of the splat.
intnum_nodes How many blobs (nodes) in the splat.
doubleradius The outer radius of the splat.
doubleinner_radius The inner radius of the splat.
doublevariation How random the nodes will be.

Examples

cairo_splat(cr, 200, 200, 6, 100, 20, 0.2);

◆ cairo_star()

void cairo_star ( cairo_t *  cr,
double  x,
double  y,
double  r0,
double  r1,
int  points,
double  rotation 
)

Creates a star shape with the specified number of points.

The two radius parameters are somewhat interchangeable. You could call one the inner radius and one the outer radius, but it does not matter which is larger or smaller, though that will affect the orientation of the star.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the star.
doubley The y position of the star.
doubler0 The radius of one set of points of the star.
doubler1 The radius of the other set of points of the star.
doublesides How many points to the star.
doublerotation The rotation of the star in radians.

Examples

cairo_star(cr, 100, 100, 60, 20, 5, 0);

◆ cairo_stroke_circle()

void cairo_stroke_circle ( cairo_t *  cr,
double  x,
double  y,
double  r 
)

Draws the stroked outline of a circle.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the circle.
doubley The y position of the circle.
doubler The radius of the circle.

Examples

cairo_stroke_circle(cr, 100, 100, 50);

◆ cairo_stroke_curve_to()

void cairo_stroke_curve_to ( cairo_t *  cr,
double  x0,
double  y0,
double  x1,
double  y1,
double  x2,
double  y2 
)

Draws the stroke of a Bezier curve.

Parameters
cairo_t*cr The cairo context.
doublex0 The x value of the first control point.
doubley0 The y value of the first control point.
doublex1 The x value of the second control point.
doubley1 The y value of the second control point.
doublex2 The x value of the end point.
doubley2 The y value of the end point.

Examples

cairo_move_to(cr, 100, 100);
cairo_stroke_curve_to(200, 0, 300, 300, 400, 100);

◆ cairo_stroke_ellipse()

void cairo_stroke_ellipse ( cairo_t *  cr,
double  x,
double  y,
double  xr,
double  yr 
)

Draws the stroked outline of an ellipse.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the ellipse.
doubley The y position of the ellipse.
doublexr The x radius of the ellipse.
doubleyr The y radius of the ellipse.

Examples

cairo_stroke_ellipse(cr, 100, 100, 50, 75);

◆ cairo_stroke_fractal_line()

void cairo_stroke_fractal_line ( cairo_t *  cr,
double  x0,
double  y0,
double  x1,
double  y1,
double  roughness,
int  iterations 
)

Draws the stroked path of a fractal line between two points.

Parameters
cairo_t*cr The cairo context.
doublex0 The x value of the first point.
doubley0 The y value of the first point.
doublex0 The x value of the second point.
doubley0 The y value of the second point.
doubleroughness How much the points will be offset during iteration.
intiterations How many iterations to build the line.

Examples

cairo_stroke_fractal_line(cr, 100, 100, 200, 200, 0.4, 5);

◆ cairo_stroke_heart()

void cairo_stroke_heart ( cairo_t *  cr,
double  x,
double  y,
double  w,
double  h,
double  r 
)

Draws the stroked outline of a heart shape.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the heart.
doubley The y position of the heart.
doublew The width of the heart.
doubleh The height of the heart.
doubler The rotation of the heart in radians.

Examples

cairo_stroke_heart(cr, 100, 100, 50, 50, 0);

◆ cairo_stroke_hex_grid()

void cairo_stroke_hex_grid ( cairo_t *  cr,
double  x,
double  y,
double  w,
double  h,
double  res_0,
double  res_1 
)

Fills a hexagonal grid.

Using a slightly smaller value for res_1 than res_0 draws all the hexagons spaced out from each other. This is especially useful when filling a hex grid.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the grid.
doubley The y position of the grid.
doublew The width of the grid.
doubleh The height of the grid.
doubleres_0 The resolution (hex radius) of the grid itself.
doubleres_1 The resolution (hex radius) of each individual drawn hexagon.

Examples

cairo_fill_hex_grid(cr, 0, 0, 500, 500, 30, 28);

◆ cairo_stroke_multi_curve()

void cairo_stroke_multi_curve ( cairo_t *  cr,
bl_point_list path 
)

Draws the stroked path of an open smooth curve through a list of points.

The curve will not pass through each point. Instead, the points will be used as quadratic Bezier control points for each segment of the curve.

Parameters
cairo_t*cr The cairo context.
bl_point_list*path A linked list of bl_point objects.

Examples

bl_point_list *path = bl_make_point_list();
bl_add_point_xy(path, 100, 100);
bl_add_point_xy(path, 110, 200);
// add more points...
cairo_stroke_multi_curve(cr, path);
bl_point_list_destroy(path);

◆ cairo_stroke_multi_loop()

void cairo_stroke_multi_loop ( cairo_t *  cr,
bl_point_list path 
)

Draws the stroked outline of a smooth closed curve through a list of points.

Parameters
cairo_t*cr The cairo context.
bl_point_list*path A linked list of bl_point objects.

Examples

bl_point_list *path = bl_make_point_list();
bl_add_point_xy(path, 100, 100);
bl_add_point_xy(path, 110, 200);
// add more points...
cairo_stroke_multi_loop(cr, path);
bl_point_list_destroy(path);

◆ cairo_stroke_path()

void cairo_stroke_path ( cairo_t *  cr,
bl_point_list path,
bool  close 
)

Draws the stroked shape of a path of connected points.

Use bl_make_point_list to create a list, and bl_add_point or pl_add_point_xy to add points to the list. Be sure to call bl_point_list_destroy when you are done with the list to avoid memory leaks.

Parameters
cairo_t*cr The cairo context.
bl_point_list*path A linked list of bl_point objects.
boolclose Whether or not to draw a final line back to the start.

Examples

bl_point_list *path = bl_make_point_list();
bl_add_point_xy(path, 100, 100);
bl_add_point_xy(path, 110, 200);
// add more points...
cairo_stroke_path(cr, path, true);
bl_point_list_destroy(path);

◆ cairo_stroke_polygon()

void cairo_stroke_polygon ( cairo_t *  cr,
double  x,
double  y,
double  r,
int  sides,
double  rotation 
)

Draws the stroked outline of a regular polygon.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the polygon.
doubley The y position of the polygon.
doubler The radius of the polygon.
doublesides How many sides to the polygon.
doublerotation The rotation of the polygon in radians.

Examples

cairo_stroke_polygon(cr, 100, 100, 50, 5, 0);

◆ cairo_stroke_quad_curve_to()

void cairo_stroke_quad_curve_to ( cairo_t *  cr,
double  x0,
double  y0,
double  x1,
double  y1 
)

Draws the stroke of a quadratic curve.

Parameters
cairo_t*cr The cairo context.
doublex0 The x value of the control point.
doubley0 The y value of the control point.
doublex1 The x value of the end point.
doubley1 The y value of the end point.

Examples

cairo_move_to(cr, 100, 100);
cairo_stroke_quad_curve_to(200, 0, 300, 100);

◆ cairo_stroke_rectangle()

void cairo_stroke_rectangle ( cairo_t *  cr,
double  x,
double  y,
double  w,
double  h 
)

Draws the stroked outline of a rectangle.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the rectangle.
doubley The y position of the rectangle.
doublew The width of the rectangle.
doubleh The height of the rectangle.

Examples

cairo_stroke_rectangle(cr, 100, 100, 200, 300);

◆ cairo_stroke_round_rectangle()

void cairo_stroke_round_rectangle ( cairo_t *  cr,
double  x,
double  y,
double  w,
double  h,
double  r 
)

Draws the stroked outline of a rounded rectangle.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the rectangle.
doubley The y position of the rectangle.
doublew The width of the rectangle.
doubleh The height of the rectangle.
doubler The corner radius of the rectangle.

Examples

cairo_stroke_round_rectangle(cr, 100, 100, 200, 300, 20);

◆ cairo_stroke_splat()

void cairo_stroke_splat ( cairo_t *  cr,
double  x,
double  y,
int  num_nodes,
double  radius,
double  inner_radius,
double  variation 
)

Draws the stroked outline of a splat shape.

Parameters
cairo_t*cr The cairo context.
char*text The text to draw.
doublex The x position of the splat.
doubley The y position of the splat.
intnum_nodes How many blobs (nodes) in the splat.
doubleradius The outer radius of the splat.
doubleinner_radius The inner radius of the splat.
doublevariation How random the nodes will be.

Examples

cairo_stroke_splat(cr, 200, 200, 6, 100, 20, 0.2);

◆ cairo_stroke_star()

void cairo_stroke_star ( cairo_t *  cr,
double  x,
double  y,
double  r0,
double  r1,
int  points,
double  rotation 
)

Draws the stroked outline of a star.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the star.
doubley The y position of the star.
doubler0 The radius of one set of points of the star.
doubler1 The radius of the other set of points of the star.
doublesides How many points to the star.
doublerotation The rotation of the star in radians.

Examples

cairo_stroke_star(cr, 100, 100, 60, 20, 5, 0);

◆ cairo_stroke_text()

void cairo_stroke_text ( cairo_t *  cr,
char *  text,
double  x,
double  y 
)

Draws the specified text with a stroke.

Parameters
cairo_t*cr The cairo context.
doublex The x position of the text.
doubley The y position of the text.
char*text The format string to construct the text with.
...Additional parameters to fill in the format string with.

Examples

cairo_stroke_text(cr, "hello world", 100, 100);