├── .editorconfig ├── .gitattributes ├── .gitignore ├── .gitmodules ├── .travis.yml ├── CHANGELOG.md ├── LICENSE-APACHE.md ├── LICENSE-MIT.md ├── README.md ├── docs ├── basic-data-types.md ├── cap-style.md ├── color-space.md ├── color-stop.md ├── color-transform-with-alpha.md ├── color-transform.md ├── compression-method.md ├── fill-style.md ├── fill-styles │ ├── bitmap.md │ ├── focal-gradient.md │ ├── linear-gradient.md │ ├── morph-bitmap.md │ ├── morph-focal-gradient.md │ ├── morph-linear-gradient.md │ ├── morph-radial-gradient.md │ ├── morph-solid.md │ ├── radial-gradient.md │ └── solid.md ├── filter.md ├── filters │ ├── bevel.md │ ├── blur.md │ ├── color-matrix.md │ ├── convolution.md │ ├── drop-shadow.md │ ├── glow.md │ ├── gradient-bevel.md │ └── gradient-glow.md ├── glyph.md ├── gradient-spread.md ├── gradient.md ├── header.md ├── join-style.md ├── join-styles │ ├── bevel.md │ ├── miter.md │ └── round.md ├── language-code.md ├── line-style.md ├── matrix.md ├── morph-fill-style.md ├── morph-shape-record.md ├── morph-shape.md ├── movie.md ├── named-id.md ├── primitives.md ├── radial-gradient.md ├── s-rgb8.md ├── shape-record.md ├── shape-records │ ├── edge.md │ ├── morph-edge.md │ ├── morph-style-change.md │ └── style-change.md ├── shape.md ├── shapes │ ├── clip-action.md │ └── clip-event-flags.md ├── sound │ ├── audio-coding-format.md │ ├── sound-rate.md │ ├── sound-size.md │ └── sound-type.md ├── straight-s-rgba8.md ├── swf-signature.md ├── tag-header.md ├── tag.md ├── tags │ ├── csm-text-settings.md │ ├── define-binary-data.md │ ├── define-bitmap.md │ ├── define-cff-font.md │ ├── define-dynamic-text.md │ ├── define-font-align-zones.md │ ├── define-font-info.md │ ├── define-font-name.md │ ├── define-font.md │ ├── define-jpeg-tables.md │ ├── define-morph-shape.md │ ├── define-partial-font.md │ ├── define-shape.md │ ├── define-sound.md │ ├── define-sprite.md │ ├── define-text.md │ ├── do-abc.md │ ├── do-action.md │ ├── do-init-action.md │ ├── enable-debugger.md │ ├── export-assets.md │ ├── file-attributes.md │ ├── import-assets.md │ ├── metadata.md │ ├── place-object.md │ ├── remove-object.md │ ├── script-limits.md │ ├── show-frame.md │ ├── sound-stream-block.md │ ├── sound-stream-head.md │ ├── start-sound.md │ ├── start-sound2.md │ ├── symbol-class.md │ └── telemetry.md ├── text │ ├── csm-table-hint.md │ ├── font-alignment-zone-data.md │ ├── font-alignment-zone.md │ ├── font-layout.md │ ├── glyph-entry.md │ ├── grid-fitting.md │ ├── kerning-record.md │ ├── text-alignment.md │ ├── text-record.md │ └── text-renderer.md └── vector-2d.md ├── rs ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE-APACHE.md ├── LICENSE-MIT.md ├── README.md ├── bin │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── clippy.toml ├── rustfmt.toml └── src │ ├── basic_types.rs │ ├── button.rs │ ├── control.rs │ ├── fill_styles.rs │ ├── filters.rs │ ├── float_is.rs │ ├── gradient.rs │ ├── image.rs │ ├── join_styles.rs │ ├── lib.rs │ ├── movie.rs │ ├── serde_buffer.rs │ ├── shape.rs │ ├── sound.rs │ ├── tags.rs │ ├── text.rs │ └── video.rs ├── ts ├── .eslintrc.json ├── .gitignore ├── .yarn │ └── releases │ │ └── yarn-4.0.0-rc.4.cjs ├── .yarnrc.yml ├── LICENSE-APACHE.md ├── LICENSE-MIT.md ├── README.md ├── package.json ├── src │ ├── lib │ │ ├── blend-mode.mts │ │ ├── button │ │ │ ├── button-cond-action.mts │ │ │ ├── button-cond.mts │ │ │ ├── button-record.mts │ │ │ └── button-sound.mts │ │ ├── cap-style.mts │ │ ├── clip-action.mts │ │ ├── clip-event-flags.mts │ │ ├── color-space.mts │ │ ├── color-stop.mts │ │ ├── color-transform-with-alpha.mts │ │ ├── color-transform.mts │ │ ├── compression-method.mts │ │ ├── control │ │ │ ├── abc-header.mts │ │ │ ├── label.mts │ │ │ ├── protect.mts │ │ │ ├── scene.mts │ │ │ ├── script-limits.mts │ │ │ └── symbol-class.mts │ │ ├── fill-style.mts │ │ ├── fill-styles │ │ │ ├── _type.mts │ │ │ ├── bitmap.mts │ │ │ ├── focal-gradient.mts │ │ │ ├── index.mts │ │ │ ├── linear-gradient.mts │ │ │ ├── morph-bitmap.mts │ │ │ ├── morph-focal-gradient.mts │ │ │ ├── morph-linear-gradient.mts │ │ │ ├── morph-radial-gradient.mts │ │ │ ├── morph-solid.mts │ │ │ ├── radial-gradient.mts │ │ │ └── solid.mts │ │ ├── filter.mts │ │ ├── filters │ │ │ ├── _type.mts │ │ │ ├── bevel.mts │ │ │ ├── blur.mts │ │ │ ├── color-matrix.mts │ │ │ ├── convolution.mts │ │ │ ├── drop-shadow.mts │ │ │ ├── glow.mts │ │ │ ├── gradient-bevel.mts │ │ │ ├── gradient-glow.mts │ │ │ └── index.mts │ │ ├── fixed-point │ │ │ ├── fixed-point.mts │ │ │ ├── sfixed16p16.mts │ │ │ ├── sfixed8p8.mts │ │ │ ├── ufixed16p16.mts │ │ │ └── ufixed8p8.mts │ │ ├── glyph.mts │ │ ├── gradient-spread.mts │ │ ├── gradient.mts │ │ ├── header.mts │ │ ├── image-type.mts │ │ ├── index.mts │ │ ├── join-style.mts │ │ ├── join-styles │ │ │ ├── _type.mts │ │ │ ├── bevel.mts │ │ │ ├── index.mts │ │ │ ├── miter.mts │ │ │ └── round.mts │ │ ├── language-code.mts │ │ ├── line-style.mts │ │ ├── matrix.mts │ │ ├── morph-color-stop.mts │ │ ├── morph-fill-style.mts │ │ ├── morph-gradient.mts │ │ ├── morph-line-style.mts │ │ ├── morph-shape-record.mts │ │ ├── morph-shape-styles.mts │ │ ├── morph-shape.mts │ │ ├── movie.mts │ │ ├── named-id.mts │ │ ├── rect.mts │ │ ├── s-rgb8.mts │ │ ├── shape-record.mts │ │ ├── shape-records │ │ │ ├── _type.mts │ │ │ ├── edge.mts │ │ │ ├── index.mts │ │ │ ├── morph-edge.mts │ │ │ ├── morph-style-change.mts │ │ │ └── style-change.mts │ │ ├── shape-styles.mts │ │ ├── shape.mts │ │ ├── sound │ │ │ ├── adpcm-mono-packet.mts │ │ │ ├── adpcm-sound-data.mts │ │ │ ├── adpcm-stereo-packet.mts │ │ │ ├── audio-coding-format.mts │ │ │ ├── mp3-bit-rate.mts │ │ │ ├── mp3-channel-mode.mts │ │ │ ├── mp3-frame.mts │ │ │ ├── mp3-layer.mts │ │ │ ├── mp3-sound-data.mts │ │ │ ├── mp3-stream-sound-data.mts │ │ │ ├── mpeg-version.mts │ │ │ ├── sound-envelope.mts │ │ │ ├── sound-info.mts │ │ │ ├── sound-rate.mts │ │ │ ├── sound-size.mts │ │ │ └── sound-type.mts │ │ ├── sprite-tag.mts │ │ ├── straight-s-rgba8.mts │ │ ├── swf-signature.mts │ │ ├── tag-header.mts │ │ ├── tag.mts │ │ ├── tags │ │ │ ├── _tag.mts │ │ │ ├── _type.mts │ │ │ ├── csm-text-settings.mts │ │ │ ├── define-binary-data.mts │ │ │ ├── define-bitmap.mts │ │ │ ├── define-button-color-transform.mts │ │ │ ├── define-button-sound.mts │ │ │ ├── define-button.mts │ │ │ ├── define-cff-font.mts │ │ │ ├── define-dynamic-text.mts │ │ │ ├── define-font-align-zones.mts │ │ │ ├── define-font-info.mts │ │ │ ├── define-font-name.mts │ │ │ ├── define-font.mts │ │ │ ├── define-glyph-font.mts │ │ │ ├── define-jpeg-tables.mts │ │ │ ├── define-morph-shape.mts │ │ │ ├── define-scaling-grid.mts │ │ │ ├── define-scene-and-frame-label-data.mts │ │ │ ├── define-shape.mts │ │ │ ├── define-sound.mts │ │ │ ├── define-sprite.mts │ │ │ ├── define-text.mts │ │ │ ├── define-video-stream.mts │ │ │ ├── do-abc.mts │ │ │ ├── do-action.mts │ │ │ ├── do-init-action.mts │ │ │ ├── enable-debugger.mts │ │ │ ├── enable-postscript.mts │ │ │ ├── export-assets.mts │ │ │ ├── file-attributes.mts │ │ │ ├── frame-label.mts │ │ │ ├── import-assets.mts │ │ │ ├── index.mts │ │ │ ├── metadata.mts │ │ │ ├── place-object.mts │ │ │ ├── protect.mts │ │ │ ├── raw-body.mts │ │ │ ├── raw.mts │ │ │ ├── remove-object.mts │ │ │ ├── script-limits.mts │ │ │ ├── set-background-color.mts │ │ │ ├── set-tab-index.mts │ │ │ ├── show-frame.mts │ │ │ ├── sound-stream-block.mts │ │ │ ├── sound-stream-head.mts │ │ │ ├── start-sound.mts │ │ │ ├── start-sound2.mts │ │ │ ├── symbol-class.mts │ │ │ ├── telemetry.mts │ │ │ └── video-frame.mts │ │ ├── text │ │ │ ├── csm-table-hint.mts │ │ │ ├── em-square-size.mts │ │ │ ├── font-alignment-zone-data.mts │ │ │ ├── font-alignment-zone.mts │ │ │ ├── font-layout.mts │ │ │ ├── glyph-entry.mts │ │ │ ├── grid-fitting.mts │ │ │ ├── index.mts │ │ │ ├── kerning-record.mts │ │ │ ├── text-alignment.mts │ │ │ ├── text-record.mts │ │ │ └── text-renderer.mts │ │ ├── tsconfig.json │ │ ├── vector-2d.mts │ │ └── video │ │ │ ├── h263-block-data.mts │ │ │ ├── h263-macro-block.mts │ │ │ ├── h263-video-packet.mts │ │ │ ├── screen-image-block.mts │ │ │ ├── screen-video-packet.mts │ │ │ ├── screen2-color-depth.mts │ │ │ ├── screen2-image-block-diff-position.mts │ │ │ ├── screen2-image-block-prime-position.mts │ │ │ ├── screen2-image-block.mts │ │ │ ├── screen2-image-format.mts │ │ │ ├── screen2-video-packet.mts │ │ │ ├── video-codec.mts │ │ │ ├── video-deblocking.mts │ │ │ ├── vp6-flv-alpha-video-packet.mts │ │ │ ├── vp6-flv-video-packet.mts │ │ │ ├── vp6-swf-alpha-video-packet.mts │ │ │ └── vp6-swf-video-packet.mts │ └── test │ │ ├── meta.mts │ │ ├── movie.spec.mts │ │ ├── tags.spec.mts │ │ ├── test-resources.mts │ │ ├── tsconfig.json │ │ ├── utils.mts │ │ └── various.spec.mts ├── tsconfig.json └── yarn.lock └── update-submodules.sh /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | charset = utf-8 7 | indent_style = space 8 | indent_size = 2 9 | end_of_line = lf 10 | indent_brace_style = K&R 11 | insert_final_newline = true 12 | trim_trailing_whitespace = true 13 | max_line_length = 120 14 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Enforce `lf` for text files (even on Windows) 2 | * text=auto eol=lf 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Editor # 3 | ############################################################################### 4 | # JetBrains (Webstorm, IntelliJ IDEA, ...) 5 | .idea/ 6 | *.iml 7 | 8 | ############################################################################### 9 | # Temporary files # 10 | ############################################################################### 11 | *.log 12 | *.tmp 13 | tmp/ 14 | logs/ 15 | 16 | ############################################################################### 17 | # Other # 18 | ############################################################################### 19 | # Runtime data 20 | pids 21 | *.pid 22 | *.seed 23 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "tests/movies"] 2 | path = tests/movies 3 | url = https://github.com/open-flash-db/movies.git 4 | [submodule "tests/tags"] 5 | path = tests/tags 6 | url = https://github.com/open-flash-db/tags.git 7 | [submodule "tests/various"] 8 | path = tests/various 9 | url = https://github.com/open-flash-db/various.git 10 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | matrix: 2 | include: 3 | - language: node_js 4 | os: 5 | - linux 6 | #- osx 7 | #- windows 8 | node_js: 9 | - 14 10 | before_script: 11 | - cd ts 12 | script: 13 | - yarn install 14 | - yarn test 15 | 16 | - language: rust 17 | os: 18 | - linux 19 | # rust: 20 | # - stable 21 | before_script: 22 | - cd rs 23 | - rustup component add rustfmt 24 | script: 25 | - cargo fmt --all -- --check 26 | - cargo build 27 | - cargo test 28 | - cargo test --no-default-features 29 | 30 | notifications: 31 | email: false 32 | -------------------------------------------------------------------------------- /LICENSE-MIT.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright © 2017-2019 Charles Samborski 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /docs/basic-data-types.md: -------------------------------------------------------------------------------- 1 | # Basic data types 2 | 3 | TODO: Remove endianness (irrelevant in the AST) 4 | 5 | ## Int8 6 | 7 | ## Int16Le 8 | 9 | ## Int32Le 10 | 11 | ## Uint8 12 | 13 | ## Uint16Le 14 | 15 | ## Uint32Le 16 | 17 | ## EncodedUint32Le 18 | 19 | ## CString 20 | 21 | ## Fixed8P8Le 22 | 23 | ## Fixed16P16Le 24 | 25 | ## Ufixed8P8Le 26 | 27 | ## Ufixed16P16Le 28 | 29 | ## Rect 30 | 31 | ## Rgb 32 | 33 | ## Rgba 34 | -------------------------------------------------------------------------------- /docs/cap-style.md: -------------------------------------------------------------------------------- 1 | # CapStyle 2 | 3 | ``` 4 | enum CapStyle { 5 | None; 6 | Round; 7 | Square; 8 | } 9 | ``` 10 | -------------------------------------------------------------------------------- /docs/color-space.md: -------------------------------------------------------------------------------- 1 | # ColorSpace 2 | 3 | Represents the color space used for gradient interpolation. 4 | 5 | The spec calls it `InterpolationMode`. 6 | 7 | See: https://www.w3.org/TR/SVG/painting.html#ColorInterpolationProperties 8 | 9 | ``` 10 | enum ColorSpace { 11 | SRgb; 12 | LinearRgb; 13 | } 14 | ``` 15 | -------------------------------------------------------------------------------- /docs/color-stop.md: -------------------------------------------------------------------------------- 1 | # ColorStop 2 | 3 | Represents a key point in a gradient. 4 | 5 | ``` 6 | interface ColorStop { 7 | ratio: Uint8; 8 | color: StraightSRgba8; 9 | } 10 | ``` 11 | -------------------------------------------------------------------------------- /docs/color-transform-with-alpha.md: -------------------------------------------------------------------------------- 1 | # ColorTransformWithAlpha 2 | 3 | ``` 4 | interface ColorTransformWithAlpha { 5 | redMult: Sfixed(8, 8); 6 | greenMult: Sfixed(8, 8); 7 | blueMult: Sfixed(8, 8); 8 | alphaMult: Sfixed(8, 8); 9 | redAdd: Sint(16); 10 | greenAdd: Sint(16); 11 | blueAdd: Sint(16); 12 | alphaAdd: Sint(16); 13 | } 14 | ``` 15 | -------------------------------------------------------------------------------- /docs/color-transform.md: -------------------------------------------------------------------------------- 1 | # ColorTransform 2 | 3 | ``` 4 | interface ColorTransform { 5 | redMult: Sfixed(8, 8); 6 | greenMult: Sfixed(8, 8); 7 | blueMult: Sfixed(8, 8); 8 | redAdd: Sint(16); 9 | greenAdd: Sint(16); 10 | blueAdd: Sint(16); 11 | } 12 | ``` 13 | -------------------------------------------------------------------------------- /docs/compression-method.md: -------------------------------------------------------------------------------- 1 | # CompressionMethod 2 | 3 | The compression method used for this file. (Irrelevant in the AST?) 4 | 5 | ``` 6 | interface CompressionMethod { 7 | Deflate; 8 | Lzma; 9 | None; 10 | } 11 | ``` 12 | -------------------------------------------------------------------------------- /docs/fill-style.md: -------------------------------------------------------------------------------- 1 | # FillStyle 2 | 3 | ``` 4 | union(type) FillStyle { 5 | fillStyles.Bitmap; 6 | fillStyles.FocalRadialGradient; 7 | fillStyles.MorphLinearGradient; 8 | fillStyles.MorphRadialGradient; 9 | fillStyles.MorphSolid; 10 | } 11 | ``` 12 | -------------------------------------------------------------------------------- /docs/fill-styles/bitmap.md: -------------------------------------------------------------------------------- 1 | # MorphFocalGradient 2 | 3 | ``` 4 | interface ClippedBitmap FillStyle(type) { 5 | bitmapId: Uint(16); 6 | matrix: Matrix; 7 | repeating: Boolean; 8 | smoothed: Boolean; 9 | } 10 | ``` 11 | -------------------------------------------------------------------------------- /docs/fill-styles/focal-gradient.md: -------------------------------------------------------------------------------- 1 | # MorphFocalGradient 2 | 3 | ``` 4 | interface MorphFocalGradient FillStyle(type) { 5 | matrix: Matrix; 6 | gradient: Gradient; 7 | focalPoint: Fixed8P8; 8 | } 9 | ``` 10 | 11 | TODO: Find out how the focal point works. 12 | -------------------------------------------------------------------------------- /docs/fill-styles/linear-gradient.md: -------------------------------------------------------------------------------- 1 | # MorphLinearGradient 2 | 3 | ``` 4 | interface MorphLinearGradient FillStyle(type) { 5 | matrix: Matrix; 6 | gradient: Gradient; 7 | } 8 | ``` 9 | -------------------------------------------------------------------------------- /docs/fill-styles/morph-bitmap.md: -------------------------------------------------------------------------------- 1 | # MorphFocalGradient 2 | 3 | ``` 4 | interface ClippedBitmap MorphFillStyle(type) { 5 | bitmapId: Uint(16); 6 | matrix: Matrix; 7 | repeating: Boolean; 8 | smoothed: Boolean; 9 | } 10 | ``` 11 | -------------------------------------------------------------------------------- /docs/fill-styles/morph-focal-gradient.md: -------------------------------------------------------------------------------- 1 | # MorphFocalGradient 2 | 3 | ``` 4 | interface MorphFocalGradient MorphFillStyle(type) { 5 | matrix: Matrix; 6 | gradient: Gradient; 7 | focalPoint: Fixed8P8; 8 | } 9 | ``` 10 | 11 | TODO: Find out how the focal point works. 12 | -------------------------------------------------------------------------------- /docs/fill-styles/morph-linear-gradient.md: -------------------------------------------------------------------------------- 1 | # MorphLinearGradient 2 | 3 | ``` 4 | interface MorphLinearGradient MorphFillStyle(type) { 5 | matrix: Matrix; 6 | gradient: Gradient; 7 | } 8 | ``` 9 | -------------------------------------------------------------------------------- /docs/fill-styles/morph-radial-gradient.md: -------------------------------------------------------------------------------- 1 | # MorphRadialGradient 2 | 3 | ``` 4 | interface MorphRadialGradient MorphFillStyle(type) { 5 | matrix: Matrix; 6 | gradient: Gradient; 7 | } 8 | ``` 9 | -------------------------------------------------------------------------------- /docs/fill-styles/morph-solid.md: -------------------------------------------------------------------------------- 1 | # MorphSolid 2 | 3 | ``` 4 | interface MorphSolid variantof MorphFillStyle(type) { 5 | color: StraightSRgba; 6 | } 7 | ``` 8 | -------------------------------------------------------------------------------- /docs/fill-styles/radial-gradient.md: -------------------------------------------------------------------------------- 1 | # MorphRadialGradient 2 | 3 | ``` 4 | interface MorphRadialGradient FillStyle(type) { 5 | matrix: Matrix; 6 | gradient: Gradient; 7 | } 8 | ``` 9 | -------------------------------------------------------------------------------- /docs/fill-styles/solid.md: -------------------------------------------------------------------------------- 1 | # MorphSolid 2 | 3 | ``` 4 | interface MorphSolid variantof FillStyle(type) { 5 | color: StraightSRgba; 6 | } 7 | ``` 8 | -------------------------------------------------------------------------------- /docs/filter.md: -------------------------------------------------------------------------------- 1 | # Filter 2 | 3 | ``` 4 | union(filter) Filter { 5 | Bevel; 6 | Blur; 7 | ColorMatrix; 8 | Convolution; 9 | DropShadow; 10 | Glow; 11 | GradientBevel; 12 | GradientGlow; 13 | } 14 | ``` 15 | -------------------------------------------------------------------------------- /docs/filters/bevel.md: -------------------------------------------------------------------------------- 1 | # Bevel 2 | 3 | ``` 4 | interface Bevel variantof Filter(filter) { 5 | shadowColor: StraightSRgba8; 6 | highlightColor: StraightSRgba8; 7 | blurX: Sfixed(16, 16); 8 | blurY: Sfixed(16, 16); 9 | angle: Sfixed(16, 16); 10 | distance: Sfixed(16, 16); 11 | strength: Sfixed(8, 8); 12 | inner: Boolean; 13 | knockout: Boolean; 14 | compositeSource: Boolean; 15 | onTop: Boolean; 16 | passes: Uint(4); 17 | } 18 | ``` 19 | -------------------------------------------------------------------------------- /docs/filters/blur.md: -------------------------------------------------------------------------------- 1 | # Blur 2 | 3 | ``` 4 | interface Blur variantof Filter(filter) { 5 | blurX: Sfixed(16, 16); 6 | blurY: Sfixed(16, 16); 7 | passes: Uint(5); 8 | } 9 | ``` 10 | -------------------------------------------------------------------------------- /docs/filters/color-matrix.md: -------------------------------------------------------------------------------- 1 | # ColorMatrix 2 | 3 | ``` 4 | interface ColorMatrix variantof Filter(filter) { 5 | matrix: Float(32)[20]; 6 | } 7 | ``` 8 | -------------------------------------------------------------------------------- /docs/filters/convolution.md: -------------------------------------------------------------------------------- 1 | # Convolution 2 | 3 | ``` 4 | interface Convolution variantof Filter(filter) { 5 | matrixWidth: UintSize; 6 | matrixHeight: UintSize; 7 | divisor: Float(32); 8 | bias: Float(32); 9 | matrix: Float(32)[matrixWidth × matrixHeight]; 10 | defaultColor: StraightSRgba8; 11 | clamp: Boolean; 12 | preserveAlpha: Boolean; 13 | } 14 | ``` 15 | -------------------------------------------------------------------------------- /docs/filters/drop-shadow.md: -------------------------------------------------------------------------------- 1 | # DropShadow 2 | 3 | ``` 4 | interface DropShadow variantof Filter(filter) { 5 | color: StraightSRgba8; 6 | blurX: Sfixed(16, 16); 7 | blurY: Sfixed(16, 16); 8 | angle: Sfixed(16, 16); 9 | distance: Sfixed(16, 16); 10 | strength: Sfixed(8, 8); 11 | inner: Boolean; 12 | knockout: Boolean; 13 | compositeSource: Boolean; 14 | passes: Uint(5); 15 | } 16 | ``` 17 | -------------------------------------------------------------------------------- /docs/filters/glow.md: -------------------------------------------------------------------------------- 1 | # Glow 2 | 3 | ``` 4 | interface Glow variantof Filter(filter) { 5 | color: StraightSRgba8; 6 | blurX: Sfixed(16, 16); 7 | blurY: Sfixed(16, 16); 8 | strength: Sfixed(8, 8); 9 | inner: Boolean; 10 | knockout: Boolean; 11 | compositeSource: Boolean; 12 | passes: Uint(5); 13 | } 14 | ``` 15 | -------------------------------------------------------------------------------- /docs/filters/gradient-bevel.md: -------------------------------------------------------------------------------- 1 | # GradientBevel 2 | 3 | ``` 4 | interface GradientBevel variantof Filter(filter) { 5 | gradient: ColorStop[]; 6 | blurX: Sfixed(16, 16); 7 | blurY: Sfixed(16, 16); 8 | angle: Sfixed(16, 16); 9 | distance: Sfixed(16, 16); 10 | strength: Sfixed(8, 8); 11 | inner: Boolean; 12 | knockout: Boolean; 13 | compositeSource: Boolean; 14 | onTop: Boolean; 15 | passes: Uint(4); 16 | } 17 | ``` 18 | -------------------------------------------------------------------------------- /docs/filters/gradient-glow.md: -------------------------------------------------------------------------------- 1 | # GradientGlow 2 | 3 | ``` 4 | interface GradientGlow variantof Filter(filter) { 5 | gradient: ColorStop[]; 6 | blurX: Sfixed(16, 16); 7 | blurY: Sfixed(16, 16); 8 | angle: Sfixed(16, 16); 9 | distance: Sfixed(16, 16); 10 | strength: Sfixed(8, 8); 11 | inner: Boolean; 12 | knockout: Boolean; 13 | compositeSource: Boolean; 14 | onTop: Boolean; 15 | passes: Uint(4); 16 | } 17 | ``` 18 | -------------------------------------------------------------------------------- /docs/glyph.md: -------------------------------------------------------------------------------- 1 | # Glyph 2 | 3 | ``` 4 | interface Glyph { 5 | records: ShapeRecord[]; 6 | } 7 | ``` 8 | -------------------------------------------------------------------------------- /docs/gradient-spread.md: -------------------------------------------------------------------------------- 1 | # GradientSpread 2 | 3 | Defines how gradients are extended beyond their definition range. 4 | 5 | The spec calls it `SpreadMode`. 6 | 7 | ``` 8 | enum GradientSpread { 9 | Pad; 10 | Reflect; 11 | Repeat; 12 | } 13 | ``` 14 | -------------------------------------------------------------------------------- /docs/gradient.md: -------------------------------------------------------------------------------- 1 | # Gradient 2 | 3 | Represents the color repartition in a gradient. 4 | 5 | This also encompasses part of the `MorphFocalGradient` from the spec. 6 | 7 | ``` 8 | interface MorphLinearGradient { 9 | spread: GradientSpread; 10 | colorSpace: ColorSpace; 11 | colors: ColorStop[]; 12 | } 13 | ``` 14 | -------------------------------------------------------------------------------- /docs/header.md: -------------------------------------------------------------------------------- 1 | # Header 2 | 3 | ``` 4 | interface Header { 5 | version: Uint(8); 6 | size: Rect; 7 | frameRate: Ufixed(8, 8); 8 | frameCount: Uint(16); 9 | } 10 | ``` 11 | -------------------------------------------------------------------------------- /docs/join-style.md: -------------------------------------------------------------------------------- 1 | # JoinStyle 2 | 3 | ``` 4 | union(type) JoinStyle { 5 | Bevel; 6 | Miter; 7 | Round; 8 | } 9 | ``` 10 | -------------------------------------------------------------------------------- /docs/join-styles/bevel.md: -------------------------------------------------------------------------------- 1 | # Bevel 2 | 3 | ``` 4 | interface Bevel variantof JoinStyle(type) { 5 | } 6 | ``` 7 | -------------------------------------------------------------------------------- /docs/join-styles/miter.md: -------------------------------------------------------------------------------- 1 | # Miter 2 | 3 | ``` 4 | interface Miter variantof JoinStyle(type) { 5 | limit: Uint(16); 6 | } 7 | ``` 8 | -------------------------------------------------------------------------------- /docs/join-styles/round.md: -------------------------------------------------------------------------------- 1 | # Round 2 | 3 | ``` 4 | interface Round variantof JoinStyle(type) { 5 | } 6 | ``` 7 | -------------------------------------------------------------------------------- /docs/language-code.md: -------------------------------------------------------------------------------- 1 | # LanguageCode 2 | 3 | ``` 4 | enum LanguageCode { 5 | Auto; 6 | Latin; 7 | Japanese; 8 | Korean; 9 | SimplifiedChinese; 10 | TraditionalChinese; 11 | } 12 | ``` 13 | -------------------------------------------------------------------------------- /docs/line-style.md: -------------------------------------------------------------------------------- 1 | # LineStyle 2 | 3 | ``` 4 | interface LineStyle { 5 | width: Uint(16); 6 | startCap: CapStyle; 7 | endCap: CapStyle; 8 | join: JoinStyle; 9 | noHScale: Boolean; 10 | noVScale: Boolean; 11 | noClose: Boolean; 12 | pixelHinting: Boolean; 13 | fill: FillStyle; 14 | } 15 | ``` 16 | -------------------------------------------------------------------------------- /docs/matrix.md: -------------------------------------------------------------------------------- 1 | # Matrix 2 | 3 | ``` 4 | interface Matrix { 5 | scaleX: Sfixed(16, 16); 6 | scaleY: Sfixed(16, 16); 7 | rotateSkew0: Sfixed(16, 16); 8 | rotateSkew1: Sfixed(16, 16); 9 | translateX: Sint(16); 10 | translateY: Sint(16); 11 | } 12 | ``` 13 | -------------------------------------------------------------------------------- /docs/morph-fill-style.md: -------------------------------------------------------------------------------- 1 | # MorphFillStyle 2 | 3 | ``` 4 | union(type) MorphFillStyle { 5 | morphFillStyles.Bitmap; 6 | morphFillStyles.FocalRadialGradient; 7 | morphFillStyles.MorphLinearGradient; 8 | morphFillStyles.MorphRadialGradient; 9 | morphFillStyles.MorphSolid; 10 | } 11 | ``` 12 | -------------------------------------------------------------------------------- /docs/morph-shape-record.md: -------------------------------------------------------------------------------- 1 | # ShapeRecord 2 | 3 | ``` 4 | union(type) MorphShapeRecord { 5 | MorphEdge; 6 | StyleChange; 7 | } 8 | ``` 9 | -------------------------------------------------------------------------------- /docs/morph-shape.md: -------------------------------------------------------------------------------- 1 | # MorphShape 2 | 3 | ``` 4 | interface MorphShape { 5 | fillStyles: MorphFillStyle[]; 6 | lineStyles: LineStyle[]; 7 | records: MorphShapeRecord[]; 8 | } 9 | ``` 10 | -------------------------------------------------------------------------------- /docs/movie.md: -------------------------------------------------------------------------------- 1 | # Movie 2 | 3 | This is the root node of the AST. 4 | 5 | ``` 6 | interface Movie { 7 | header: Header; 8 | tags: Tag[]; 9 | } 10 | ``` 11 | -------------------------------------------------------------------------------- /docs/named-id.md: -------------------------------------------------------------------------------- 1 | # NamedId 2 | 3 | ``` 4 | interface NamedId { 5 | id: Uint(16); 6 | name: String; 7 | } 8 | ``` 9 | -------------------------------------------------------------------------------- /docs/radial-gradient.md: -------------------------------------------------------------------------------- 1 | # MorphRadialGradient 2 | 3 | 4 | 5 | ``` 6 | interface MorphRadialGradient { 7 | spread: GradientSpread; 8 | colorSpace: ColorSpace; 9 | colors: ColorStop[]; 10 | focalPoint: SFixed8P8; 11 | } 12 | ``` 13 | 14 | -------------------------------------------------------------------------------- /docs/s-rgb8.md: -------------------------------------------------------------------------------- 1 | # SRgb8 2 | 3 | Point in the the sRGB color space with 8 bits per channel. 4 | 5 | ``` 6 | interface SRgb8 { 7 | r: Uint(8); 8 | g: Uint(8); 9 | b: Uint(8); 10 | } 11 | ``` 12 | -------------------------------------------------------------------------------- /docs/shape-record.md: -------------------------------------------------------------------------------- 1 | # ShapeRecord 2 | 3 | ``` 4 | union(type) ShapeRecord { 5 | Edge; 6 | StyleChange; 7 | } 8 | ``` 9 | -------------------------------------------------------------------------------- /docs/shape-records/edge.md: -------------------------------------------------------------------------------- 1 | # Edge 2 | 3 | ``` 4 | interface Edge variantof ShapeRecord(type) { 5 | delta: Vector2D; 6 | controlDelta: Option; 7 | } 8 | ``` 9 | -------------------------------------------------------------------------------- /docs/shape-records/morph-edge.md: -------------------------------------------------------------------------------- 1 | # MorphEdge 2 | 3 | ``` 4 | interface MorphEdge variantof MorphShapeRecord(type) { 5 | delta: Vector2D; 6 | controlDelta: Option; 7 | } 8 | ``` 9 | -------------------------------------------------------------------------------- /docs/shape-records/morph-style-change.md: -------------------------------------------------------------------------------- 1 | # MorphStyleChange 2 | 3 | ``` 4 | interface MorphStyleChange variantof MorphShapeRecord(type) { 5 | moveTo: Option(Vector2D); 6 | leftFill: Option(Usize); 7 | rightFill: Option(Usize); 8 | lineStyle: Option(Usize); 9 | fillStyles: Option(FillStyle[]); 10 | lineStyles: Option(LineStyle[]); 11 | } 12 | ``` 13 | -------------------------------------------------------------------------------- /docs/shape-records/style-change.md: -------------------------------------------------------------------------------- 1 | # StyleChange 2 | 3 | ``` 4 | interface StyleChange variantof ShapeRecord(type) { 5 | moveTo: Option(Vector2D); 6 | leftFill: Option(Usize); 7 | rightFill: Option(Usize); 8 | lineStyle: Option(Usize); 9 | fillStyles: Option(FillStyle[]); 10 | lineStyles: Option(LineStyle[]); 11 | } 12 | ``` 13 | -------------------------------------------------------------------------------- /docs/shape.md: -------------------------------------------------------------------------------- 1 | # Shape 2 | 3 | ``` 4 | interface Shape { 5 | fillStyles: FillStyle[]; 6 | lineStyles: LineStyle[]; 7 | records: ShapeRecord[]; 8 | } 9 | ``` 10 | -------------------------------------------------------------------------------- /docs/shapes/clip-action.md: -------------------------------------------------------------------------------- 1 | # ClipAction 2 | 3 | ``` 4 | interface ClipAction { 5 | eventFlags: ClipEventFlags; 6 | keyCode: Option(Uint(8)); 7 | actions: Action[]; 8 | } 9 | ``` 10 | -------------------------------------------------------------------------------- /docs/shapes/clip-event-flags.md: -------------------------------------------------------------------------------- 1 | # ClipEventFlags 2 | 3 | ``` 4 | interface ClipEventFlags { 5 | keyUp: Boolean; 6 | keyDown: Boolean; 7 | mouseUp: Boolean; 8 | mouseDown: Boolean; 9 | unload: Boolean; 10 | enterFrane: Boolean; 11 | load: Boolean; 12 | dragOver: Boolean; 13 | rollOut: Boolean; 14 | rollOver: Boolean; 15 | releaseOutside: Boolean; 16 | release: Boolean; 17 | press: Boolean; 18 | initialize: Boolean; 19 | data: Boolean; 20 | construct: Boolean; 21 | keyPress: Boolean; 22 | dragOut: Boolean; 23 | } 24 | ``` 25 | -------------------------------------------------------------------------------- /docs/sound/audio-coding-format.md: -------------------------------------------------------------------------------- 1 | # SoundType 2 | 3 | ``` 4 | enum AudioCodingFormat { 5 | UncompressedNativeEndian; 6 | Adpcm; 7 | Mp3; 8 | UncompressedLittleEndian; 9 | Nellymoser16; 10 | Nellymoser8; 11 | Nellymoser; 12 | Speex; 13 | } 14 | ``` 15 | -------------------------------------------------------------------------------- /docs/sound/sound-rate.md: -------------------------------------------------------------------------------- 1 | # SoundRate 2 | 3 | ``` 4 | whitelist(Uint16) SoundRate { 5 | 5500; 6 | 11000; 7 | 22000; 8 | 44000; 9 | } 10 | ``` 11 | -------------------------------------------------------------------------------- /docs/sound/sound-size.md: -------------------------------------------------------------------------------- 1 | # SoundSize 2 | 3 | ``` 4 | whitelist(Uint8) SoundSize { 5 | 8; 6 | 16; 7 | } 8 | ``` 9 | -------------------------------------------------------------------------------- /docs/sound/sound-type.md: -------------------------------------------------------------------------------- 1 | # SoundType 2 | 3 | ``` 4 | enum SoundType { 5 | Mono; 6 | Stereo; 7 | } 8 | ``` 9 | -------------------------------------------------------------------------------- /docs/straight-s-rgba8.md: -------------------------------------------------------------------------------- 1 | # StraightSRgba8 2 | 3 | Point in the the sRGB color space with transparency and 8 bits per channel. 4 | 5 | ``` 6 | interface SRgb8 { 7 | r: Uint(8); 8 | g: Uint(8); 9 | b: Uint(8); 10 | a: Uint(8); 11 | } 12 | ``` 13 | -------------------------------------------------------------------------------- /docs/swf-signature.md: -------------------------------------------------------------------------------- 1 | # SwfSignature 2 | 3 | This corresponds to the first 8 bytes of the SWF file. While the remaining part of the file 4 | may be compressed, the signature is always written without any transformation. 5 | 6 | ``` 7 | interface SwfSignature { 8 | compression: CompressionMethod; 9 | version: Uint(8); 10 | uncompressedLength: Uint(32); 11 | } 12 | ``` 13 | -------------------------------------------------------------------------------- /docs/tag-header.md: -------------------------------------------------------------------------------- 1 | # TagHeader 2 | 3 | Internal type representing a raw tag header. 4 | 5 | ``` 6 | interface TagHeader { 7 | code: Uint(16); 8 | length: Uint(32); 9 | } 10 | ``` 11 | -------------------------------------------------------------------------------- /docs/tags/csm-text-settings.md: -------------------------------------------------------------------------------- 1 | # CsmTextSettings 2 | 3 | ``` 4 | interface CsmTextSettings variantof Tag(type) { 5 | type: TagType.CsmTextSettings; 6 | textId: Uint(16); 7 | renderer: TextRenderer; 8 | fitting: GridFitting; 9 | thickness: Float(32); 10 | sharpness: Float(32); 11 | } 12 | ``` 13 | -------------------------------------------------------------------------------- /docs/tags/define-binary-data.md: -------------------------------------------------------------------------------- 1 | # DefineBinaryData 2 | 3 | ``` 4 | interface DefineBinaryData variantof Tag(type) { 5 | id: Uint(16); 6 | data: Buffer; 7 | } 8 | ``` 9 | -------------------------------------------------------------------------------- /docs/tags/define-cff-font.md: -------------------------------------------------------------------------------- 1 | # DefineCffFont 2 | 3 | ``` 4 | interface DefineCffFont variantof Tag(type) { 5 | id: Uint(16); 6 | fontName: String; 7 | isItalic: Boolean; 8 | isBold: Boolean; 9 | data: Buffer; 10 | } 11 | ``` 12 | -------------------------------------------------------------------------------- /docs/tags/define-dynamic-text.md: -------------------------------------------------------------------------------- 1 | # DefineDynamicText 2 | 3 | ``` 4 | interface DefineDynamicText variantof Tag(type) { 5 | id: Uint(16); 6 | bounds: Rect; 7 | wordWrap: Boolean; 8 | multiline: Boolean; 9 | password: Boolean; 10 | readonly: Boolean; 11 | autoSize: Boolean; 12 | noSelect: Boolean; 13 | border: Boolean; 14 | wasStatic: Boolean; 15 | html: Boolean; 16 | useGlyphFont: Boolean; 17 | fontId: Option(Uint(16)); 18 | fontSize: Option(Uint(16)); 19 | fontClass?: String; 20 | color?: StraightSRgba8; 21 | maxLength: Uint(16); 22 | align?: TextAlignment; 23 | marginLeft: Uint(16); 24 | marginRight: Uint(16); 25 | indent: Uint(16); 26 | leading: Sint(16); 27 | variableName: Option(String); 28 | text: Option(String); 29 | } 30 | ``` 31 | -------------------------------------------------------------------------------- /docs/tags/define-font-align-zones.md: -------------------------------------------------------------------------------- 1 | # DefineFontAlignZones 2 | 3 | ``` 4 | interface DefineFontAlignZones variantof Tag(type) { 5 | fontId: Uint(16); 6 | csmTableHint: CsmTableHint; 7 | zones: FontAlignmentZone[]; 8 | } 9 | ``` 10 | -------------------------------------------------------------------------------- /docs/tags/define-font-info.md: -------------------------------------------------------------------------------- 1 | # DefineFontInfo 2 | 3 | ``` 4 | interface DefineFontInfo variantof Tag(type) { 5 | fontId: Uint(16); 6 | fontName: String; 7 | isSmall: Boolean; 8 | isShiftJis: Boolean; 9 | isAnsi: Boolean; 10 | isItalic: Boolean; 11 | isBold: Boolean; 12 | language?: LanguageCode; 13 | codeUnits: Uint(16)[]; 14 | } 15 | ``` 16 | -------------------------------------------------------------------------------- /docs/tags/define-font-name.md: -------------------------------------------------------------------------------- 1 | # DefineFontName 2 | 3 | ``` 4 | interface DefineFontName variantof Tag(type) { 5 | fontId: Uint(16); 6 | name: String; 7 | copyright: String; 8 | } 9 | ``` 10 | -------------------------------------------------------------------------------- /docs/tags/define-font.md: -------------------------------------------------------------------------------- 1 | # DefineFont 2 | 3 | ``` 4 | interface DefineFont variantof Tag(type) { 5 | id: Uint(16); 6 | fontName: String; 7 | isSmall: Boolean; 8 | isShiftJis: Boolean; 9 | isAnsi: Boolean; 10 | isItalic: Boolean; 11 | isBold: Boolean; 12 | language: LanguageCode; 13 | glyphs: Glyph[]; 14 | codeUnits: Uint(16)[]; 15 | layout: Option(FontLayout); 16 | } 17 | ``` 18 | -------------------------------------------------------------------------------- /docs/tags/define-jpeg-tables.md: -------------------------------------------------------------------------------- 1 | # DefineJpegTables 2 | 3 | ``` 4 | interface DefineJpegTables variantof Tag(type) { 5 | data: Buffer; 6 | } 7 | ``` 8 | -------------------------------------------------------------------------------- /docs/tags/define-morph-shape.md: -------------------------------------------------------------------------------- 1 | # DefineMorphShape 2 | 3 | ``` 4 | interface DefineMorphShape variantof Tag(type) { 5 | id: Uint(16); 6 | startBounds: Rect; 7 | endBounds: Rect; 8 | // TODO: Combine edgeBounds with something like MorphRect 9 | startEdgeBounds: Option(Rect); 10 | endEdgeBounds: Option(Rect); 11 | hasFillWinding: Boolean; 12 | hasNonScalingStrokes: Boolean; 13 | hasScalingStrokes: Boolean; 14 | shape: MorphShape; 15 | } 16 | ``` 17 | -------------------------------------------------------------------------------- /docs/tags/define-partial-font.md: -------------------------------------------------------------------------------- 1 | # DefinePartialFont 2 | 3 | ``` 4 | interface DefinePartialFont variantof Tag(type) { 5 | id: Uint(16); 6 | glyphs: Glyph[]; 7 | } 8 | ``` 9 | -------------------------------------------------------------------------------- /docs/tags/define-shape.md: -------------------------------------------------------------------------------- 1 | # DefineShape 2 | 3 | ``` 4 | interface DefineShape variantof Tag(type) { 5 | id: Uint(16); 6 | bounds: Rect; 7 | edgeBounds: Option(Rect); 8 | hasFillWinding: Boolean; 9 | hasNonScalingStrokes: Boolean; 10 | hasScalingStrokes: Boolean; 11 | shape: Shape; 12 | } 13 | ``` 14 | -------------------------------------------------------------------------------- /docs/tags/define-sound.md: -------------------------------------------------------------------------------- 1 | # DefineSound 2 | 3 | ``` 4 | interface DefineSound variantof Tag(type) { 5 | id: Uint(16); 6 | soundType: SoundType; 7 | soundSize: SoundSize; 8 | soundRate: SoundRate; 9 | format: AudioCodingFormat; 10 | sampleCount: Uint(32); 11 | data: Buffer; 12 | } 13 | ``` 14 | -------------------------------------------------------------------------------- /docs/tags/define-sprite.md: -------------------------------------------------------------------------------- 1 | # DefineSprite 2 | 3 | ``` 4 | interface DefineSprite variantof Tag(type) { 5 | id: Uint(16); 6 | frameCount: UintSize; 7 | tags: Tag[]; 8 | } 9 | ``` 10 | -------------------------------------------------------------------------------- /docs/tags/define-text.md: -------------------------------------------------------------------------------- 1 | # DefineText 2 | 3 | ``` 4 | interface DefineText variantof Tag(type) { 5 | id: Uint(16); 6 | bounds: Rect; 7 | matrix: Matrix; 8 | records: TextRecord[]; 9 | } 10 | ``` 11 | -------------------------------------------------------------------------------- /docs/tags/do-abc.md: -------------------------------------------------------------------------------- 1 | # DoAbc 2 | 3 | ``` 4 | interface DoAbc variantof Tag(type) { 5 | flags: Uint(32); 6 | name: String; 7 | data: Buffer; 8 | } 9 | ``` 10 | -------------------------------------------------------------------------------- /docs/tags/do-action.md: -------------------------------------------------------------------------------- 1 | # DoAction 2 | 3 | ``` 4 | interface DoAction variantof Tag(type) { 5 | actions: Buffer; 6 | } 7 | ``` 8 | -------------------------------------------------------------------------------- /docs/tags/do-init-action.md: -------------------------------------------------------------------------------- 1 | # DoInitAction 2 | 3 | ``` 4 | interface DoInitAction variantof Tag(type) { 5 | spriteId: Uint(16); 6 | actions: Buffer; 7 | } 8 | ``` 9 | -------------------------------------------------------------------------------- /docs/tags/enable-debugger.md: -------------------------------------------------------------------------------- 1 | # EnableDebugger 2 | 3 | ``` 4 | interface EnableDebugger variantof Tag(type) { 5 | password: String; 6 | } 7 | ``` 8 | -------------------------------------------------------------------------------- /docs/tags/export-assets.md: -------------------------------------------------------------------------------- 1 | # ExportAssets 2 | 3 | ``` 4 | interface ExportAssets variantof Tag(type) { 5 | assets: NamedId[]; 6 | } 7 | ``` 8 | -------------------------------------------------------------------------------- /docs/tags/file-attributes.md: -------------------------------------------------------------------------------- 1 | # FileAttributes 2 | 3 | ``` 4 | interface FileAttributes variantof Tag(type) { 5 | useNetwork: Boolean; 6 | // Not in the spec, found in Shumway 7 | useRelativeUrls: Boolean; 8 | // Not in the spec, found in Shumway 9 | noCrossDomainCaching: Boolean; 10 | useAs3: Boolean; 11 | hasMetadata: Boolean; 12 | useGpu: Boolean; 13 | useDirectBlit: Boolean; 14 | } 15 | ``` 16 | -------------------------------------------------------------------------------- /docs/tags/import-assets.md: -------------------------------------------------------------------------------- 1 | # ImportAssets 2 | 3 | ``` 4 | interface ExportAssets variantof Tag(type) { 5 | url: String; 6 | assets: NamedId[]; 7 | } 8 | ``` 9 | -------------------------------------------------------------------------------- /docs/tags/metadata.md: -------------------------------------------------------------------------------- 1 | # Metadata 2 | 3 | ``` 4 | interface Metadata variantof Tag(type) { 5 | metadata: String; 6 | } 7 | ``` 8 | -------------------------------------------------------------------------------- /docs/tags/place-object.md: -------------------------------------------------------------------------------- 1 | # PlaceObject 2 | 3 | ``` 4 | interface PlaceObject variantof Tag(type) { 5 | isUpdate: Boolean; 6 | depth: Uint(16); 7 | characterId: Option(Uint(16)); 8 | className: Option(String); 9 | matrix: Option(Matrix); 10 | colorTransform: Option(ColorTransformWithAlpha); 11 | ratio: Option(Uint(16)); 12 | name: Option(String); 13 | clipDepth: Option(Uint(16)); 14 | filters: Option(Filter[]); 15 | blendMode: Option(BlendMode); 16 | bitmapCache: Option(boolean); 17 | visible: Option(boolean); 18 | backgroundColor: Option(StraightSRgba); 19 | clipActions: Option(ClipAction[]); 20 | } 21 | ``` 22 | 23 | `isUpdate` corresponds to `PlaceFlagMove` in the spec. 24 | -------------------------------------------------------------------------------- /docs/tags/remove-object.md: -------------------------------------------------------------------------------- 1 | # RemoveObject 2 | 3 | ``` 4 | interface PlaceObject variantof Tag(type) { 5 | characterId: Option(Uint(16)); 6 | depth: Uint(16); 7 | } 8 | ``` 9 | -------------------------------------------------------------------------------- /docs/tags/script-limits.md: -------------------------------------------------------------------------------- 1 | # ScriptLimits 2 | 3 | ``` 4 | interface ScriptLimits variantof Tag(type) { 5 | maxRecursionDepth: Uint(16); 6 | scriptTimeout: Uint(16); 7 | } 8 | ``` 9 | 10 | - `maxRecursionDepth` has a default of 256. 11 | - `scriptTimeout` is in seconds. Default is between 15 and 20 seconds. 12 | -------------------------------------------------------------------------------- /docs/tags/show-frame.md: -------------------------------------------------------------------------------- 1 | # ShowFrame 2 | 3 | ``` 4 | interface ShowFrame variantof Tag(type) { 5 | } 6 | ``` 7 | -------------------------------------------------------------------------------- /docs/tags/sound-stream-block.md: -------------------------------------------------------------------------------- 1 | # SoundStreamBlock 2 | 3 | ``` 4 | interface SoundStreamBlock variantof Tag(type) { 5 | data: Buffer; 6 | } 7 | ``` 8 | -------------------------------------------------------------------------------- /docs/tags/sound-stream-head.md: -------------------------------------------------------------------------------- 1 | # SoundStreamHead 2 | 3 | ``` 4 | interface SoundStreamHead variantof Tag(type) { 5 | playbackSoundType: SoundType; 6 | playbackSoundSize: SoundSize; 7 | playbackSoundRate: SoundRate; 8 | streamSoundType: SoundType; 9 | streamSoundSize: SoundSize; 10 | streamSoundRate: SoundRate; 11 | streamFormat: AudioCodingFormat; 12 | sampleCount: Uint(16); 13 | latencySeek: Option(Sint(16)); 14 | } 15 | ``` 16 | -------------------------------------------------------------------------------- /docs/tags/start-sound.md: -------------------------------------------------------------------------------- 1 | # StartSound 2 | 3 | ``` 4 | interface StartSound variantof Tag(type) { 5 | soundId: Uint(16); 6 | soundInfo: SoundInfo; 7 | } 8 | ``` 9 | -------------------------------------------------------------------------------- /docs/tags/start-sound2.md: -------------------------------------------------------------------------------- 1 | # StartSound 2 | 3 | ``` 4 | interface StartSound2 variantof Tag(type) { 5 | soundClassName: String; 6 | soundInfo: SoundInfo; 7 | } 8 | ``` 9 | -------------------------------------------------------------------------------- /docs/tags/symbol-class.md: -------------------------------------------------------------------------------- 1 | # SymbolClass 2 | 3 | ``` 4 | interface SymbolClass variantof Tag(type) { 5 | symbols: NamedId[]; 6 | } 7 | ``` 8 | 9 | `ExportAssets` for AS3. 10 | -------------------------------------------------------------------------------- /docs/tags/telemetry.md: -------------------------------------------------------------------------------- 1 | # Telemetry 2 | 3 | ``` 4 | interface Telemetry variantof Tag(type) { 5 | password: Option(Buffer); 6 | } 7 | ``` 8 | -------------------------------------------------------------------------------- /docs/text/csm-table-hint.md: -------------------------------------------------------------------------------- 1 | # CsmTableHint 2 | 3 | ``` 4 | enum CsmTableHint { 5 | Thin; 6 | Medium; 7 | Thick; 8 | } 9 | ``` 10 | -------------------------------------------------------------------------------- /docs/text/font-alignment-zone-data.md: -------------------------------------------------------------------------------- 1 | # FontAlignmentZoneData 2 | 3 | ``` 4 | interface FontAlignmentZoneData { 5 | origin: Float(16); 6 | size: Float(16); 7 | } 8 | ``` 9 | -------------------------------------------------------------------------------- /docs/text/font-alignment-zone.md: -------------------------------------------------------------------------------- 1 | # FontAlignmentZone 2 | 3 | ``` 4 | interface FontAlignmentZone { 5 | data: FontAlignmentZoneData[]; 6 | hasX: Boolean; 7 | hasY: Boolean; 8 | } 9 | ``` 10 | -------------------------------------------------------------------------------- /docs/text/font-layout.md: -------------------------------------------------------------------------------- 1 | # FontLayout 2 | 3 | ``` 4 | interface FontLayout { 5 | ascent: Uint(16); 6 | descent: Uint(16); 7 | leading: Uint(16); 8 | advances: Uint(16)[]; 9 | bounds: Rect[]; 10 | kerning: KerningRecord[]; 11 | } 12 | ``` 13 | -------------------------------------------------------------------------------- /docs/text/glyph-entry.md: -------------------------------------------------------------------------------- 1 | # GlyphEntry 2 | 3 | ``` 4 | enum GlyphEntry { 5 | index: UintSize; 6 | advance: Sint(32); 7 | } 8 | ``` 9 | -------------------------------------------------------------------------------- /docs/text/grid-fitting.md: -------------------------------------------------------------------------------- 1 | # GridFitting 2 | 3 | ``` 4 | enum GridFitting { 5 | None; 6 | Pixel; 7 | SubPixel; 8 | } 9 | ``` 10 | -------------------------------------------------------------------------------- /docs/text/kerning-record.md: -------------------------------------------------------------------------------- 1 | # KerningRecord 2 | 3 | ``` 4 | interface KerningRecord { 5 | left: Uint(16); 6 | right: Uint(16); 7 | adjustment: Sint(16); 8 | } 9 | ``` 10 | -------------------------------------------------------------------------------- /docs/text/text-alignment.md: -------------------------------------------------------------------------------- 1 | # TextAlignment 2 | 3 | ``` 4 | enum TextAlignment { 5 | Left; 6 | Right; 7 | Center; 8 | Justify; 9 | } 10 | ``` 11 | -------------------------------------------------------------------------------- /docs/text/text-record.md: -------------------------------------------------------------------------------- 1 | # TextRecord 2 | 3 | ``` 4 | interface TextRecord { 5 | fontId: Option(Uint(16)); 6 | color: Option(StraightSRgba8); 7 | offsetX: Sint(16); 8 | offsetY: Sint(16); 9 | fontSize: Option(Uint(16)); 10 | entries: GlyphEntry[]; 11 | } 12 | ``` 13 | -------------------------------------------------------------------------------- /docs/text/text-renderer.md: -------------------------------------------------------------------------------- 1 | # TextRenderer 2 | 3 | ``` 4 | enum TextRenderer { 5 | Normal; 6 | Advanced; 7 | } 8 | ``` 9 | -------------------------------------------------------------------------------- /docs/vector-2d.md: -------------------------------------------------------------------------------- 1 | # Vector2D 2 | 3 | Vector in the 2D space. 4 | 5 | ``` 6 | interface Vector2D { 7 | x: Sint(32); 8 | y: Sint(32); 9 | } 10 | ``` 11 | -------------------------------------------------------------------------------- /rs/.gitignore: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Editor # 3 | ############################################################################### 4 | # JetBrains (Webstorm, IntelliJ IDEA, ...) 5 | .idea/ 6 | *.iml 7 | 8 | # Komodo 9 | *.komodoproject 10 | .komodotools 11 | 12 | ############################################################################### 13 | # Build # 14 | ############################################################################### 15 | /target/ 16 | 17 | ############################################################################### 18 | # Temporary files # 19 | ############################################################################### 20 | *.log 21 | *.tmp 22 | tmp/ 23 | logs/ 24 | 25 | ############################################################################### 26 | # Other # 27 | ############################################################################### 28 | # Runtime data 29 | pids 30 | *.pid 31 | *.seed 32 | -------------------------------------------------------------------------------- /rs/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "swf-types" 3 | version = "0.14.0" 4 | authors = ["Charles Samborski "] 5 | description = "Type definitions for the SWF file format" 6 | documentation = "https://github.com/open-flash/swf-types" 7 | homepage = "https://github.com/open-flash/swf-types" 8 | repository = "https://github.com/open-flash/swf-types" 9 | readme = "./README.md" 10 | keywords = ["ast", "swf"] 11 | license = "MIT/Apache-2.0" 12 | edition = "2021" 13 | rust-version = "1.60.0" 14 | 15 | [badges] 16 | travis-ci = { repository = "open-flash/swf-types", branch = "master" } 17 | 18 | [lib] 19 | name = "swf_types" 20 | path = "src/lib.rs" 21 | 22 | [dependencies] 23 | hex = { version = "0.4.3", optional = true } 24 | serde = { version = "1.0.137", optional = true, features = ["derive"] } 25 | swf-fixed = "0.1.5" 26 | 27 | [features] 28 | # Serialization is enabled by default. 29 | # Use `swf-types = { version = "...", default-features = false }` to disable it. 30 | default = ["serde"] 31 | 32 | # Adds implementation for `serde`'s `Serialiaze` and `Deserialize` traits. 33 | serde = ["dep:serde", "dep:hex"] 34 | 35 | [dev-dependencies] 36 | serde_json_v8 = "0.1.1" 37 | test-generator = "0.3.0" 38 | 39 | [workspace] 40 | members = ["bin"] 41 | -------------------------------------------------------------------------------- /rs/LICENSE-MIT.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright © 2017-2019 Charles Samborski 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /rs/README.md: -------------------------------------------------------------------------------- 1 | 2 | Open Flash logo 4 | 5 | 6 | # SWF Types (Rust) 7 | 8 | [![crates.io](https://img.shields.io/crates/v/swf-types.svg)](https://crates.io/crates/swf-types) 9 | [![GitHub repository](https://img.shields.io/badge/Github-open--flash%2Fswf--types-blue.svg)](https://github.com/open-flash/swf-types) 10 | [![Build status](https://img.shields.io/travis/com/open-flash/swf-types/master.svg)](https://travis-ci.com/open-flash/swf-types) 11 | 12 | Rust implementation of the SWF Abstract Syntax Tree (AST). 13 | -------------------------------------------------------------------------------- /rs/bin/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "swf-types-bin" 3 | version = "0.14.0" 4 | authors = ["Charles Samborski "] 5 | description = "Type definitions for the SWF file format" 6 | documentation = "https://github.com/open-flash/swf-types" 7 | homepage = "https://github.com/open-flash/swf-types" 8 | repository = "https://github.com/open-flash/swf-types" 9 | readme = "./README.md" 10 | keywords = ["ast", "swf"] 11 | license = "MIT/Apache-2.0" 12 | edition = "2021" 13 | 14 | [[bin]] 15 | name = "swf-types" 16 | path = "src/main.rs" 17 | 18 | [dependencies] 19 | serde_json_v8 = "^0.1.1" 20 | swf-types = { path = "../." } 21 | -------------------------------------------------------------------------------- /rs/bin/src/main.rs: -------------------------------------------------------------------------------- 1 | use swf_types::Movie; 2 | 3 | fn main() { 4 | let args: Vec = std::env::args().collect(); 5 | if args.len() < 2 { 6 | eprintln!("Missing input path"); 7 | return; 8 | } 9 | 10 | let file_path = &args[1]; 11 | let json_file = ::std::fs::File::open(file_path).expect("Failed to open file"); 12 | let reader = ::std::io::BufReader::new(json_file); 13 | let movie: Movie = serde_json_v8::from_reader(reader).expect("Failed to read value"); 14 | 15 | println!( 16 | "{}", 17 | serde_json_v8::to_string_pretty(&movie).expect("Failed to print value") 18 | ); 19 | } 20 | -------------------------------------------------------------------------------- /rs/clippy.toml: -------------------------------------------------------------------------------- 1 | # cargo clippy --all-targets --all-features -- -D warnings 2 | 3 | # (Using default config) 4 | -------------------------------------------------------------------------------- /rs/rustfmt.toml: -------------------------------------------------------------------------------- 1 | # cargo fmt --all 2 | max_width = 120 3 | tab_spaces = 2 4 | -------------------------------------------------------------------------------- /rs/src/control.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "serde")] 2 | use ::serde::{Deserialize, Serialize}; 3 | 4 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] 5 | #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 6 | pub struct AbcHeader { 7 | pub flags: u32, 8 | pub name: String, 9 | } 10 | 11 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] 12 | #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 13 | pub struct Label { 14 | pub frame: u32, 15 | pub name: String, 16 | } 17 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] 18 | #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 19 | pub struct Scene { 20 | pub offset: u32, 21 | pub name: String, 22 | } 23 | -------------------------------------------------------------------------------- /rs/src/float_is.rs: -------------------------------------------------------------------------------- 1 | pub trait Is { 2 | fn is(&self, other: &Self) -> bool; 3 | } 4 | 5 | impl Is for f32 { 6 | fn is(&self, other: &f32) -> bool { 7 | self.to_bits() == other.to_bits() 8 | } 9 | } 10 | 11 | impl Is for f64 { 12 | fn is(&self, other: &f64) -> bool { 13 | self.to_bits() == other.to_bits() 14 | } 15 | } 16 | 17 | impl Is for Vec { 18 | fn is(&self, other: &Self) -> bool { 19 | if self.len() != other.len() { 20 | return false; 21 | } 22 | for (i, left) in self.iter().enumerate() { 23 | if !left.is(&other[i]) { 24 | return false; 25 | } 26 | } 27 | true 28 | } 29 | } 30 | 31 | impl Is for [f32; 20] { 32 | fn is(&self, other: &Self) -> bool { 33 | for i in 0..20 { 34 | if !self[i].is(&other[i]) { 35 | return false; 36 | } 37 | } 38 | true 39 | } 40 | } 41 | 42 | #[cfg(test)] 43 | mod test_float_is { 44 | use super::Is; 45 | 46 | #[test] 47 | fn test_f32_is() { 48 | assert!(::std::f32::NAN.is(&::std::f32::NAN)) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /rs/src/gradient.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "serde")] 2 | use ::serde::{Deserialize, Serialize}; 3 | 4 | use crate::basic_types::StraightSRgba8; 5 | 6 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(rename_all = "PascalCase"))] 7 | #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 8 | pub enum GradientSpread { 9 | Pad, 10 | Reflect, 11 | Repeat, 12 | } 13 | 14 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(rename_all = "PascalCase"))] 15 | #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 16 | pub enum ColorSpace { 17 | SRgb, 18 | LinearRgb, 19 | } 20 | 21 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] 22 | #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 23 | pub struct ColorStop { 24 | pub ratio: u8, 25 | pub color: StraightSRgba8, 26 | } 27 | 28 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] 29 | #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 30 | pub struct MorphColorStop { 31 | pub ratio: u8, 32 | pub morph_ratio: u8, 33 | pub color: StraightSRgba8, 34 | pub morph_color: StraightSRgba8, 35 | } 36 | 37 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] 38 | #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 39 | pub struct Gradient { 40 | pub spread: GradientSpread, 41 | pub color_space: ColorSpace, 42 | pub colors: Vec, 43 | } 44 | 45 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] 46 | #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 47 | pub struct MorphGradient { 48 | pub spread: GradientSpread, 49 | pub color_space: ColorSpace, 50 | pub colors: Vec, 51 | } 52 | -------------------------------------------------------------------------------- /rs/src/image.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "serde")] 2 | use ::serde::{Deserialize, Serialize}; 3 | 4 | /// Supported image types 5 | /// 6 | /// - `x-swf-partial-jpeg`: JPEG file without Tables/Misc chunk. It has to be defined in a 7 | /// `DefineJpegTables` tag and injected in the first Start Of Frame (SOF) JPEG chunk. 8 | /// - `x-swf-jpeg3`: JPEG with alpha mask (see DefineBitsJPEG3) 9 | /// - `x-swf-jpeg4`: JPEG with alpha mask and deblocking (see DefineBitsJPEG4) 10 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] 11 | #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 12 | pub enum ImageType { 13 | #[cfg_attr(feature = "serde", serde(rename = "image/jpeg"))] 14 | Jpeg, 15 | #[cfg_attr(feature = "serde", serde(rename = "image/gif"))] 16 | Gif, 17 | #[cfg_attr(feature = "serde", serde(rename = "image/png"))] 18 | Png, 19 | #[cfg_attr(feature = "serde", serde(rename = "image/x-swf-partial-jpeg"))] 20 | SwfPartialJpeg, 21 | #[cfg_attr(feature = "serde", serde(rename = "image/x-swf-jpeg3"))] 22 | SwfJpeg3, 23 | #[cfg_attr(feature = "serde", serde(rename = "image/x-swf-jpeg4"))] 24 | SwfJpeg4, 25 | #[cfg_attr(feature = "serde", serde(rename = "image/x-swf-lossless1"))] 26 | SwfLossless1, 27 | #[cfg_attr(feature = "serde", serde(rename = "image/x-swf-lossless2"))] 28 | SwfLossless2, 29 | } 30 | -------------------------------------------------------------------------------- /rs/src/join_styles.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "serde")] 2 | use ::serde::{Deserialize, Serialize}; 3 | 4 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] 5 | #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 6 | pub struct Miter { 7 | pub limit: u16, 8 | } 9 | -------------------------------------------------------------------------------- /rs/src/movie.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "serde")] 2 | use ::serde::{Deserialize, Serialize}; 3 | 4 | use crate::basic_types::Rect; 5 | use crate::fixed::Ufixed8P8; 6 | use crate::Tag; 7 | 8 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(rename_all = "PascalCase"))] 9 | #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 10 | pub enum CompressionMethod { 11 | None, 12 | Deflate, 13 | Lzma, 14 | } 15 | 16 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] 17 | #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 18 | pub struct Header { 19 | /// SWF version 20 | pub swf_version: u8, 21 | // Frame size in twips 22 | pub frame_size: Rect, 23 | pub frame_rate: Ufixed8P8, 24 | pub frame_count: u16, 25 | } 26 | 27 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] 28 | #[derive(Clone, Debug, PartialEq, Eq)] 29 | pub struct Movie { 30 | pub header: Header, 31 | pub tags: Vec, 32 | } 33 | 34 | /// The signature is the part of the header that is not compressed 35 | #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] 36 | #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 37 | pub struct SwfSignature { 38 | /// The compression method used for the body of this SWF file 39 | pub compression_method: CompressionMethod, 40 | /// SWF version 41 | pub swf_version: u8, 42 | // Uncompressed SWF File length (including the header) 43 | pub uncompressed_file_length: usize, 44 | } 45 | -------------------------------------------------------------------------------- /rs/src/serde_buffer.rs: -------------------------------------------------------------------------------- 1 | use hex::FromHex; 2 | use serde::{Deserialize, Deserializer, Serializer}; 3 | 4 | /// Serializes `buffer` to a lowercase hex string. 5 | pub fn buffer_to_hex(buffer: &T, serializer: S) -> Result 6 | where 7 | T: AsRef<[u8]>, 8 | S: Serializer, 9 | { 10 | serializer.serialize_str(hex::encode(buffer).as_ref()) 11 | } 12 | 13 | /// Deserializes a lowercase hex string to a `Vec`. 14 | pub fn hex_to_buffer<'de, D>(deserializer: D) -> Result, D::Error> 15 | where 16 | D: Deserializer<'de>, 17 | { 18 | use serde::de::Error; 19 | String::deserialize(deserializer) 20 | .and_then(|string| Vec::from_hex(&string).map_err(|err| Error::custom(err.to_string()))) 21 | } 22 | 23 | pub fn optional_buffer_to_hex(buffer: &Option>, serializer: S) -> Result 24 | where 25 | S: Serializer, 26 | { 27 | use serde::Serialize; 28 | 29 | #[derive(Serialize)] 30 | struct Wrapper<'a>(#[serde(serialize_with = "buffer_to_hex")] &'a Vec); 31 | 32 | buffer.as_ref().map(Wrapper).serialize(serializer) 33 | } 34 | 35 | pub fn hex_to_optional_buffer<'de, D>(deserializer: D) -> Result>, D::Error> 36 | where 37 | D: Deserializer<'de>, 38 | { 39 | #[derive(Deserialize)] 40 | struct Wrapper(#[serde(deserialize_with = "hex_to_buffer")] Vec); 41 | 42 | let v = Option::deserialize(deserializer)?; 43 | Ok(v.map(|Wrapper(bytes)| bytes)) 44 | } 45 | -------------------------------------------------------------------------------- /rs/src/video.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "serde")] 2 | use ::serde::{Deserialize, Serialize}; 3 | 4 | #[cfg_attr( 5 | feature = "serde", 6 | derive(Serialize, Deserialize), 7 | serde(tag = "type", rename_all = "PascalCase") 8 | )] 9 | #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 10 | pub enum VideoCodec { 11 | None, 12 | Jpeg, 13 | Sorenson, 14 | Screen, 15 | Vp6, 16 | Vp6Alpha, 17 | Screen2, 18 | Avc, 19 | } 20 | 21 | #[cfg_attr( 22 | feature = "serde", 23 | derive(Serialize, Deserialize), 24 | serde(tag = "type", rename_all = "PascalCase") 25 | )] 26 | #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 27 | pub enum VideoDeblocking { 28 | PacketValue, 29 | Off, 30 | Level1, 31 | Level2, 32 | Level3, 33 | Level4, 34 | } 35 | -------------------------------------------------------------------------------- /ts/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "es2021": true 4 | }, 5 | "plugins": [ 6 | "@typescript-eslint", 7 | "simple-import-sort" 8 | ], 9 | "parser": "@typescript-eslint/parser", 10 | "extends": [ 11 | "eslint:recommended", 12 | "plugin:@typescript-eslint/eslint-recommended" 13 | ], 14 | "globals": {}, 15 | "ignorePatterns": [ 16 | "node_modules" 17 | ], 18 | "rules": { 19 | "block-scoped-var": "error", 20 | "curly": [ 21 | "error", 22 | "all" 23 | ], 24 | "dot-location": [ 25 | "error", 26 | "property" 27 | ], 28 | "eqeqeq": "error", 29 | "indent": [ 30 | "error", 31 | 2, 32 | { 33 | "SwitchCase": 1 34 | } 35 | ], 36 | "linebreak-style": [ 37 | "error", 38 | "unix" 39 | ], 40 | "no-duplicate-imports": "error", 41 | "no-eval": "error", 42 | "no-label-var": "error", 43 | "no-tabs": "error", 44 | "no-trailing-spaces": "error", 45 | "no-unused-vars": "off", 46 | "no-use-before-define": "off", 47 | "no-var": "error", 48 | "one-var-declaration-per-line": "error", 49 | "quotes": [ 50 | "error", 51 | "double" 52 | ], 53 | "semi": [ 54 | "error", 55 | "always" 56 | ], 57 | "semi-spacing": [ 58 | "error", 59 | { 60 | "before": false, 61 | "after": true 62 | } 63 | ], 64 | "simple-import-sort/imports": "error", 65 | "simple-import-sort/exports": "error", 66 | "space-before-blocks": [ 67 | "error", 68 | "always" 69 | ], 70 | "space-infix-ops": "error", 71 | "unicode-bom": [ 72 | "error", 73 | "never" 74 | ] 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /ts/.yarnrc.yml: -------------------------------------------------------------------------------- 1 | nodeLinker: pnp 2 | 3 | yarnPath: .yarn/releases/yarn-4.0.0-rc.4.cjs 4 | -------------------------------------------------------------------------------- /ts/LICENSE-MIT.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright © 2017-2019 Charles Samborski 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ts/README.md: -------------------------------------------------------------------------------- 1 | 2 | Open Flash logo 4 | 5 | 6 | # SWF Types (Typescript) 7 | 8 | [![npm](https://img.shields.io/npm/v/swf-types.svg)](https://www.npmjs.com/package/swf-types) 9 | [![GitHub repository](https://img.shields.io/badge/Github-open--flash%2Fswf--types-blue.svg)](https://github.com/open-flash/swf-types) 10 | [![Build status](https://img.shields.io/travis/com/open-flash/swf-types/master.svg)](https://travis-ci.com/open-flash/swf-types) 11 | 12 | Typescript implementation of the SWF Abstract Syntax Tree (AST). 13 | 14 | ## Usage 15 | 16 | ```shell 17 | # Run as a simple user 18 | npm install -S swf-types 19 | ``` 20 | 21 | ```typescript 22 | import {readFileString} from "fs"; 23 | import {Movie} from "swf-types"; 24 | 25 | // Deserialize 26 | const jsonString: string = readFileString("ast.json").toString("utf8"); 27 | const parsedJson: Movie.Json = JSON.parse(jsonString); 28 | const movie: Movie = Movie.Type.read("json", parsedJson); 29 | 30 | // Serialize 31 | const emittedJson: Movie.Json = Movie.Type.write("json", movie); 32 | console.log(JSON.stringify(jsonMovie, null, 2)); 33 | ``` 34 | -------------------------------------------------------------------------------- /ts/src/lib/blend-mode.mts: -------------------------------------------------------------------------------- 1 | import { CaseStyle } from "kryo"; 2 | import { TsEnumType } from "kryo/ts-enum"; 3 | 4 | export enum BlendMode { 5 | Normal, 6 | Layer, 7 | Multiply, 8 | Screen, 9 | Lighten, 10 | Darken, 11 | Difference, 12 | Add, 13 | Subtract, 14 | Invert, 15 | Alpha, 16 | Erase, 17 | Overlay, 18 | Hardlight, 19 | } 20 | 21 | export const $BlendMode: TsEnumType = new TsEnumType({ 22 | enum: BlendMode, 23 | changeCase: CaseStyle.PascalCase, 24 | }); 25 | -------------------------------------------------------------------------------- /ts/src/lib/button/button-cond-action.mts: -------------------------------------------------------------------------------- 1 | import { CaseStyle } from "kryo"; 2 | import { $Bytes } from "kryo/bytes"; 3 | import { RecordIoType, RecordType } from "kryo/record"; 4 | 5 | import { $ButtonCond, ButtonCond } from "./button-cond.mjs"; 6 | 7 | export interface ButtonCondAction { 8 | readonly conditions?: ButtonCond; 9 | readonly actions: Uint8Array; 10 | } 11 | 12 | export const $ButtonCondAction: RecordIoType = new RecordType({ 13 | properties: { 14 | conditions: {type: $ButtonCond, optional: true}, 15 | actions: {type: $Bytes}, 16 | }, 17 | changeCase: CaseStyle.SnakeCase, 18 | }); 19 | -------------------------------------------------------------------------------- /ts/src/lib/button/button-cond.mts: -------------------------------------------------------------------------------- 1 | import { CaseStyle } from "kryo"; 2 | import { $Boolean } from "kryo/boolean"; 3 | import { $Uint32 } from "kryo/integer"; 4 | import { RecordIoType, RecordType } from "kryo/record"; 5 | import { Uint32 } from "semantic-types"; 6 | 7 | export interface ButtonCond { 8 | idleToOverUp: boolean; 9 | overUpToIdle: boolean; 10 | overUpToOverDown: boolean; 11 | overDownToOverUp: boolean; 12 | overDownToOutDown: boolean; 13 | outDownToOverDown: boolean; 14 | outDownToIdle: boolean; 15 | idleToOverDown: boolean; 16 | overDownToIdle: boolean; 17 | keyPress?: Uint32; 18 | } 19 | 20 | export const $ButtonCond: RecordIoType = new RecordType({ 21 | properties: { 22 | idleToOverUp: {type: $Boolean}, 23 | overUpToIdle: {type: $Boolean}, 24 | overUpToOverDown: {type: $Boolean}, 25 | overDownToOverUp: {type: $Boolean}, 26 | overDownToOutDown: {type: $Boolean}, 27 | outDownToOverDown: {type: $Boolean}, 28 | outDownToIdle: {type: $Boolean}, 29 | idleToOverDown: {type: $Boolean}, 30 | overDownToIdle: {type: $Boolean}, 31 | keyPress: {type: $Uint32, optional: true}, 32 | }, 33 | changeCase: CaseStyle.SnakeCase, 34 | }); 35 | -------------------------------------------------------------------------------- /ts/src/lib/button/button-record.mts: -------------------------------------------------------------------------------- 1 | import { CaseStyle } from "kryo"; 2 | import { ArrayType } from "kryo/array"; 3 | import { $Boolean } from "kryo/boolean"; 4 | import { $Uint16 } from "kryo/integer"; 5 | import { RecordIoType, RecordType } from "kryo/record"; 6 | import { Uint16 } from "semantic-types"; 7 | 8 | import { $BlendMode, BlendMode } from "../blend-mode.mjs"; 9 | import { $ColorTransformWithAlpha, ColorTransformWithAlpha } from "../color-transform-with-alpha.mjs"; 10 | import { $Filter, Filter } from "../filter.mjs"; 11 | import { $Matrix, Matrix } from "../matrix.mjs"; 12 | 13 | export interface ButtonRecord { 14 | stateUp: boolean; 15 | stateOver: boolean; 16 | stateDown: boolean; 17 | stateHitTest: boolean; 18 | characterId: Uint16; 19 | depth: Uint16; 20 | matrix: Matrix; 21 | colorTransform: ColorTransformWithAlpha; 22 | filters: Filter[]; 23 | blendMode: BlendMode; 24 | } 25 | 26 | export const $ButtonRecord: RecordIoType = new RecordType({ 27 | properties: { 28 | stateUp: {type: $Boolean}, 29 | stateOver: {type: $Boolean}, 30 | stateDown: {type: $Boolean}, 31 | stateHitTest: {type: $Boolean}, 32 | characterId: {type: $Uint16}, 33 | depth: {type: $Uint16}, 34 | matrix: {type: $Matrix}, 35 | colorTransform: {type: $ColorTransformWithAlpha}, 36 | filters: {type: new ArrayType({itemType: $Filter, maxLength: Infinity})}, 37 | blendMode: {type: $BlendMode}, 38 | }, 39 | changeCase: CaseStyle.SnakeCase, 40 | }); 41 | -------------------------------------------------------------------------------- /ts/src/lib/button/button-sound.mts: -------------------------------------------------------------------------------- 1 | import { CaseStyle } from "kryo"; 2 | import { $Uint16 } from "kryo/integer"; 3 | import { RecordIoType, RecordType } from "kryo/record"; 4 | import { Uint16 } from "semantic-types"; 5 | 6 | import { $SoundInfo, SoundInfo } from "../sound/sound-info.mjs"; 7 | 8 | export interface ButtonSound { 9 | soundId: Uint16; 10 | soundInfo: SoundInfo; 11 | } 12 | 13 | export const $ButtonSound: RecordIoType = new RecordType({ 14 | properties: { 15 | soundId: {type: $Uint16}, 16 | soundInfo: {type: $SoundInfo}, 17 | }, 18 | changeCase: CaseStyle.SnakeCase, 19 | }); 20 | -------------------------------------------------------------------------------- /ts/src/lib/cap-style.mts: -------------------------------------------------------------------------------- 1 | import { CaseStyle } from "kryo"; 2 | import { TsEnumType } from "kryo/ts-enum"; 3 | 4 | export enum CapStyle { 5 | Round, 6 | None, 7 | Square, 8 | } 9 | 10 | export const $CapStyle: TsEnumType = new TsEnumType({ 11 | enum: CapStyle, 12 | changeCase: CaseStyle.PascalCase, 13 | }); 14 | -------------------------------------------------------------------------------- /ts/src/lib/clip-action.mts: -------------------------------------------------------------------------------- 1 | import { CaseStyle } from "kryo"; 2 | import { $Bytes } from "kryo/bytes"; 3 | import { $Uint8 } from "kryo/integer"; 4 | import { RecordIoType, RecordType } from "kryo/record"; 5 | import { Uint8 } from "semantic-types"; 6 | 7 | import { $ClipEventFlags, ClipEventFlags } from "./clip-event-flags.mjs"; 8 | 9 | export interface ClipAction { 10 | events: ClipEventFlags; 11 | keyCode?: Uint8; 12 | actions: Uint8Array; 13 | } 14 | 15 | export const $ClipAction: RecordIoType = new RecordType({ 16 | properties: { 17 | events: {type: $ClipEventFlags}, 18 | keyCode: {type: $Uint8, optional: true}, 19 | actions: {type: $Bytes}, 20 | }, 21 | changeCase: CaseStyle.SnakeCase, 22 | }); 23 | -------------------------------------------------------------------------------- /ts/src/lib/clip-event-flags.mts: -------------------------------------------------------------------------------- 1 | import { CaseStyle } from "kryo"; 2 | import { $Boolean } from "kryo/boolean"; 3 | import { RecordIoType, RecordType } from "kryo/record"; 4 | 5 | export interface ClipEventFlags { 6 | load: boolean; 7 | enterFrame: boolean; 8 | unload: boolean; 9 | mouseMove: boolean; 10 | mouseDown: boolean; 11 | mouseUp: boolean; 12 | keyDown: boolean; 13 | keyUp: boolean; 14 | data: boolean; 15 | initialize: boolean; 16 | press: boolean; 17 | release: boolean; 18 | releaseOutside: boolean; 19 | rollOver: boolean; 20 | rollOut: boolean; 21 | dragOver: boolean; 22 | dragOut: boolean; 23 | keyPress: boolean; 24 | construct: boolean; 25 | } 26 | 27 | export const $ClipEventFlags: RecordIoType = new RecordType({ 28 | properties: { 29 | keyUp: {type: $Boolean}, 30 | keyDown: {type: $Boolean}, 31 | mouseUp: {type: $Boolean}, 32 | mouseDown: {type: $Boolean}, 33 | mouseMove: {type: $Boolean}, 34 | unload: {type: $Boolean}, 35 | enterFrame: {type: $Boolean}, 36 | load: {type: $Boolean}, 37 | dragOver: {type: $Boolean}, 38 | rollOut: {type: $Boolean}, 39 | rollOver: {type: $Boolean}, 40 | releaseOutside: {type: $Boolean}, 41 | release: {type: $Boolean}, 42 | press: {type: $Boolean}, 43 | initialize: {type: $Boolean}, 44 | data: {type: $Boolean}, 45 | construct: {type: $Boolean}, 46 | keyPress: {type: $Boolean}, 47 | dragOut: {type: $Boolean}, 48 | }, 49 | changeCase: CaseStyle.SnakeCase, 50 | }); 51 | -------------------------------------------------------------------------------- /ts/src/lib/color-space.mts: -------------------------------------------------------------------------------- 1 | import { CaseStyle } from "kryo"; 2 | import { TsEnumType } from "kryo/ts-enum"; 3 | 4 | export enum ColorSpace { 5 | SRgb, 6 | LinearRgb, 7 | } 8 | 9 | export const $ColorSpace: TsEnumType = new TsEnumType({ 10 | enum: ColorSpace, 11 | changeCase: CaseStyle.PascalCase, 12 | }); 13 | -------------------------------------------------------------------------------- /ts/src/lib/color-stop.mts: -------------------------------------------------------------------------------- 1 | import { CaseStyle } from "kryo"; 2 | import { $Uint8 } from "kryo/integer"; 3 | import { RecordIoType, RecordType } from "kryo/record"; 4 | import { Uint8 } from "semantic-types"; 5 | 6 | import { $StraightSRgba8, StraightSRgba8 } from "./straight-s-rgba8.mjs"; 7 | 8 | export interface ColorStop { 9 | ratio: Uint8; 10 | color: StraightSRgba8; 11 | } 12 | 13 | export const $ColorStop: RecordIoType = new RecordType({ 14 | properties: { 15 | ratio: {type: $Uint8}, 16 | color: {type: $StraightSRgba8}, 17 | }, 18 | changeCase: CaseStyle.SnakeCase, 19 | }); 20 | -------------------------------------------------------------------------------- /ts/src/lib/color-transform-with-alpha.mts: -------------------------------------------------------------------------------- 1 | import { CaseStyle } from "kryo"; 2 | import { $Sint16 } from "kryo/integer"; 3 | import { RecordIoType, RecordType } from "kryo/record"; 4 | import { Sint16 } from "semantic-types"; 5 | 6 | import { $ColorTransform, ColorTransform } from "./color-transform.mjs"; 7 | import { Sfixed8P8 } from "./fixed-point/sfixed8p8.mjs"; 8 | 9 | export interface ColorTransformWithAlpha extends ColorTransform { 10 | alphaMult: Sfixed8P8; 11 | alphaAdd: Sint16; 12 | } 13 | 14 | // tslint:disable-next-line:max-line-length 15 | export const $ColorTransformWithAlpha: RecordIoType = new RecordType({ 16 | properties: { 17 | redMult: $ColorTransform.properties.redMult, 18 | greenMult: $ColorTransform.properties.greenMult, 19 | blueMult: $ColorTransform.properties.blueMult, 20 | alphaMult: {type: Sfixed8P8}, 21 | redAdd: $ColorTransform.properties.redAdd, 22 | greenAdd: $ColorTransform.properties.greenAdd, 23 | blueAdd: $ColorTransform.properties.blueAdd, 24 | alphaAdd: {type: $Sint16}, 25 | }, 26 | changeCase: CaseStyle.SnakeCase, 27 | }); 28 | -------------------------------------------------------------------------------- /ts/src/lib/color-transform.mts: -------------------------------------------------------------------------------- 1 | import { CaseStyle } from "kryo"; 2 | import { $Sint16 } from "kryo/integer"; 3 | import { RecordIoType, RecordType } from "kryo/record"; 4 | import { Sint16 } from "semantic-types"; 5 | 6 | import { Sfixed8P8 } from "./fixed-point/sfixed8p8.mjs"; 7 | 8 | export interface ColorTransform { 9 | redMult: Sfixed8P8; 10 | greenMult: Sfixed8P8; 11 | blueMult: Sfixed8P8; 12 | redAdd: Sint16; 13 | greenAdd: Sint16; 14 | blueAdd: Sint16; 15 | } 16 | 17 | export const $ColorTransform: RecordIoType = new RecordType(() => ({ 18 | properties: { 19 | redMult: {type: Sfixed8P8}, 20 | greenMult: {type: Sfixed8P8}, 21 | blueMult: {type: Sfixed8P8}, 22 | redAdd: {type: $Sint16}, 23 | greenAdd: {type: $Sint16}, 24 | blueAdd: {type: $Sint16}, 25 | }, 26 | changeCase: CaseStyle.SnakeCase, 27 | })); 28 | -------------------------------------------------------------------------------- /ts/src/lib/compression-method.mts: -------------------------------------------------------------------------------- 1 | import { CaseStyle } from "kryo"; 2 | import { TsEnumType } from "kryo/ts-enum"; 3 | 4 | export enum CompressionMethod { 5 | None, 6 | Deflate, 7 | Lzma, 8 | } 9 | 10 | export const $CompressionMethod: TsEnumType = new TsEnumType({ 11 | enum: CompressionMethod, 12 | changeCase: CaseStyle.PascalCase, 13 | }); 14 | -------------------------------------------------------------------------------- /ts/src/lib/control/abc-header.mts: -------------------------------------------------------------------------------- 1 | import { CaseStyle } from "kryo"; 2 | import { $Uint32 } from "kryo/integer"; 3 | import { RecordIoType, RecordType } from "kryo/record"; 4 | import { Ucs2StringType } from "kryo/ucs2-string"; 5 | import { Uint32 } from "semantic-types"; 6 | 7 | export interface AbcHeader { 8 | readonly flags: Uint32; 9 | readonly name: string; 10 | } 11 | 12 | export const $AbcHeader: RecordIoType = new RecordType({ 13 | properties: { 14 | flags: {type: $Uint32}, 15 | name: {type: new Ucs2StringType({maxLength: Infinity})}, 16 | }, 17 | changeCase: CaseStyle.SnakeCase, 18 | }); 19 | -------------------------------------------------------------------------------- /ts/src/lib/control/label.mts: -------------------------------------------------------------------------------- 1 | import { CaseStyle } from "kryo"; 2 | import { IntegerType } from "kryo/integer"; 3 | import { RecordIoType, RecordType } from "kryo/record"; 4 | import { Ucs2StringType } from "kryo/ucs2-string"; 5 | 6 | export interface Label { 7 | frame: number; 8 | name: string; 9 | } 10 | 11 | export const $Label: RecordIoType