canvaz
LmanTW/canvaz
-
A simple, easy-to-use image processing library written entirely in Zig.
3 3 0 1
4
image-processing, zig, zig-library, zig-package
build.zig.zon
build.zig
View on Github
LmanTW/canvaz
A simple, easy-to-use image processing library written entirely in Zig.
A simple, easy-to-use image processing library written entirely in Zig.
NOTE Canvaz is still in early development and is halted. I might revisit this project after I'm more experienced with Zig.
const canvaz = @import("canvaz");
const std = @import("std");
const Shape = canvaz.Shape;
pub fn main() !void {
const canvas = try canvaz.init(512, 512, std.heap.page_allocator);
defer canvas.deinit();
const image = try canvaz.Image.initFromFile("image.png", canvas.allocator);
defer image.deinit();
canvas.drawShape(Shape.circle(0, 0, 512), canvaz.Color.black);
canvas.drawImage(image, Shape.roundRectangle(256, 256, 320, 320, 32).move(-0.5, -0.5), .cover);
canvas.drawFilter(canvaz.Filter.posterize(0.15), Shape.rectangle(0, 0, 256, 512));
try canvas.saveToFile("result.png");
}
zig fetch --save "https://github.com/zigimg/zigimg/archive/[commit hash].tar.gz"
build.zig
.const canvaz = b.dependency("canvaz", .{
.target = target,
.optimize = optimize
})
exe.root_module.addImport("canvaz", canvaz.module("canvaz"));
WARNING Canvaz uses zigimg which uses the nominated 2024.10.0-mach version of Zig.
Canvaz is designed to be simple and easy-to-use while still offering the capability for advanced more graphics processing. As a result, you can easily perform image and filter masking in Canvaz.
Initialize and saving a canvas. | Clearing and filling the canvas. |
|
|
Initialize a color. | Modifing the color. |
|
|
Initialize a shape. | Moving the shape. | Drawing the shape. |
|
|
|
Initialize an image. | Scaling the image. | Drawing the image. |
|
|
|
NOTE Check out zigimg for the supported formats.
Drawing the filter. |
|