-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from keiya01/feat/impl-flex-direction-row
Feat/support `flex-direction: row;`
- Loading branch information
Showing
16 changed files
with
338 additions
and
103 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,78 @@ | ||
use og_image_writer::{style, writer::OGImageWriter}; | ||
use std::path::Path; | ||
|
||
fn main() -> anyhow::Result<()> { | ||
let text = "This is Open Graphic Image Writer for Web Developer."; | ||
|
||
let mut container = OGImageWriter::new(style::WindowStyle { | ||
width: 500, | ||
height: 250, | ||
background_color: Some(style::Rgba([70, 40, 90, 255])), | ||
align_items: style::AlignItems::Center, | ||
justify_content: style::JustifyContent::Center, | ||
..style::WindowStyle::default() | ||
})?; | ||
|
||
let font = Vec::from(include_bytes!("../fonts/Mplus1-Black.ttf") as &[u8]); | ||
|
||
container.set_text( | ||
text, | ||
style::Style { | ||
margin: style::Margin(0, 10, 0, 10), | ||
line_height: 1.5, | ||
font_size: 80., | ||
word_break: style::WordBreak::Normal, | ||
color: style::Rgba([255, 255, 255, 255]), | ||
text_align: style::TextAlign::Start, | ||
text_overflow: style::TextOverflow::Ellipsis, | ||
max_height: Some(200), | ||
..style::Style::default() | ||
}, | ||
font, | ||
)?; | ||
|
||
let mut writer = OGImageWriter::new(style::WindowStyle { | ||
width: 1024, | ||
height: 512, | ||
background_color: Some(style::Rgba([255, 255, 255, 255])), | ||
align_items: style::AlignItems::Center, | ||
justify_content: style::JustifyContent::Center, | ||
flex_direction: style::FlexDirection::Row, | ||
..style::WindowStyle::default() | ||
})?; | ||
|
||
writer.set_container( | ||
&mut container, | ||
style::Style { | ||
margin: style::Margin(0, 10, 0, 10), | ||
text_align: style::TextAlign::Center, | ||
border_radius: style::BorderRadius(10, 10, 10, 10), | ||
..style::Style::default() | ||
}, | ||
)?; | ||
|
||
let font = Vec::from(include_bytes!("../fonts/Mplus1-Black.ttf") as &[u8]); | ||
|
||
writer.set_text( | ||
"This is Open Graphic Image Writer for Web Developer.", | ||
style::Style { | ||
margin: style::Margin(0, 20, 0, 20), | ||
line_height: 1.8, | ||
font_size: 100., | ||
word_break: style::WordBreak::Normal, | ||
color: style::Rgba([0, 0, 0, 255]), | ||
text_align: style::TextAlign::Center, | ||
max_width: Some(500), | ||
max_height: Some(400), | ||
..style::Style::default() | ||
}, | ||
font, | ||
)?; | ||
|
||
let out_dir = "./examples/assets"; | ||
let out_filename = "output_row_container.png"; | ||
|
||
writer.generate(Path::new(&format!("{}/{}", out_dir, out_filename)))?; | ||
|
||
Ok(()) | ||
} |
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
Oops, something went wrong.