beautypg.com

Ktam3874/pitx software guide – Kontron KTAM3874-pITX User Manual

Page 148

background image

KTD-S0057-I

Page 144 Linux® Programming Examples (DebianTM)


KTAM3874/pITX Software Guide


static void draw_cairo_object2 (XSystem sys, cairo_t *cr)
{
XColor

col;

double x = 0.0, y = 0.0,

width = OBJ_WIDTH,

height = OBJ_HEIGHT,

radius = HALF(OBJ_WIDTH);

cairo_save

(cr);

cairo_arc (cr, x + radius, y + radius, radius, 0.0, 2.0 * M_PI);

cairo_clip

(cr);

cairo_new_path (cr);

/* current path is not consumed by cairo_clip */

XAllocNamedColor (sys.disp, sys.cmap, OBJ2_COL1, &col, &col);

cairo_set_source_rgb (cr, RGB_R (C(col)), RGB_G (C(col)), RGB_B (C(col)));

cairo_rectangle (cr, x, y, width, height);

cairo_fill

(cr);

XAllocNamedColor (sys.disp, sys.cmap, OBJ2_COL2, &col, &col);

cairo_set_source_rgb (cr, RGB_R (C(col)), RGB_G (C(col)), RGB_B (C(col)));

cairo_move_to (cr, x, y);

cairo_line_to (cr, x + width, y + height);

cairo_move_to (cr, x + width, y);

cairo_line_to (cr, x, y + height);

cairo_set_line_width (cr, LINE_WIDTH);

cairo_stroke

(cr);

cairo_restore

(cr);

}

static void draw_cairo_object3 (XSystem sys, cairo_t *cr)
{
XColor

col;

double x = 0.0, y = 0.0,

width = OBJ_WIDTH,

height = OBJ_HEIGHT,

dashes[] = { 50.0, 10.0, 10.0, 10.0 },

offset = -dashes[0];

int ndash = sizeof (dashes) / sizeof (dashes[0]);

cairo_save

(cr);

XAllocNamedColor (sys.disp, sys.cmap, OBJ3_COL, &col, &col);

cairo_set_source_rgb (cr, RGB_R (C(col)), RGB_G (C(col)), RGB_B (C(col)));

cairo_set_dash (cr, dashes, ndash, offset);

cairo_set_line_width (cr, LINE_WIDTH);

cairo_move_to (cr, x + HALF(width), y);

cairo_line_to (cr, x + width, y + height);

cairo_rel_line_to

(cr, -HALF(width), 0.0);

cairo_curve_to (cr, x + QUART(width), y + height, x + QUART(width), y + HALF(height),

x + HALF(width), y + HALF(height));

cairo_stroke

(cr);

cairo_restore

(cr);

}

This manual is related to the following products: