Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sunsided/rotated-grid
Rotated grid calculations in Rust for CMYK halftone dithering and more
https://github.com/sunsided/rotated-grid
dithering dithering-images halftone image-processing poster print rust
Last synced: 13 days ago
JSON representation
Rotated grid calculations in Rust for CMYK halftone dithering and more
- Host: GitHub
- URL: https://github.com/sunsided/rotated-grid
- Owner: sunsided
- License: eupl-1.2
- Created: 2023-07-01T23:28:42.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-26T11:22:44.000Z (9 months ago)
- Last Synced: 2024-04-27T10:09:40.288Z (7 months ago)
- Topics: dithering, dithering-images, halftone, image-processing, poster, print, rust
- Language: Rust
- Homepage: https://crates.io/crates/rotated-grid
- Size: 127 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Rotated grids in Rust
🎨 _For halftone dithering and more._
---
This crate provides a generator for enumerating grid coordinates at a specified frequency along a rotated grid.
This can come in useful e.g. when you want to create halftone dithering grids for CMYK processing:
See e.g. my [opencv-cartoon-effect](https://github.com/sunsided/opencv-cartoon-effect) repo for an almost-real-world
usage example.## Usage example
```rust
use rotated_grid::{Angle, GridPositionIterator, GridCoordinate};const WIDTH: usize = 16;
const HEIGHT: usize = 10;fn main() {
let halftone_grids = [
("Cyan", 15.0),
("Magenta", 75.0),
("Yellow", 0.0),
("Black", 45.0),
];
for (name, angle) in halftone_grids {
println!("{name} at {angle}°", name = name, angle = angle);
let grid = GridPositionIterator::new(
WIDTH as _,
HEIGHT as _,
7.0,
7.0,
0.0,
0.0,
Angle::::from_degrees(angle),
);
let (_, expected_max) = grid.size_hint();
let mut count = 0;
for GridCoordinate { x, y } in grid {
println!("{x}, {y}", x = x, y = y);
count += 1;
}
assert!(count <= expected_max.unwrap())
}
}
```You can run the example application using
```shell
cargo run --package cmyk
```