|
|
|
@ -35,6 +35,9 @@ cairo_matrix_init_from_matrix(
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
void |
|
|
|
|
/**
|
|
|
|
|
* \brief Prints the transformation definet by a hvif matrix. |
|
|
|
|
*/ |
|
|
|
|
print_matrix(const hvif_matrix* matrix) |
|
|
|
|
{ |
|
|
|
|
printf("x_new = %f * x + %f * y + %f\n", matrix->xx, matrix->xy, matrix->x0); |
|
|
|
@ -47,6 +50,9 @@ print_matrix(const hvif_matrix* matrix)
|
|
|
|
|
#define B(c) (COLOR_GET_BLUE(c) / 255.0) |
|
|
|
|
#define A(c) (COLOR_GET_ALPHA(c) / 255.0) |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \brief Create a patch for a diamond gradient. |
|
|
|
|
*/ |
|
|
|
|
void |
|
|
|
|
create_diamond_patch( |
|
|
|
|
cairo_pattern_t* pat, double s1, double s2, hvif_color c1, hvif_color c2) |
|
|
|
@ -93,6 +99,9 @@ create_diamond_patch(
|
|
|
|
|
cairo_mesh_pattern_end_patch(pat); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \brief Create a patch for a conic gradient. |
|
|
|
|
*/ |
|
|
|
|
void |
|
|
|
|
create_conic_patch( |
|
|
|
|
cairo_pattern_t* pat, double r, double angle1, double angle2, hvif_color c1, |
|
|
|
@ -117,6 +126,11 @@ create_conic_patch(
|
|
|
|
|
cairo_mesh_pattern_end_patch(pat); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \brief Create a cairo pattern from a \a hvif style. |
|
|
|
|
* |
|
|
|
|
* XY and sqrt XY gradients are unsupported and replaced by radial gradients. |
|
|
|
|
*/ |
|
|
|
|
hvif_cairo_status |
|
|
|
|
create_pattern_style(cairo_pattern_t** pat, hvif_style* style) |
|
|
|
|
{ |
|
|
|
@ -235,6 +249,9 @@ create_pattern_style(cairo_pattern_t** pat, hvif_style* style)
|
|
|
|
|
return unsupported ? HVIF_CAIRO_UNSUPPORTED : HVIF_CAIRO_SUCCESS; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \brief Create a cairo path from a \a hvif path. |
|
|
|
|
*/ |
|
|
|
|
void |
|
|
|
|
create_path(cairo_t* cr, cairo_path_t** path, hvif_path* hvif_path) |
|
|
|
|
{ |
|
|
|
@ -357,6 +374,7 @@ hvif_cairo_status
|
|
|
|
|
hvif_cairo_png_render( |
|
|
|
|
const char* filename, hvif_image* image, unsigned pixel_size) |
|
|
|
|
{ |
|
|
|
|
assert(image != NULL); |
|
|
|
|
cairo_surface_t* surface = |
|
|
|
|
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, pixel_size, pixel_size); |
|
|
|
|
double scale = pixel_size / 64.0; |
|
|
|
@ -377,6 +395,8 @@ hvif_cairo_status
|
|
|
|
|
hvif_cairo_surface_render( |
|
|
|
|
cairo_surface_t* surface, hvif_image* image, double scale) |
|
|
|
|
{ |
|
|
|
|
assert(surface != NULL); |
|
|
|
|
assert(image != NULL); |
|
|
|
|
cairo_t* cr = cairo_create(surface); |
|
|
|
|
cairo_scale(cr, scale, scale); |
|
|
|
|
hvif_cairo_status result = hvif_cairo_render(cr, image, scale); |
|
|
|
@ -387,6 +407,8 @@ hvif_cairo_surface_render(
|
|
|
|
|
hvif_cairo_status |
|
|
|
|
hvif_cairo_render(cairo_t* context, hvif_image* image, double scale) |
|
|
|
|
{ |
|
|
|
|
assert(context != NULL); |
|
|
|
|
assert(image != NULL); |
|
|
|
|
cairo_save(context); |
|
|
|
|
|
|
|
|
|
cairo_pattern_t** patterns = |
|
|
|
@ -440,3 +462,4 @@ hvif_cairo_render(cairo_t* context, hvif_image* image, double scale)
|
|
|
|
|
cairo_restore(context); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|