Skip to content

An SVG generating single header file C library appropriate for "intro to programming" classes in C/C++.

License

Notifications You must be signed in to change notification settings

davecom/SuperSimpleGraphics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SuperSimpleGraphics

This is an extremely simplistic SVG generating single header file C library appropriate for "intro to programming" classes in C or C++. Using it is as simple as dropping ssg.h into your project and then #include "ssg.h" in your source file. Right now it is a hack done in a couple hours with two example programs as a proof of concept, so there's not yet a lot of error checking or features.

Documentation

There are only five functions for now:

void start_graphics(int width, int height)

Starts the creation of a new SVG file with a canvas of width and height dimensions.

void draw_ellipse(int x, int y, int width, int height, const char *color)

Draws an ellipse.

void draw_rectangle(int x, int y, int width, int height, const char *color)

Draws a rectangle.

void draw_line(int x1, int y1, int x2, int y2, const char *color)

Draws a line.

void write_graphics(const char *name)

Writes an svg file with the filename name and the .svg extension. Frees any used memory and closes the file.

Examples

So far there are two simple examples included in this directory:

  • france_flag.c draws the French flag.

French Flag

  • sierpinski.c draws sierpinski triangles

Sierpinski Triangles

Running them is as simple as:

gcc france_flag.c
./a.out

Then a .svg file will be generated in the same directory. They have been tested with clang on macOS, gcc on GNU/Linux, and Visual C++ on Windows.

License

Licensed under the MIT license.

About

An SVG generating single header file C library appropriate for "intro to programming" classes in C/C++.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages