pub enum Transform {
    Id,
    Rotate90,
    Rotate180,
    Rotate270,
    FlipRow,
    FlipCol,
    FlipDiag,
    FlipAntidiag,
}
Expand description

Transformations (rotations and reflections) after the last generation in a period.

After the last generation in a period, the pattern will return to the first generation, applying this transformation first, and then the translation defined by dx and dy.

8 different values correspond to 8 elements of the dihedral group D8.

Id is the identity transformation.

R means rotations around the center of the world. The number after it is the counterclockwise rotation angle in degrees.

F means reflections (flips). The symbol after it is the axis of reflection.

Some of the transformations are only valid when the world is square. and some are only valid when the world has no diagonal width.

Variants§

§

Id

Id.

Identity transformation.

§

Rotate90

R90.

90° rotation counterclockwise.

Requires the world to be square and have no diagonal width.

§

Rotate180

R180.

180° rotation counterclockwise.

§

Rotate270

R270.

270° rotation counterclockwise.

Requires the world to be square and have no diagonal width.

§

FlipRow

F-.

Reflection across the middle row.

Requires the world to have no diagonal width.

§

FlipCol

F|.

Reflection across the middle column.

Requires the world to have no diagonal width.

§

FlipDiag

F\.

Reflection across the diagonal.

Requires the world to be square.

§

FlipAntidiag

F/.

Reflection across the antidiagonal.

Requires the world to be square.

Implementations§

source§

impl Transform

source

pub const ALL: [Self; 8] = _

source

pub const fn require_square_world(self) -> bool

Whether this transformation requires the world to be square.

Returns true for R90, R270, F\ and F/.

source

pub const fn require_no_diagonal_width(self) -> bool

Whether this transformation requires the world to have no diagonal width.

Returns true for R90, R270, F- and F|.

source

pub const fn order(self) -> u8

The order of this transformation in the symmetry group.

source

pub const fn inverse(self) -> Self

The inverse of this transformation.

source

pub const fn is_in(self, sym: Symmetry) -> bool

Whether the transformation is a member of the symmetry group, i.e., whether patterns with this symmetry are invariant under this transformation.

source

pub const fn act_on(self, coord: Coord, width: i32, height: i32) -> Coord

Apply the transformation on a coordinate.

Trait Implementations§

source§

impl Clone for Transform

source§

fn clone(&self) -> Transform

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Transform

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Transform

source§

fn default() -> Transform

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Transform

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Transform

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl FromStr for Transform

§

type Err = String

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for Transform

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Mul for Transform

§

type Output = Transform

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Self) -> Self

Performs the * operation. Read more
source§

impl PartialEq for Transform

source§

fn eq(&self, other: &Transform) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Transform

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Copy for Transform

source§

impl Eq for Transform

source§

impl StructuralEq for Transform

source§

impl StructuralPartialEq for Transform

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,