Expand description
§concentric_circles
A Rust library for efficient generation and iteration of concentric circle perimeters using Bresenham’s algorithm.
- No floating-point types are used: all calculations are performed with integer types for maximum performance and precision.
- Provides iterator adapters for coloring, sector extraction, coordinate mapping, and more.
- Suitable for image processing, procedural graphics, and scientific visualization.
- No heap allocations; works in
no_stdenvironments.
§Type Limits
Note:
The maximum allowed radius depends on the types used for the coordinates and the radius.
For example, if you use i8 for points and u8 for the radius, the maximum safe radius is i8::MAX - 1 (i.e., 126).
If you specify a larger radius, an empty iterator is returned—no panic or overflow will occur.
§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.
Structs§
- AddColor
- An iterator adapter that adds a constant color to each
(x, y)coordinate. - AddColor
Radial - An iterator adapter that adds color radially, updating the color when the radius changes.
- Circle
Sector Skip - An iterator adapter that skips points within a specified sector of a circle.
- Circle
Sector Take - An iterator adapter that filters points to form a sector of a circle, taking coordinates within the sector.
- Concentric
Circles - An iterator over concentric circle perimeters using Bresenham’s algorithm.
- Crown
- An iterator adapter that filters points to those within the specified rectangular bounds.
- Crown
With Color - An iterator adapter that filters points within a specified rectangular area.
- MapCircle
Sector - An iterator adapter that updates the color for points within a specified sector of a circle using a closure.
- MapColor
Radial - An iterator adapter that updates the color based on the radius, using a closure.
- Point
With Radius - An iterator adapter that adds a radius to each point of the current circle from
ConcentricCircles. - Scaling
U32 - an iterator for scaling values from type
u32to typeu8. - Step
Rings - An iterator adapter that generates step rings.
- ToImage
Coordinates - An iterator adapter for converting
ConcentricCirclescoordinates to image coordinates. - ToImage
Coordinates With Color - An iterator adapter for converting
ConcentricCirclescoordinates with color to image coordinates.
Traits§
- Concentric
Circles Adapters - A trait that provides iterator adapters for
ConcentricCircles. - Point
With Color - The
PointWithColortrait provides iterator adapters for working with points that have associated color information. - Radii
- The trait provides a method to get the outer and inner radius of a
ConcentricCirclesiterator.
Functions§
- points_
in_ circle - Returns the number of points on the perimeter of a circle for a given radius, or
Noneif the radius is zero. - radius_
from_ circle_ points - Returns the radius of a circle for a given number of points on its perimeter, if possible.
- sum_
circles_ points - Returns the total number of points on the perimeters of circles with radii from
fromtoto(inclusive).