Fix example in README

This commit is contained in:
Mike Welsh 2016-08-29 14:10:32 -07:00
parent a29fe29305
commit a3df1d8251
1 changed files with 20 additions and 17 deletions

View File

@ -13,11 +13,14 @@ swf = "0.1"
```rust
extern crate swf;
use std::io::BufReader;
use std::fs::File;
fn main() {
let mut f = try!(File::open("file.swf"));
let mut reader = BufReader::new(f);
let swf = swf::read_swf(reader);
println("The SWF has {} frames", swf.num_frames);
let f = File::open("file.swf").unwrap();
let reader = BufReader::new(f);
let swf = swf::read_swf(reader).unwrap();
println!("The SWF has {} frames", swf.num_frames);
}
```
@ -32,19 +35,19 @@ use swf::*;
fn main() {
let f = File::create("file.swf").unwrap();
let writer = BufWriter::new(f);
let swf = Swf {
version: 6,
compression: Compression::Zlib,
stage_size: Rectangle { x_min: 0f32, x_max: 400f32, y_min: 0f32, y_max: 400f32 },
frame_rate: 60f32,
num_frames: 1,
tags: vec![
Tag::SetBackgroundColor(Color { r: 255, g: 0, b: 0, a: 255 }),
Tag::ShowFrame
]
};
swf::write_swf(&swf, writer).unwrap();
let writer = BufWriter::new(f);
let swf = Swf {
version: 6,
compression: Compression::Zlib,
stage_size: Rectangle { x_min: 0f32, x_max: 400f32, y_min: 0f32, y_max: 400f32 },
frame_rate: 60f32,
num_frames: 1,
tags: vec![
Tag::SetBackgroundColor(Color { r: 255, g: 0, b: 0, a: 255 }),
Tag::ShowFrame
]
};
swf::write_swf(&swf, writer).unwrap();
}
```