]> gitweb.michael.orlitzky.com - libsvgtiny-pixbuf.git/commitdiff
example.c: use transparent background.
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 4 Aug 2023 13:19:51 +0000 (09:19 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Fri, 4 Aug 2023 13:19:51 +0000 (09:19 -0400)
example.c

index d0b0af074c7251fd4693898d8d8ce2d66c4b5eb4..aa71e233cee108f95056f3d6d9edd18371c5fbb2 100644 (file)
--- a/example.c
+++ b/example.c
@@ -69,17 +69,19 @@ static void render_path(cairo_t* cr, shape_t* path) {
     }
   }
   if (path->fill != svgtiny_TRANSPARENT) {
-    cairo_set_source_rgb(cr,
-                        svgtiny_RED(path->fill) / 255.0,
-                        svgtiny_GREEN(path->fill) / 255.0,
-                        svgtiny_BLUE(path->fill) / 255.0);
+    cairo_set_source_rgba(cr,
+                         svgtiny_RED(path->fill) / 255.0,
+                         svgtiny_GREEN(path->fill) / 255.0,
+                         svgtiny_BLUE(path->fill) / 255.0,
+                         1);
     cairo_fill_preserve(cr);
   }
   if (path->stroke != svgtiny_TRANSPARENT) {
-    cairo_set_source_rgb(cr,
-                        svgtiny_RED(path->stroke) / 255.0,
-                        svgtiny_GREEN(path->stroke) / 255.0,
-                        svgtiny_BLUE(path->stroke) / 255.0);
+    cairo_set_source_rgba(cr,
+                         svgtiny_RED(path->stroke) / 255.0,
+                         svgtiny_GREEN(path->stroke) / 255.0,
+                         svgtiny_BLUE(path->stroke) / 255.0,
+                         1);
     cairo_set_line_width(cr, path->stroke_width);
     cairo_stroke_preserve(cr);
   }
@@ -175,7 +177,7 @@ static cairo_t* cairo_context_from_diagram(diagram_t* diagram) {
   cairo_status_t crs;
   unsigned int i;
 
-  surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24,
+  surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
                                       diagram->width,
                                       diagram->height);
 
@@ -203,7 +205,7 @@ static cairo_t* cairo_context_from_diagram(diagram_t* diagram) {
     return NULL;
   }
 
-  cairo_set_source_rgb(cr, 1, 1, 1);
+  cairo_set_source_rgba(cr, 0, 0, 0, 0);
   cairo_paint(cr);
 
   /* Loop through the shapes in the diagram... */
@@ -218,10 +220,11 @@ static cairo_t* cairo_context_from_diagram(diagram_t* diagram) {
     if (diagram->shape[i].text) {
       /* Figure out what color to use from the R/G/B components of the
         shape's stroke. */
-      cairo_set_source_rgb(cr,
-                          svgtiny_RED(diagram->shape[i].stroke) / 255.0,
-                          svgtiny_GREEN(diagram->shape[i].stroke) / 255.0,
-                          svgtiny_BLUE(diagram->shape[i].stroke) / 255.0);
+      cairo_set_source_rgba(cr,
+                           svgtiny_RED(diagram->shape[i].stroke) / 255.0,
+                           svgtiny_GREEN(diagram->shape[i].stroke) / 255.0,
+                           svgtiny_BLUE(diagram->shape[i].stroke) / 255.0,
+                           1);
       /* Then move to the actual position of the text within the
         shape... */
       cairo_move_to(cr,