Crate concentric_circles

Crate concentric_circles 

Source
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_std environments.

§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.

The iterator
basic_iterator
The adapter
add_color_radial
The adapter
circle_sector
The adapter
map_circle_sector
The adapter
map_color_radial
The adapter
crown
The adapter
step_rings
The adapter
to_image_coordinates

Structs§

AddColor
An iterator adapter that adds a constant color to each (x, y) coordinate.
AddColorRadial
An iterator adapter that adds color radially, updating the color when the radius changes.
CircleSectorSkip
An iterator adapter that skips points within a specified sector of a circle.
CircleSectorTake
An iterator adapter that filters points to form a sector of a circle, taking coordinates within the sector.
ConcentricCircles
An iterator over concentric circle perimeters using Bresenham’s algorithm.
Crown
An iterator adapter that filters points to those within the specified rectangular bounds.
CrownWithColor
An iterator adapter that filters points within a specified rectangular area.
MapCircleSector
An iterator adapter that updates the color for points within a specified sector of a circle using a closure.
MapColorRadial
An iterator adapter that updates the color based on the radius, using a closure.
PointWithRadius
An iterator adapter that adds a radius to each point of the current circle from ConcentricCircles.
ScalingU32
an iterator for scaling values from type u32 to type u8.
StepRings
An iterator adapter that generates step rings.
ToImageCoordinates
An iterator adapter for converting ConcentricCircles coordinates to image coordinates.
ToImageCoordinatesWithColor
An iterator adapter for converting ConcentricCircles coordinates with color to image coordinates.

Traits§

ConcentricCirclesAdapters
A trait that provides iterator adapters for ConcentricCircles.
PointWithColor
The PointWithColor trait 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 ConcentricCircles iterator.

Functions§

points_in_circle
Returns the number of points on the perimeter of a circle for a given radius, or None if 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 from to to (inclusive).