From 5a7e2a0547da9c6fc9169cb6ee4234674db8a4bd Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Sat, 24 Oct 2020 22:57:05 +0200 Subject: [PATCH] added some text drawing --- main.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/main.cpp b/main.cpp index 9e54c9f..1cf3d2d 100644 --- a/main.cpp +++ b/main.cpp @@ -32,15 +32,30 @@ void draw(sc::gui::Window& window) { cairo_surface_t* cs {cairo_image_surface_create_for_data(static_cast(s->pixels), CAIRO_FORMAT_RGB24, s->w, s->h, s->pitch)}; cairo_t* cr {cairo_create(cs)}; + + // white background cairo_set_source_rgb(cr, 1, 1, 1); cairo_rectangle(cr, 0, 0, s->w, s->h); cairo_fill(cr); + + // orange rectangle cairo_rectangle(cr, 300, 300, 100, 100); cairo_set_source_rgb(cr, 1, 0.5, 0); cairo_fill(cr); + + // black rectangle cairo_rectangle(cr, 200, 200, 100, 100); cairo_set_source_rgb(cr, 0, 0, 0); cairo_fill(cr); + + // light blue text + cairo_set_source_rgb(cr, 0, 0.5, 1); + cairo_select_font_face(cr, "Optima", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); + cairo_set_font_size(cr, 42); + cairo_move_to(cr, 350, 150); + cairo_show_text(cr, "Cairo on SDL"); + + // show window.show_image(image); cairo_surface_destroy(cs); cairo_destroy(cr);