diff options
author | Nicholas Johnson <nick@nicholasjohnson.ch> | 2024-04-22 00:00:00 +0000 |
---|---|---|
committer | Nicholas Johnson <nick@nicholasjohnson.ch> | 2024-04-22 00:00:00 +0000 |
commit | 10f8782d43edbc6e6b1cacedd40c2299528f8d68031133dc6b6721520aac7f4d (patch) | |
tree | be32289e011bc1ec55395d369a97f4bcf683e717a90159af2e24379bd8feadac | |
parent | 4e042126bd9f250fc84a00fa34de90cc48d15ccf9715a72ef465669313331252 (diff) | |
download | hitomezashi-rs-10f8782d43edbc6e6b1cacedd40c2299528f8d68031133dc6b6721520aac7f4d.tar.gz hitomezashi-rs-10f8782d43edbc6e6b1cacedd40c2299528f8d68031133dc6b6721520aac7f4d.zip |
Write library crate documentation
-rw-r--r-- | src/lib.rs | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -16,6 +16,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ +#![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<f64>) { // skew=0.5 generates the most random-looking patterns let skew: f64 = skew.unwrap_or(0.5); |