# concentric_circles
A Rust crate for generating points on concentric circles.
## Overview
`concentric_circles` provides iterators and adapters for generating coordinates of points distributed along multiple concentric circles. It is designed to be lightweight, efficient, and compatible with `no_std` environments.
## Visual Examples
Below are images demonstrating how `ConcentricCircles` renders. These were generated by example programs in the `examples` folder.
Run them with `cargo run --example example_name`.
|<img title="Basic iterator" src="https://raw.githubusercontent.com/pic16f877ccs/image/refs/heads/pixelization/basic_iter.png" alt="" width="" height="">|<img title="Add color radial" src="https://raw.githubusercontent.com/pic16f877ccs/image/refs/heads/pixelization/add_color_radial.png" alt="" width="" height="">|<img title="Circle sector" src="https://raw.githubusercontent.com/pic16f877ccs/image/refs/heads/pixelization/circle_sector.png" alt="" width="" height="">|<img title="Map circle sector" src="https://raw.githubusercontent.com/pic16f877ccs/image/refs/heads/pixelization/map_circle_sector.png" alt="" width="" height="">|<img title="Map color radial" src="https://raw.githubusercontent.com/pic16f877ccs/image/refs/heads/pixelization/map_color_radial.png" alt="" width="" height="">|<img title="Crown adapter" src="https://raw.githubusercontent.com/pic16f877ccs/image/refs/heads/pixelization/crown_adapter.png" alt="" width="" height="">|<img title="Step rings" src="https://raw.githubusercontent.com/pic16f877ccs/image/refs/heads/pixelization/step_rings.png" alt="" width="" height="">|<img title="To image coordinates" src="https://raw.githubusercontent.com/pic16f877ccs/image/refs/heads/pixelization/to_image_coordinates.png" alt="" width="" height="">|
|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
## Features
- Generate points on multiple circles with customizable radii and point counts
- Iterator-based API for ergonomic and efficient usage
- `no_std` support (no dependency on the Rust standard library)
- Flexible adapters for various point generation strategies
## Usage
Add this to your `Cargo.toml`:
```toml
[dependencies]
concentric_circles = "0.1"
```
### Basic usage:
```rust
use concentric_circles::{ConcentricCirclesAdapters, ConcentricCircles, ScalingU32};
use concentric_circles::sum_circles_points;
let inner_radius = 100;
let outer_radius = 500;
let x_offset = outer_radius as i32;
let y_offset = outer_radius as i32;
let circles_points = sum_circles_points(inner_radius, outer_radius).unwrap();
let mut scaling_iter = ScalingU32::new(circles_points as u32);
let mut value = 0;
let iterator = ConcentricCircles::new(inner_radius, outer_radius)
.to_image_coordinates(x_offset, y_offset)
.map(|(x, y)| {
value = scaling_iter.next().unwrap();
(x, y, [255 - value, 255 - value, 255 - value, 255])
});
```
## License
* MIT license