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

Page 156

Advertising
background image

KTD-S0057-I

Page 152 Linux® Programming Examples (DebianTM)


KTAM3874/pITX Software Guide

/***************************************************************
* Cairo PDF demonstration program

* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License.
****************************************************************/

#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <cairo/cairo-pdf.h>

/* #include <cairo/cairo-ps.h>
#include <cairo/cairo-svg.h> */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define WIDTH

595

#define HEIGHT

842

#define OBJ1_COL1

"black"

#define OBJ1_COL2

"sienna"

#define OBJ2_COL1

"red"

#define OBJ2_COL2

"blue"

#define OBJ2_XOFFS 300
#define OBJ2_YOFFS 0
#define NUM_TEXT

20

#define TEXT_WIDTH

250.0

#define TEXT_HEIGHT

250.0

#define TEXT_SIZE

20.0

#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)

typedef struct {
Display

*disp;

Colormap

cmap;

} XSystem;

static void draw_quadrant (XSystem sys, cairo_t *cr, const char *text, const cairo_text_extents_t *extents,

const cairo_matrix_t *transform, int x_off, int y_off)

{
XColor

col;

int

i;

for (i = 0; i < NUM_TEXT / 4; i++)

{

cairo_save

(cr);

cairo_rotate (cr, 2.0 * M_PI * (double) i / (double) NUM_TEXT);

cairo_transform (cr, transform);

cairo_set_line_width (cr, 1.0);

cairo_rectangle (cr, (double) x_off - 0.5, (double) y_off - 0.5, extents->width + 1.0, extents->height + 1.0);

Advertising
This manual is related to the following products: