Library for rendering images and videos directly using C and the NetPBM image format
Compile repo:
make
./render
or
g++ -o render main.cpp Artwork/Color.h Artwork/Artwork.h Artwork/Artwork.c
./render
Include header:
#include "Artwork/Artwork.h"
Create artwork and set values:
Artwork art = newArt(400, 400);
Dont forget to free afterwards to avoid memory leaks!
freeArt(art);
Set color scheme with stroke, fill and stroke width:
art.strokeColor = Color { 255, 0, 0 };
art.strokeWidth = 5;
art.fillColor = Color { 200, 200, 200 };
Set individual pixel
setPixel(art, <x>, <y>, Color {255, 255, 255});
Draw line (color determined by stroke color):
drawLine(art, <x0>, <y0>, <x1>, <y1>);
Draw rect:
drawRect(art, <top-left x>, <top-left y>, <width>, <height>);
Draw circle:
drawCircle(art, <x>, <y>, <radius>);
Draw ellipse:
drawEllipse(art, <x>, <y>, <x-radius>, <y-radius>);
Clear artwork / fill it entirely_
clear(art, Color { 0, 0, 0 });
Save as a single image:
char filename[] = "nicePic.ppm";
saveArt(art, filename);
Pipe it out (necessary for video creation):
pipeArtTo(art, stdout);
Pipe it to VLC:
./ExecutableNameHere | ppmtoy4m -F60:1 | vlc -
Or render the complete video:
./ExecutableNameHere | ffmpeg -i pipe:0 -c:v libx264rgb VideoName.avi
The SFML_Artwork class is essentially a C++ wrapper for the standard rendering. It enables you to create Artworks from sf::Image objects, the entire window for example.
#include "SFML_Artwork/SFML_Artwork.h"
Create your window and rendering:
RenderWindow window(VideoMode(800, 800), "Rendering");
Rendering* rendering = createRendering(800, 800);
Texture texture;
Image image;
Vector2u windowsize;
Save your window as an image:
windowsize = window.getSize();
texture.create(windowsize.x, windowsize.y);
texture.update(window);
image = texture.copyToImage();
Artwork art = SFML_Artwork::fromImage(image);
saveArt(art);