https://github.com/deevus/zig-squarified
https://github.com/deevus/zig-squarified
zig-package
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/deevus/zig-squarified
- Owner: deevus
- Created: 2025-01-02T09:47:30.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-05T08:34:38.000Z (over 1 year ago)
- Last Synced: 2025-03-11T11:20:01.372Z (over 1 year ago)
- Topics: zig-package
- Language: Zig
- Homepage:
- Size: 36.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# zig-squarified
**A library for generating squarified treemap layouts in Zig.**
## Demo
```
zig build run
```
Runs a basic Raylib demo that displays a treemap.

## Install as a Zig package
```
zig fetch git+https://github.com/deevus/zig-squarified.git --save=squarified
```
Import as a dependency in your `build.zig`:
```zig
const lib_squarified = b.dependency("squarified", {});
const module_squarified = lib_squarified.module("squarified");
exe.root_module.addImport("squarified", module_squarified);
```
## Usage
```zig
const squarify = @import("squarified");
const Squarify = squarify.Squarify(f32);
// Create your root node
const root = Node{
.value = 100,
.data = 0,
.children = &[_]Node{
Node{ .value = 50, .data = 1 },
Node{ .value = 30, .data = 2 },
Node{ .value = 20, .data = 3 },
},
};
// Define your container
const container = squarify.Rect{ .x = 0, .y = 0, .width = 800, .height = 600 };
// Squarify
const treemap = try Squarify.init(allocator).squarify(container, root);
defer treemap.deinit();
```
## Contributing
Pull requests and issues are welcome.
Enjoy creating fast squarified treemaps with Zig!