https://github.com/davecom/supersimplegraphics
An SVG generating single header file C library appropriate for "intro to programming" classes in C/C++.
https://github.com/davecom/supersimplegraphics
intro-to-c introduction-to-programming svg
Last synced: 27 days ago
JSON representation
An SVG generating single header file C library appropriate for "intro to programming" classes in C/C++.
- Host: GitHub
- URL: https://github.com/davecom/supersimplegraphics
- Owner: davecom
- License: mit
- Created: 2018-09-15T03:46:27.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-01T03:47:11.000Z (over 7 years ago)
- Last Synced: 2025-01-09T09:52:51.502Z (over 1 year ago)
- Topics: intro-to-c, introduction-to-programming, svg
- Language: C
- Homepage:
- Size: 13.7 KB
- Stars: 6
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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:
```C
void start_graphics(int width, int height)
```
Starts the creation of a new SVG file with a canvas of `width` and `height` dimensions.
```C
void draw_ellipse(int x, int y, int width, int height, const char *color)
```
Draws an ellipse.
```C
void draw_rectangle(int x, int y, int width, int height, const char *color)
```
Draws a rectangle.
```C
void draw_line(int x1, int y1, int x2, int y2, const char *color)
```
Draws a line.
```C
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.

- `sierpinski.c` draws sierpinski triangles

Running them is as simple as:
```bash
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.