aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs26
1 files changed, 26 insertions, 0 deletions
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 <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);