This repository has no description
1#[cfg(feature = "web")]
2use wasm_bindgen::prelude::*;
3
4use slug::slugify;
5
6#[cfg_attr(feature = "web", wasm_bindgen)]
7#[derive(Debug, Clone, Copy, PartialEq)]
8pub enum TransformationType {
9 Scale,
10 Rotate,
11 Skew,
12 Matrix,
13}
14
15#[derive(Debug, Clone, Copy, PartialEq)]
16pub enum Transformation {
17 Scale(f32, f32),
18 Rotate(f32),
19 Skew(f32, f32),
20 Matrix(f32, f32, f32, f32, f32, f32),
21}
22
23impl Transformation {
24 pub fn name(&self) -> String {
25 match self {
26 Transformation::Matrix(..) => "matrix",
27 Transformation::Rotate(..) => "rotate",
28 Transformation::Scale(..) => "scale",
29 Transformation::Skew(..) => "skew",
30 }
31 .to_owned()
32 }
33
34 #[allow(non_snake_case)]
35 pub fn ScaleUniform(scale: f32) -> Self {
36 Transformation::Scale(scale, scale)
37 }
38
39 pub fn id(&self) -> String {
40 slugify(format!("{:?}", self))
41 }
42}