@ -24,14 +24,21 @@ enum Error {
Template(askama::Error),
}
fn positions(size: SVGMeasure, padding: SVGMeasure, dimensions: &DocumentDimensions, count: u32) -> Vec<(SVGMeasure, SVGMeasure)> {
fn positions(
size: SVGMeasure,
padding: SVGMeasure,
dimensions: &DocumentDimensions,
count: u32,
) -> Vec<(SVGMeasure, SVGMeasure)> {
let grid = size + padding;
let row_count = ((dimensions.width - padding * 2.0) / grid) as u32;
(0..count)
.map(|i| (
grid * (i % row_count).into() + padding,
grid * (i / row_count).into() + padding,
))
.map(|i| {
(
)
})
.collect()
@ -1,15 +1,15 @@
use super::SVGUnit;
use derive_more::From;
use lazy_static::lazy_static;
use regex::Regex;
use std::cmp::Ordering;
use std::fmt;
use std::num::ParseFloatError;
use std::str::FromStr;
use std::{
fmt::Display,
ops::{Add, Div, Mul, Sub, Rem},
ops::{Add, Div, Mul, Rem, Sub},
};
use strum::ParseError;
#[derive(Debug, Clone, Copy)]
@ -63,4 +63,4 @@ fn from_str() {
assert_eq!(m_10cm, SVGMeasure::from_str("10cm").unwrap());
assert_eq!(m_5mm, SVGMeasure::from_str("5mm").unwrap());
assert_eq!(m_0, SVGMeasure::from_str("0").unwrap());
@ -1,8 +1,7 @@
use strum_macros::{Display, EnumString, IntoStaticStr};
/// https://oreillymedia.github.io/Using_SVG/guide/units.html
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[derive(Display, EnumString, IntoStaticStr)]
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, EnumString, IntoStaticStr)]
pub enum SVGUnit {
/// Pixel units, directly equivalent to SVG user units.
#[strum(serialize = "px")]
@ -36,4 +35,4 @@ impl SVGUnit {
Pica => 16.0,