use avm1; use std::collections::HashSet; #[derive(Debug, PartialEq)] pub struct Swf { pub version: u8, pub compression: Compression, pub stage_size: Rectangle, pub frame_rate: f32, pub num_frames: u16, pub tags: Vec, } /// Defines the compression type used in an SWF. #[derive(Debug, PartialEq, Eq)] pub enum Compression { None, Zlib, Lzma, } #[derive(Debug, PartialEq, Clone)] pub struct Rectangle { pub x_min: f32, pub x_max: f32, pub y_min: f32, pub y_max: f32, } #[derive(Debug, PartialEq, Clone)] pub struct Color { pub r: u8, pub g: u8, pub b: u8, pub a: u8, } #[derive(Debug, PartialEq, Clone)] pub struct ColorTransform { pub r_multiply: f32, pub g_multiply: f32, pub b_multiply: f32, pub a_multiply: f32, pub r_add: i16, pub g_add: i16, pub b_add: i16, pub a_add: i16, } impl ColorTransform { pub fn new() -> ColorTransform { ColorTransform { r_multiply: 1f32, g_multiply: 1f32, b_multiply: 1f32, a_multiply: 1f32, r_add: 0, g_add: 0, b_add: 0, a_add: 0, } } } #[derive(Debug, PartialEq, Clone)] pub struct Matrix { pub translate_x: f32, pub translate_y: f32, pub scale_x: f32, pub scale_y: f32, pub rotate_skew_0: f32, pub rotate_skew_1: f32, } impl Matrix { pub fn new() -> Matrix { Matrix { translate_x: 0f32, translate_y: 0f32, scale_x: 1f32, scale_y: 1f32, rotate_skew_0: 0f32, rotate_skew_1: 0f32, } } } #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum Language { Unknown, Latin, Japanese, Korean, SimplifiedChinese, TraditionalChinese, } #[derive(Debug, PartialEq)] pub struct FileAttributes { pub use_direct_blit: bool, pub use_gpu: bool, pub has_metadata: bool, pub is_action_script_3: bool, pub use_network_sandbox: bool, } #[derive(Debug, PartialEq)] pub struct FrameLabel { pub frame_num: u32, pub label: String, } pub type Depth = i16; pub type CharacterId = u16; pub type Twips = i32; #[derive(Debug, PartialEq)] pub struct PlaceObject { pub version: u8, pub action: PlaceObjectAction, pub depth: Depth, pub matrix: Option, pub color_transform: Option, pub ratio: Option, pub name: Option, pub clip_depth: Option, pub class_name: Option, pub filters: Vec, pub background_color: Option, pub blend_mode: BlendMode, pub clip_actions: Vec, pub is_image: bool, pub is_bitmap_cached: bool, pub is_visible: bool, pub amf_data: Option>, } #[derive(Debug, PartialEq, Clone, Copy)] pub enum PlaceObjectAction { Place(CharacterId), Modify, Replace(CharacterId), } #[derive(Debug, PartialEq, Clone)] pub enum Filter { DropShadowFilter(Box), BlurFilter(Box), GlowFilter(Box), BevelFilter(Box), GradientGlowFilter(Box), ConvolutionFilter(Box), ColorMatrixFilter(Box), GradientBevelFilter(Box), } #[derive(Debug, PartialEq, Clone)] pub struct DropShadowFilter { pub color: Color, pub blur_x: f64, pub blur_y: f64, pub angle: f64, pub distance: f64, pub strength: f32, pub is_inner: bool, pub is_knockout: bool, pub num_passes: u8, } #[derive(Debug, PartialEq, Clone)] pub struct BlurFilter { pub blur_x: f64, pub blur_y: f64, pub num_passes: u8, } #[derive(Debug, PartialEq, Clone)] pub struct GlowFilter { pub color: Color, pub blur_x: f64, pub blur_y: f64, pub strength: f32, pub is_inner: bool, pub is_knockout: bool, pub num_passes: u8, } #[derive(Debug, PartialEq, Clone)] pub struct BevelFilter { pub shadow_color: Color, pub highlight_color: Color, pub blur_x: f64, pub blur_y: f64, pub angle: f64, pub distance: f64, pub strength: f32, pub is_inner: bool, pub is_knockout: bool, pub is_on_top: bool, pub num_passes: u8, } #[derive(Debug, PartialEq, Clone)] pub struct GradientGlowFilter { pub colors: Vec, pub blur_x: f64, pub blur_y: f64, pub angle: f64, pub distance: f64, pub strength: f32, pub is_inner: bool, pub is_knockout: bool, pub is_on_top: bool, pub num_passes: u8, } #[derive(Debug, PartialEq, Clone)] pub struct ConvolutionFilter { pub num_matrix_rows: u8, pub num_matrix_cols: u8, pub matrix: Vec, pub divisor: f64, pub bias: f64, pub default_color: Color, pub is_clamped: bool, pub is_preserve_alpha: bool, } #[derive(Debug, PartialEq, Clone)] pub struct ColorMatrixFilter { pub matrix: [f64; 20], } #[derive(Debug, PartialEq, Clone)] pub struct GradientBevelFilter { pub colors: Vec, pub blur_x: f64, pub blur_y: f64, pub angle: f64, pub distance: f64, pub strength: f32, pub is_inner: bool, pub is_knockout: bool, pub is_on_top: bool, pub num_passes: u8, } #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum BlendMode { Normal, Layer, Multiply, Screen, Lighten, Darken, Difference, Add, Subtract, Invert, Alpha, Erase, Overlay, HardLight, } #[derive(Debug, PartialEq, Eq, Clone)] pub struct ClipAction { pub events: HashSet, pub key_code: Option, pub action_data: Vec, } #[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)] pub enum ClipEvent { KeyUp, KeyDown, MouseUp, MouseDown, MouseMove, Unload, EnterFrame, Load, DragOver, RollOut, RollOver, ReleaseOutside, Release, Press, Initialize, Data, Construct, KeyPress, DragOut, } pub type ClipEventFlags = HashSet; #[derive(Debug, PartialEq)] pub enum Tag { ExportAssets(Vec), ScriptLimits { max_recursion_depth: u16, timeout_in_seconds: u16, }, ShowFrame, Protect(Option), CsmTextSettings(CsmTextSettings), DefineBinaryData { id: CharacterId, data: Vec }, DefineBits { id: CharacterId, jpeg_data: Vec }, DefineBitsJpeg2 { id: CharacterId, jpeg_data: Vec }, DefineBitsJpeg3(DefineBitsJpeg3), DefineBitsLossless(DefineBitsLossless), DefineButton(Box