swf: Derive Hash for Gradient and associated types

This commit is contained in:
Nathan Adams 2024-01-24 20:34:18 +01:00
parent 2d42abcb70
commit 6dac4958fb
5 changed files with 8 additions and 8 deletions

View File

@ -762,7 +762,7 @@ pub enum FillStyle {
},
}
#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct Gradient {
pub matrix: Matrix,
pub spread: GradientSpread,
@ -770,7 +770,7 @@ pub struct Gradient {
pub records: Vec<GradientRecord>,
}
#[derive(Clone, Copy, Debug, Eq, FromPrimitive, PartialEq, Enum)]
#[derive(Clone, Copy, Debug, Eq, FromPrimitive, PartialEq, Enum, Hash)]
pub enum GradientSpread {
Pad = 0,
Reflect = 1,
@ -788,7 +788,7 @@ impl GradientSpread {
}
}
#[derive(Clone, Copy, Debug, Eq, FromPrimitive, PartialEq)]
#[derive(Clone, Copy, Debug, Eq, FromPrimitive, PartialEq, Hash)]
pub enum GradientInterpolation {
Rgb = 0,
LinearRgb = 1,
@ -805,7 +805,7 @@ impl GradientInterpolation {
}
}
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Hash)]
pub struct GradientRecord {
pub ratio: u8,
pub color: Color,

View File

@ -1,7 +1,7 @@
/// An RGBA (red, green, blue, alpha) color.
///
/// All components are stored as [`u8`] and have a color range of 0-255.
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Hash)]
pub struct Color {
/// The red component value.
pub r: u8,

View File

@ -19,7 +19,7 @@ macro_rules! define_fixed {
into_float($($into_type:path),*)
) => {
/// A signed fixed-point value with $frac_bits bits.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct $type_name($underlying_type);
/// A signed fixed-point type.

View File

@ -15,7 +15,7 @@ use std::ops;
/// This means that objects in Flash can only move in units of twips, or 1/20 pixels.
///
/// [SWF19 pp.22-24](https://web.archive.org/web/20220205011833if_/https://www.adobe.com/content/dam/acom/en/devnet/pdf/swf-file-format-spec.pdf#page=22)
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub struct Matrix {
/// The matrix element at `[0, 0]`. Labeled `ScaleX` in SWF19.
pub a: Fixed16,

View File

@ -15,7 +15,7 @@
/// 40,000 twips, or `4*10^4` . If you then have two such numbers,
/// multiplying them as part of calculations yields `16*10^8`, which is
/// relatively close to the upper limit of `i32` at about `2*10^9`.
#[derive(Clone, Copy, Debug, Default, Eq, Ord, PartialEq, PartialOrd)]
#[derive(Clone, Copy, Debug, Default, Eq, Ord, PartialEq, PartialOrd, Hash)]
pub struct Twips(i32);
impl Twips {