Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nuiipointerexception/farbe
A optimized color module and library for high performance applications.
https://github.com/nuiipointerexception/farbe
cpp rust zig zig-library zig-package
Last synced: 6 days ago
JSON representation
A optimized color module and library for high performance applications.
- Host: GitHub
- URL: https://github.com/nuiipointerexception/farbe
- Owner: nuIIpointerexception
- License: gpl-3.0
- Created: 2024-12-09T22:37:28.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2024-12-10T22:00:47.000Z (2 months ago)
- Last Synced: 2025-01-30T09:35:08.054Z (11 days ago)
- Topics: cpp, rust, zig, zig-library, zig-package
- Language: Zig
- Homepage:
- Size: 54.7 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Farbe
A optimized color module and library for high performance applications.
## Features
Various different color formats are supported:
- RGBA
- HSLA
- HSValso we can:
- Blending between colors
- Hexadecimal color parsing
- Comptime checks (Zig only)## Build
### Zig
```sh
zig build [-Dtype=(static|dynamic] [-Dbinding=(c|cpp|zig]
```Defaults:
- `type` = `static`
- `binding` = `zig`### Examples
```sh
// zig
zig build run -Dname=ansi// c
zig build run -Dname=c// cpp
zig build run -Dname=cpp
```## Usage
### Zig
```zig
const farbe = @import("farbe");// Create a new RGBA color
const red = farbe.rgba(0xFF0000FF);// Blend two colors together
const blue = farbe.rgba(0x0000FFFF);
const purple = red.blend(blue);// Convert a color to a u32 value
const u32_value = red.toU32();// Create a new HSLA color
const hsla = farbe.hsla(0.0, 1.0, 0.5, 1.0);// Convert a color to an HSLA color
const hsla = red.toHsla();// Blend two colors together
const blue = farbe.hsla(240.0 / 360.0, 1.0, 0.5, 1.0);
const purple = red.blend(blue);// Convert a color to an RGBA color
const rgba = hsla.toRgba();// Create a new HSLA color with opacity adjusted
const faded = hsla.opacity(0.5);// Create a new HSLA color with opacity adjusted
const gray = hsla.grayscale();// Fade out a color
hsla.fadeOut(0.5);
```### C / C++
Use the [farbe.h](include/c/farbe.h) header file provided in the include directory.
```c++
#include "farbe.h"// C
farbe_hsla_t blue = farbe_hsla_create(240.0f/360.0f, 1.0f, 0.5f, 1.0f);// C++
farbe::Hsla blue = farbe::Hsla(240.0f/360.0f, 1.0f, 0.5f, 1.0f);
```### Rust
Use the [farbe-rs](include/rust/src/lib.rs) crate provided in the include directory.
```rust
use farbe_rs::{Hsla, Rgba};let blue = Hsla::new(240.0f/360.0f, 1.0f, 0.5f, 1.0f);
```## License
This project is licensed under the GLPLv3 license - see the [LICENSE](LICENSE) file for details.