generated from ElnuDev/rust-project
cargo fmt
This commit is contained in:
parent
3960d6e721
commit
37da862c9f
4 changed files with 19 additions and 13 deletions
|
@ -24,14 +24,21 @@ enum Error {
|
||||||
Template(askama::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 grid = size + padding;
|
||||||
let row_count = ((dimensions.width - padding * 2.0) / grid) as u32;
|
let row_count = ((dimensions.width - padding * 2.0) / grid) as u32;
|
||||||
(0..count)
|
(0..count)
|
||||||
.map(|i| (
|
.map(|i| {
|
||||||
grid * (i % row_count).into() + padding,
|
(
|
||||||
grid * (i / row_count).into() + padding,
|
grid * (i % row_count).into() + padding,
|
||||||
))
|
grid * (i / row_count).into() + padding,
|
||||||
|
)
|
||||||
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
use super::SVGUnit;
|
use super::SVGUnit;
|
||||||
|
use derive_more::From;
|
||||||
|
use lazy_static::lazy_static;
|
||||||
|
use regex::Regex;
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::num::ParseFloatError;
|
use std::num::ParseFloatError;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::{
|
use std::{
|
||||||
fmt::Display,
|
fmt::Display,
|
||||||
ops::{Add, Div, Mul, Sub, Rem},
|
ops::{Add, Div, Mul, Rem, Sub},
|
||||||
};
|
};
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use regex::Regex;
|
|
||||||
use derive_more::From;
|
|
||||||
use strum::ParseError;
|
use strum::ParseError;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
|
|
@ -63,4 +63,4 @@ fn from_str() {
|
||||||
assert_eq!(m_10cm, SVGMeasure::from_str("10cm").unwrap());
|
assert_eq!(m_10cm, SVGMeasure::from_str("10cm").unwrap());
|
||||||
assert_eq!(m_5mm, SVGMeasure::from_str("5mm").unwrap());
|
assert_eq!(m_5mm, SVGMeasure::from_str("5mm").unwrap());
|
||||||
assert_eq!(m_0, SVGMeasure::from_str("0").unwrap());
|
assert_eq!(m_0, SVGMeasure::from_str("0").unwrap());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use strum_macros::{Display, EnumString, IntoStaticStr};
|
use strum_macros::{Display, EnumString, IntoStaticStr};
|
||||||
|
|
||||||
/// https://oreillymedia.github.io/Using_SVG/guide/units.html
|
/// https://oreillymedia.github.io/Using_SVG/guide/units.html
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, EnumString, IntoStaticStr)]
|
||||||
#[derive(Display, EnumString, IntoStaticStr)]
|
|
||||||
pub enum SVGUnit {
|
pub enum SVGUnit {
|
||||||
/// Pixel units, directly equivalent to SVG user units.
|
/// Pixel units, directly equivalent to SVG user units.
|
||||||
#[strum(serialize = "px")]
|
#[strum(serialize = "px")]
|
||||||
|
@ -36,4 +35,4 @@ impl SVGUnit {
|
||||||
Pica => 16.0,
|
Pica => 16.0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue