Ejemplo n.º 1
0
int main (int argc, char *argv[])
{
  cairo_surface_t *surface;
  cairo_t *cr;

  surface = cairo_linuxfb_surface_create(NULL);
  cr = cairo_create(surface);
  
  cairo_paint(cr);

  cairo_select_font_face(cr, "serif", CAIRO_FONT_SLANT_NORMAL,
			 CAIRO_FONT_WEIGHT_BOLD);
  cairo_set_font_size(cr, 80.0);
  cairo_set_source_rgb(cr, 1.0, 0.0, 1.0);
  cairo_move_to(cr, 00.0, 100.0);
  cairo_show_text(cr, "Hello");

  cairo_set_source_rgb(cr, 0.0, 1.0, 0.0);
  cairo_move_to(cr, 00.0, 180.0);
  cairo_show_text(cr, "World!");

  cairo_destroy(cr);
  cairo_surface_destroy(surface);

  return 0;
}
Ejemplo n.º 2
0
int main(int argc, char *argv[]) {
    char fb_node[16] = "/dev/fb0";
    char *tsdevice = NULL;
    struct tsdev *ts;
    struct sigaction action;
    cairo_linuxfb_device_t *device;
    cairo_surface_t *fbsurface;
    cairo_t *fbcr;

    if (argc > 1) {
        strcpy(fb_node, argv[1]);
    }

    printf("Frame buffer node is: %s\n", fb_node);

    if( (tsdevice = getenv("TSLIB_TSDEVICE")) != NULL )
        ts = ts_open(tsdevice, 1);
    else
        ts = ts_open("/dev/input/event0", 1);

    if (ts_config(ts)) {
        perror("ts_config");
        exit(1);
    }

    device = malloc(sizeof(*device));
    if (!device) {
        perror("Error: cannot allocate memory\n");
        exit(1);
    }

    memset(&action, 0, sizeof(struct sigaction));
    action.sa_handler = signal_handler;
    sigaction(SIGTERM, &action, NULL);
    sigaction(SIGINT, &action, NULL);

    fbsurface = cairo_linuxfb_surface_create(device, fb_node);
    fbcr = cairo_create(fbsurface);

    draw_rectangles(fbcr, ts, device);

    cairo_destroy(fbcr);
    cairo_surface_destroy(fbsurface);

    return 0;
}