ruffle/swf
dependabot-preview[bot] c3c82ffbe4 build(deps): bump num-derive from 0.2.5 to 0.3.0
Bumps [num-derive](https://github.com/rust-num/num-derive) from 0.2.5 to 0.3.0.
- [Release notes](https://github.com/rust-num/num-derive/releases)
- [Changelog](https://github.com/rust-num/num-derive/blob/master/RELEASES.md)
- [Commits](https://github.com/rust-num/num-derive/compare/num-derive-0.2.5...num-derive-0.3.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-11-22 17:13:32 +00:00
..
examples swf: cargo fmt 2019-10-03 00:46:38 -07:00
src swf: Store register count from DefineFunction2 2019-10-15 17:09:14 -07:00
tests/swfs chore: Renormalize line endings in misc files 2019-10-11 16:53:36 -07:00
Cargo.toml build(deps): bump num-derive from 0.2.5 to 0.3.0 2019-11-22 17:13:32 +00: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: Remove stale build badge from README 2019-10-03 02:31:11 -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.1"

Reading

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

let file = File::open("file.swf").unwrap();
let reader = BufReader::new(file);
let swf = swf::read_swf(reader).unwrap();
println!("The SWF has {} frames", swf.header.num_frames);

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

Writing

use swf::*;
let swf = Swf {
    header: Header {
        version: 6,
        compression: Compression::Zlib,
        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: 60.0,
        num_frames: 1,
    },
    tags: vec![
        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(&swf, 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.