makepad_path/
path_command.rs

1use makepad_geometry::{Point, Transform, Transformation};
2
3/// A command in a path
4#[derive(Clone, Copy, Debug, PartialEq)]
5pub enum PathCommand {
6    MoveTo(Point),
7    LineTo(Point),
8    QuadraticTo(Point, Point),
9    Close,
10}
11
12impl Transform for PathCommand {
13    fn transform<T>(self, t: &T) -> PathCommand
14    where
15        T: Transformation,
16    {
17        match self {
18            PathCommand::MoveTo(p) => PathCommand::MoveTo(p.transform(t)),
19            PathCommand::LineTo(p) => PathCommand::LineTo(p.transform(t)),
20            PathCommand::QuadraticTo(p1, p) => {
21                PathCommand::QuadraticTo(p1.transform(t), p.transform(t))
22            }
23            PathCommand::Close => PathCommand::Close,
24        }
25    }
26
27    fn transform_mut<T>(&mut self, t: &T)
28    where
29        T: Transformation,
30    {
31        *self = self.transform(t);
32    }
33}