Skip to main content

numeric_ticks

Function numeric_ticks 

Source
pub fn numeric_ticks(
    min: Option<FloatType>,
    max: Option<FloatType>,
) -> Result<Vec<i64>>
Expand description

About ten ticks at a power of ten apart, covering min to max: music21’s Axis.ticks. A missing bound is 0 or 10.

use music21::graph::axis::numeric_ticks;

assert_eq!(numeric_ticks(Some(1.0), Some(9.0))?, (0..=10).collect::<Vec<_>>());
assert_eq!(numeric_ticks(Some(7.0), Some(80.0))?[..3], [0, 10, 20]);
assert_eq!(numeric_ticks(Some(712.0), Some(2213.0))?[0], 600);

§Errors

A maximum below the minimum, or a span under a tenth, which have no whole step to count with.