The svg image editor svgedit is used to draw the gml4gtk and mooigraph node shapes and the resulting svg image data is used with a program to create C-source with GTK+ cairo library routines and this is easier then using librsvg.

For this work using this javascript svgedit version in svg-edit-2.8.1.tar.gz

To try this web based javascript svg image editor it is here in svgedit

The newest svgedit version is here on https://github.com/SVG-Edit/svgedit

Used the svg-edit version 2.8.1
On Linux untar it in a directory
start http server with
python -m SimpleHTTPServer
point browser to localhost:8000
Goto the index.html of sgedit

It is possible to convert every pixel in a png or jpg image into a svg drawing command
on github are multiple tools like this one https://github.com/mayuso/PNGToSVG

But those svg commands can also be translated into C source doing cairo lib commands
or C++ doing qt5 drawing commands or python etc.

My small c program to convert the easy svg data from svgedit looks like this
/* GNU GPL version 3 */

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

#define LBS 32*1032
char lbuf[LBS];
char c = 0;
char pc = 0;
int ic = 0;
char *p = (char *) 0;
char *q = (char *) 0;
char *r = (char *) 0;
int pend = 0;

int
main (int argc, char *argv)
{

  printf ("#define MCOMMAND(dx,dy) cairo_rel_move_to(crp,dx,dy)\n");
  printf ("#define LCOMMAND(dx,dy) cairo_rel_line_to(crp,dx,dy)\n");
  printf
    ("#define CCOMMAND(x1,y1,x2,y2,x,y) cairo_rel_curve_to(crp,x1,y1,x2,y2,x,y)\n");

  for (;;)
    {
      ic = 0;
      memset (lbuf, 0, LBS);

      while ((c = fgetc (stdin)) != EOF)
    {
      if (c == '\n')
        {
          break;
        }
      lbuf[ic] = (char) c;
      ic++;
    }

      if (ic == 0)
    {
      break;
    }

      p = strstr (lbuf, "path");

      if (p)
    {
      q = strstr (p, " d=\"");
      if (q)
        {
          r = strchr (q, '\"');
          if (r)
        {
          r++;

          while ((*r))
            {
              if ((*r) == '\"')
            {
              break;
            }
              if ((*r) == 'z')
            {
              break;
            }
              if ((*r) == 'm')
            {
              if (pend)
                {
                  printf (");\n");
                }
              printf ("MCOMMAND(");
              pend = 1;
              r++;
            }
              if ((*r) == 'l')
            {
              if (pend)
                {
                  printf (");\n");
                }
              printf ("LCOMMAND(");
              pend = 1;
              r++;
            }
              if ((*r) == 'c')
            {
              if (pend)
                {
                  printf (");\n");
                }
              printf ("CCOMMAND(");
              pend = 1;
              r++;
            }
              if ((*r) == ' ')
            {
              (*r) = ',';
            }
              printf ("%c", *r);
              r++;
            }
          if (pend)
            {
              printf (");\n");
            }
          pend = 0;
        }
        }
    }

    }

  return (0);
}

/* end */

As example this is svg created with svgedit

<?xml version="1.0" encoding="UTF-8"?>
<svg width="104" height="101" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
 <g>
  <title>Layer 1</title>
  <path id="svg_1" d="m0.001461,20.164606l20.765173,-20.166117l83.234846,0l0,100.999985l-104.000019,0l0,-80.833868z" stroke-width="0" stroke="#000000" fill="#FF0000"/>
 </g>
</svg>

The above C program generates this C output from the svg data

#define MCOMMAND(dx,dy) cairo_rel_move_to(crp,dx,dy)
#define LCOMMAND(dx,dy) cairo_rel_line_to(crp,dx,dy)
#define CCOMMAND(x1,y1,x2,y2,x,y) cairo_rel_curve_to(crp,x1,y1,x2,y2,x,y)
MCOMMAND(0.001461,20.164606);
LCOMMAND(20.765173,-20.166117);
LCOMMAND(83.234846,0);
LCOMMAND(0,100.999985);
LCOMMAND(-104.000019,0);
LCOMMAND(0,-80.833868);
And using gnu cpp this is the resulting C source to include


cairo_rel_move_to(crp,0.001461,20.164606);
cairo_rel_line_to(crp,20.765173,-20.166117);
cairo_rel_line_to(crp,83.234846,0);
cairo_rel_line_to(crp,0,100.999985);
cairo_rel_line_to(crp,-104.000019,0);
cairo_rel_line_to(crp,0,-80.833868);
And this is example how this is integrated into the gtk+ drawing code


/* sizes and points at 1:1 100% scaling */
#define SVG_CARD_XSIZE 104
#define SVG_CARD_YSIZE 101
#define SVG_CARD_TXSIZE 96
#define SVG_CARD_TYSIZE 90
#define SVG_CARD_TOX 5
#define SVG_CARD_TOY 6
static void
draw_nodeshape_card (cairo_t * crp, gdouble x0, gdouble y0, gdouble xs, gdouble ys, int rc, int gc, int bc, struct unode *un)
{
  cairo_path_t *cpt = (cairo_path_t *) 0;
  int r = 0;
  int g = 0;
  int b = 0;

  /* outline color */
  r = (un->bcolor & 0x00ff0000) >> 16;
  g = (un->bcolor & 0x0000ff00) >> 8;
  b = (un->bcolor & 0x000000ff);

  /* change color if in alt color drawing mode */
  if (altcolor)
    {
      if (un->bitflags.altcolor == 1)
    {
      /* change in white if drawing as altcolor */
      r = altr;
      g = altg;
      b = altb;
    }
    }

  cairo_set_source_rgb (crp, r / 255.0, g / 255.0, b / 255.0);
  /* upperleft start point */
  cairo_new_path (crp);
  cairo_save (crp);
  cairo_move_to (crp, x0, y0);
  /* */
  cairo_scale (crp, xs, ys);
  /* generated by svg to cairo-lib c tool start */
  cairo_rel_move_to (crp, 0.001461, 20.164606);
  cairo_rel_line_to (crp, 20.765173, -20.166117);
  cairo_rel_line_to (crp, 83.234846, 0);
  cairo_rel_line_to (crp, 0, 100.999985);
  cairo_rel_line_to (crp, -104.000019, 0);
  cairo_rel_line_to (crp, 0, -80.833868);
  /* generated by svg to cairo-lib c tool end */
  cairo_close_path (crp);
  /* save copy of this path to use for fill below */
  cpt = cairo_copy_path (crp);
  /* */
  cairo_stroke (crp);
  /* fill color into path */
  cairo_append_path (crp, cpt);

  r = rc;
  g = gc;
  b = bc;

  /* change color if in alt color drawing mode */
  if (altcolor)
    {
      if (un->bitflags.altcolor == 1)
    {
      /* change in white if drawing as altcolor */
      r = 0xff;
      g = 0xff;
      b = 0xff;
    }
    }
  /* fill color */
  cairo_set_source_rgb (crp, r / 255.0, g / 255.0, b / 255.0);
  cairo_fill (crp);
  cairo_stroke (crp);
  cairo_path_destroy (cpt);
  cairo_restore (crp);

  return;
}