// test.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
// Use cario
#include "../include/cairo/cairo-win32.h" // exam_draw_img
#include "../include/cairo/cairo-pdf.h" // exam_draw_pdf
#include "../include/cairo/cairo-svg.h" // exam_draw_svg
#pragma comment(lib, "../lib/cairo.lib")
void exam_draw_png()
{
cairo_surface_t *surface;
cairo_t *cr;
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 640, 480);
cr = cairo_create (surface);
cairo_select_font_face (cr, "serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 32.0);
cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
cairo_move_to (cr, 100.0, 100.0);
cairo_show_text (cr, "This is an Example using PNG as drawing output!");
cairo_rectangle(cr,10,10,100,100);
cairo_set_line_width(cr,10);
cairo_set_source_rgb(cr,0,0,1);
cairo_stroke(cr);
cairo_move_to(cr,0,0);
cairo_line_to(cr,100,100);
cairo_set_source_rgb(cr,1,0,0);
cairo_stroke(cr);
cairo_surface_write_to_png (surface, "c://exam_draw_png.png");
cairo_destroy (cr);
cairo_surface_destroy (surface);
}
void exam_draw_pdf()
{
cairo_surface_t *surface;
cairo_t *cr;
surface = cairo_pdf_surface_create ("c://exam_draw_pdf.pdf", 640, 480);
cr = cairo_create (surface);
cairo_select_font_face (cr, "serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 32.0);
cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
cairo_move_to (cr, 100, 100);
cairo_show_text (cr, "This is an Example using PDF as drawing output!");
cairo_rectangle(cr,10,10,100,100);
cairo_set_line_width(cr,10);
cairo_set_source_rgb(cr,0,0,1);
cairo_stroke(cr);
cairo_move_to(cr,0,0);
cairo_line_to(cr,100,100);
cairo_set_source_rgb(cr,1,0,0);
cairo_stroke(cr);
cairo_show_page (cr);
cairo_destroy (cr);
cairo_surface_destroy (surface);
}
void exam_draw_svg()
{
cairo_surface_t *surface;
cairo_t *cr;
surface = cairo_svg_surface_create ("c://exam_draw_svg.svg", 320, 48);
cr = cairo_create (surface);
cairo_set_source_rgb (cr, 0.627, 0, 0);
cairo_select_font_face (cr, "serif",
CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 24.0);
cairo_move_to (cr, 10.0, 34.0);
cairo_show_text (cr, "This is an Example using SVG as drawing output!");
cairo_destroy (cr);
cairo_surface_destroy (surface);
}
int _tmain(int argc, _TCHAR* argv[])
{
exam_draw_png();
exam_draw_svg();
exam_draw_pdf();
return 0;
}