Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
coverage.c File Reference
#include <math.h>
#include "cairo_test.h"

Go to the source code of this file.

Defines

#define WIDTH   64
#define HEIGHT   64
#define PAD   10
#define ARRAY_SIZE(a)   (sizeof (a) / sizeof ((a)[0]))
#define IMAGE_WIDTH   (ARRAY_SIZE (pattern_funcs) * (WIDTH + PAD) + PAD)
#define IMAGE_HEIGHT   (ARRAY_SIZE (draw_funcs) * (HEIGHT + PAD) * 2 + PAD)

Functions

static void set_solid_pattern (cairo_t *cr, int x, int y)
static void set_translucent_pattern (cairo_t *cr, int x, int y)
static void set_gradient_pattern (cairo_t *cr, int x, int y)
static void set_image_pattern (cairo_t *cr, int x, int y)
static void set_translucent_image_pattern (cairo_t *cr, int x, int y)
static void draw_text (cairo_t *cr, int x, int y)
static void draw_polygon (cairo_t *cr, int x, int y)
static void draw (cairo_t *cr, int width, int height)
int main (void)

Variables

const char fontname [] = "Bitstream Vera Sans"
const int fontsize = 40
const char png_filename [] = "romedalen.png"
static void(* pattern_funcs [])(cairo_t *cr, int x, int y)
static void(* draw_funcs [])(cairo_t *cr, int x, int y)
static cairo_test_t test

Define Documentation

#define ARRAY_SIZE (   a)    (sizeof (a) / sizeof ((a)[0]))

Definition at line 121 of file coverage.c.

#define HEIGHT   64

Definition at line 30 of file coverage.c.

Definition at line 123 of file coverage.c.

Definition at line 122 of file coverage.c.

#define PAD   10

Definition at line 31 of file coverage.c.

#define WIDTH   64

Definition at line 29 of file coverage.c.


Function Documentation

static void draw ( cairo_t *  cr,
int  width,
int  height 
) [static]

Definition at line 133 of file coverage.c.

{
    /* TODO: pattern fill, gradient fill, clipping, gradient clipping,
       path+solid alpha mask clipping */

    int i, j, x, y;

    cairo_select_font (cr, fontname,
                     CAIRO_FONT_SLANT_NORMAL,
                     CAIRO_FONT_WEIGHT_BOLD);
    cairo_scale_font (cr, fontsize);

    for (j = 0; j < ARRAY_SIZE (draw_funcs); j++) {
       for (i = 0; i < ARRAY_SIZE (pattern_funcs); i++) {
           x = i * (WIDTH + PAD) + PAD;
           y = j * (HEIGHT + PAD) + PAD;
           cairo_move_to (cr, x, y);
           pattern_funcs[i] (cr, x, y);
           draw_funcs[j] (cr, x, y);
       }
    }

    for (j = 0; j < ARRAY_SIZE (draw_funcs); j++) {
       for (i = 0; i < ARRAY_SIZE (pattern_funcs); i++) {
           x = i * (WIDTH + PAD) + PAD;
           y = (ARRAY_SIZE (draw_funcs) + j) * (HEIGHT + PAD) + PAD;

           cairo_save (cr);

           cairo_set_alpha (cr, 1.0);
           cairo_new_path (cr);
           cairo_arc (cr, x + WIDTH / 2, y + HEIGHT / 2,
                     WIDTH / 3, 0, 2 * M_PI);
           cairo_clip (cr);

           cairo_move_to (cr, x, y);
           pattern_funcs[i] (cr, x, y);
           draw_funcs[j] (cr, x, y);

           cairo_restore (cr);

       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void draw_polygon ( cairo_t *  cr,
int  x,
int  y 
) [static]

Definition at line 95 of file coverage.c.

static void draw_text ( cairo_t *  cr,
int  x,
int  y 
) [static]

Definition at line 88 of file coverage.c.

int main ( void  )

Definition at line 179 of file coverage.c.

{
    return cairo_test (&test, draw);
}

Here is the call graph for this function:

static void set_gradient_pattern ( cairo_t *  cr,
int  x,
int  y 
) [static]

Definition at line 55 of file coverage.c.

{
    cairo_pattern_t *pattern;

    pattern =
       cairo_pattern_create_linear (x, y, x + WIDTH, y + HEIGHT);
    cairo_pattern_add_color_stop (pattern, 0, 1, 1, 1, 1);
    cairo_pattern_add_color_stop (pattern, 1, 0, 0, 0.4, 1);
    cairo_set_pattern (cr, pattern);
    cairo_set_alpha (cr, 1);
}
static void set_image_pattern ( cairo_t *  cr,
int  x,
int  y 
) [static]

Definition at line 68 of file coverage.c.

{
    cairo_pattern_t *pattern;

    pattern = cairo_test_create_png_pattern (cr, png_filename);
    cairo_set_pattern (cr, pattern);
    cairo_set_alpha (cr, 1);
}

Here is the call graph for this function:

static void set_solid_pattern ( cairo_t *  cr,
int  x,
int  y 
) [static]

Definition at line 41 of file coverage.c.

{
    cairo_set_rgb_color (cr, 0, 0, 0.6);
    cairo_set_alpha (cr, 1.0);
}
static void set_translucent_image_pattern ( cairo_t *  cr,
int  x,
int  y 
) [static]

Definition at line 78 of file coverage.c.

{
    cairo_pattern_t *pattern;

    pattern = cairo_test_create_png_pattern (cr, png_filename);
    cairo_set_pattern (cr, pattern);
    cairo_set_alpha (cr, 0.5);
}

Here is the call graph for this function:

static void set_translucent_pattern ( cairo_t *  cr,
int  x,
int  y 
) [static]

Definition at line 48 of file coverage.c.

{
    cairo_set_rgb_color (cr, 0, 0, 0.6);
    cairo_set_alpha (cr, 0.5);
}

Variable Documentation

void(* draw_funcs[])(cairo_t *cr, int x, int y) [static]
Initial value:

Definition at line 116 of file coverage.c.

const char fontname[] = "Bitstream Vera Sans"

Definition at line 36 of file coverage.c.

Definition at line 37 of file coverage.c.

void(* pattern_funcs[])(cairo_t *cr, int x, int y) [static]
const char png_filename[] = "romedalen.png"

Definition at line 38 of file coverage.c.

cairo_test_t test [static]
Initial value:
 {
    "coverage",
    "Various coverage test of cairo",
    IMAGE_WIDTH, IMAGE_HEIGHT
}

Definition at line 125 of file coverage.c.