Skip to content

Commit

Permalink
add ctx.rng_angle
Browse files Browse the repository at this point in the history
  • Loading branch information
afternoon2 committed Jan 6, 2025
1 parent 7f101c2 commit aad904c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion crates/whiskers/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use rand::distributions::uniform::SampleUniform;
use rand::Rng;
use rand_distr::{Distribution, Normal, WeightedAliasIndex};
use std::{fmt::Debug, ops::Range};
use vsvg::Point;
use vsvg::{Angle, Point};

use crate::runner::InspectVariables;

Expand Down Expand Up @@ -111,6 +111,15 @@ impl<'a> Context<'a> {
normal.sample(&mut self.rng)
}

/// Helper function to return random angle
pub fn rng_angle(&mut self) -> Angle {
let deg = self.rng_range(Range {
start: 0.0,
end: 359.0,
});
Angle::from_deg(deg)
}

/// Helper function to display an inspect parameter in the inspect variables UI
pub fn inspect(&mut self, key: impl AsRef<str>, value: impl Debug) {
self.inspect_variables
Expand Down

0 comments on commit aad904c

Please sign in to comment.