ruffle/swf
dependabot[bot] 5ea1076e35 build(deps): bump enum-map from 2.4.1 to 2.4.2
Bumps [enum-map](https://github.com/xfix/enum-map) from 2.4.1 to 2.4.2.
- [Release notes](https://github.com/xfix/enum-map/releases)
- [Changelog](https://github.com/xfix/enum-map/blob/master/CHANGELOG.md)
- [Commits](https://github.com/xfix/enum-map/compare/v2.4.1...v2.4.2)

---
updated-dependencies:
- dependency-name: enum-map
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-19 16:30:46 -08:00
..
examples swf: Use Fixed in more places 2021-05-30 21:24:03 -07:00
src chore: Fix `clippy::uninlined_format_args` lints 2022-12-15 08:59:38 +02:00
tests/swfs swf: Write a non-zero 'index' value for true/false/undefined/null default values 2022-08-15 12:30:10 -07:00
Cargo.toml build(deps): bump enum-map from 2.4.1 to 2.4.2 2022-12-19 16:30:46 -08:00
LICENSE-APACHE Merge swf-rs into ruffle repo 2019-10-02 17:25:30 -07:00
LICENSE-MIT Merge swf-rs into ruffle repo 2019-10-02 17:25:30 -07:00
README.md swf: Bump version to 0.2 2022-08-16 12:59:20 -07:00

README.md

swf

crates.io docs.rs

A Rust library for reading and writing the Adobe Flash SWF file format.

# Cargo.toml
[dependencies]
swf = "0.2"

Reading

use std::io::BufReader;
use std::fs::File;

let file = File::open("file.swf").unwrap();
let reader = BufReader::new(file);
let swf_buf = swf::decompress_swf(reader).unwrap();
let swf = swf::parse_swf(&swf_buf).unwrap();
println!("The SWF has {} frame(s).", swf.header.num_frames());
println!("The SWF has {} tag(s).", swf.tags.len());

Try cargo run --example reading in this repository to run this example.

Writing

use swf::*;
let header = Header {
    compression: Compression::Zlib,
    version: 6,
    stage_size: Rectangle {
        x_min: Twips::from_pixels(0.0), x_max: Twips::from_pixels(400.0),
        y_min: Twips::from_pixels(0.0), y_max: Twips::from_pixels(400.0)
    },
    frame_rate: Fixed8::from_f32(60.0),
    num_frames: 1,
};
let tags = [
    Tag::SetBackgroundColor(Color { r: 255, g: 0, b: 0, a: 255 }),
    Tag::ShowFrame
];
let file = std::fs::File::create("file.swf").unwrap();
let writer = std::io::BufWriter::new(file);
swf::write_swf(&header, &tags, writer).unwrap();

Try cargo run --example writing in this repository to run this example.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.