#include "cairo.h"
#include "cairo-svg.h"
#include <stdio.h>


// Debug code for cairo_mask
void debug_cairo_mask()
{

	cairo_surface_t* surf = cairo_svg_surface_create ("test_out.svg", 595, 842);
	cairo_t* ctx = cairo_create(surf);

	cairo_matrix_t matrix;

	cairo_set_source_rgb (ctx, 1, 1, 1);
	cairo_fill(ctx);

	cairo_surface_t* mask_surf = cairo_image_surface_create_from_png("mask.png");
	if (cairo_surface_status(mask_surf) == CAIRO_STATUS_SUCCESS)
	{		
		cairo_pattern_t* mask_pattern = cairo_pattern_create_for_surface(mask_surf);	
		
		cairo_save(ctx);
		cairo_matrix_init(&matrix, 0.5, 0.00, 0.00, -0.5, 250, 350);
		/*cairo_matrix_init(&matrix, 0.5, 0.00, 0.00, 0.5, 250, 350);*/
		cairo_set_matrix(ctx, &matrix);

		cairo_set_source_rgb(ctx,0,0,0);
		cairo_mask(ctx, mask_pattern);

		cairo_pattern_destroy(mask_pattern);
		cairo_surface_destroy(mask_surf);
	
		cairo_restore(ctx);
		cairo_surface_write_to_png(surf, "test_out.png");
	}
	else 
	{ 
		printf("Can not create surface from file \"mask.png\". Check that the file exists and is not corrupted.\n\n");
	}
	cairo_destroy(ctx);
	cairo_surface_destroy(surf);
}