-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add in logging. - Update CHANGELOG - Reduce amount of extra space vertical used I had `line_spacing` set to 1.75 because I was going to use the program for proof-reading. That's fine, but because of how the program internals work, setting `line_spacing` to anything other than 1.0 causes pictures to take up and inordinate amount of space. I'll make it configurable from the command line later. - Added some vertical space beneath headers, so that the characters wouldn't collide with regular text. - Update to latest version of `printpdf`
- Loading branch information
Showing
9 changed files
with
174 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,5 @@ printpdf = "*" | |
rusttype = "*" | ||
failure = "*" | ||
scraper = "*" | ||
image = "*" | ||
log = "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use failure::Error; | ||
use image::{self, DynamicImage}; | ||
use std::collections::BTreeMap; | ||
use std::path::{Path, PathBuf}; | ||
|
||
pub struct Resources { | ||
root_path: PathBuf, | ||
images: BTreeMap<PathBuf, DynamicImage>, | ||
} | ||
|
||
impl Resources { | ||
pub fn new(root_path: PathBuf) -> Self { | ||
Self { | ||
root_path: root_path, | ||
images: BTreeMap::new(), | ||
} | ||
} | ||
|
||
pub fn load_image<P: AsRef<Path>>(&mut self, path: P) -> Result<&DynamicImage, Error> { | ||
let filename = self.root_path.join(path); | ||
if self.images.contains_key(&filename) { | ||
let image = self | ||
.images | ||
.get(&filename) | ||
.expect("BTreeMap said it contained the key"); | ||
Ok(image) | ||
} else { | ||
let image = image::open(&filename)?; | ||
self.images.insert(filename.clone(), image); | ||
let image = self | ||
.images | ||
.get(&filename) | ||
.expect("I just inserted the key into the map"); | ||
Ok(image) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters