From 10f8782d43edbc6e6b1cacedd40c2299528f8d68031133dc6b6721520aac7f4d Mon Sep 17 00:00:00 2001 From: Nicholas Johnson Date: Mon, 22 Apr 2024 00:00:00 +0000 Subject: Write library crate documentation --- src/lib.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 9f8643e..fe8383e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,6 +16,10 @@ along with this program. If not, see . */ +#![warn(missing_docs)] + +//! Classic two-colored Hitomezashi stitch pattern generator. + use rand::distributions::{Bernoulli, Distribution}; const TRANSPARENT_SQUARE: char = ' '; @@ -32,6 +36,28 @@ fn print_square(is_opaque: bool) { ); } +/// Prints a two-colored Hitomezashi stitch pattern of the specified dimensions. +/// +/// `skew` is the probability of a row or column beginning with a stitch. Skew values near 0 or 1 +/// generate orderly patterns. Skew values near 0.5 generate chaotic patterns. +/// +/// # Panics +/// +/// This function will panic if any of the following constraints are not met: +/// +/// `width >= 1` +/// +/// `height >= 1` +/// +/// `0 <= skew <= 1` +/// +/// # Examples +/// +/// ``` +/// use hitomezashi_rs; +/// +/// hitomezashi_rs::generate(15, 20, Some(0.7)); +/// ``` pub fn generate(width: usize, height: usize, skew: Option) { // skew=0.5 generates the most random-looking patterns let skew: f64 = skew.unwrap_or(0.5); -- cgit v1.2.3