Ktam3874/pitx software guide – Kontron KTAM3874-pITX User Manual
Page 147
KTD-S0057-I
Page 143 Linux® Programming Examples (DebianTM)
KTAM3874/pITX Software Guide
#define STAT_TXT
"Six cairo samples successfully drawn"
#define RGB_R(c)
((double)((c>>16)&255)/255.0)
#define RGB_G(c)
((double)((c>>8)&255)/255.0)
#define RGB_B(c)
((double)(c&255)/255.0)
#define C(c)
(c.pixel)
#define HALF(x)
(x/2.0)
#define QUART(x)
(x/4.0)
#define FIFTH(x)
(x/5.0)
#define TENTH(x)
(x/10.0)
typedef struct {
Display
*disp;
Window
win;
Colormap
cmap;
Visual
*visual;
int
screen;
GC
gc;
XFontStruct
*font;
Pixmap
pict;
Atom
close;
} XSystem;
static void draw_cairo_object1 (XSystem sys, cairo_t *cr)
{
XColor
col;
double x0 = 0.0, y0 = 0.0,
width = OBJ_WIDTH,
height = OBJ_HEIGHT,
radius = HALF(OBJ_WIDTH),
x1 = x0 + width,
y1 = y0 + height;
cairo_save
(cr);
cairo_move_to (cr, x0, y0 + radius);
cairo_curve_to (cr, x0 , y0, x0 , y0, x0 + radius, y0);
cairo_line_to (cr, x1 - radius, y0);
cairo_curve_to (cr, x1, y0, x1, y0, x1, y0 + radius);
cairo_line_to (cr, x1 , y1 - radius);
cairo_curve_to (cr, x1, y1, x1, y1, x1 - radius, y1);
cairo_line_to (cr, x0 + radius, y1);
cairo_curve_to (cr, x0, y1, x0, y1, x0, y1- radius);
cairo_close_path
(cr);
XAllocNamedColor (sys.disp, sys.cmap, OBJ1_COL1, &col, &col);
cairo_set_source_rgb (cr, RGB_R (C(col)), RGB_G (C(col)), RGB_B (C(col)));
cairo_fill_preserve
(cr);
XAllocNamedColor (sys.disp, sys.cmap, OBJ1_COL2, &col, &col);
cairo_set_source_rgba (cr, RGB_R (C(col)), RGB_G (C(col)), RGB_B (C(col)), ALPHA);
cairo_set_line_width (cr, LINE_WIDTH);
cairo_stroke
(cr);
cairo_restore
(cr);
}