Crates.io | css-image |
lib.rs | css-image |
version | 0.4.3 |
source | src |
created_at | 2024-03-30 13:48:40.98085 |
updated_at | 2024-05-22 19:11:53.49478 |
description | Library for rendering images from css |
homepage | |
repository | https://github.com/unixpariah/css-image |
max_upload_size | |
id | 1191095 |
size | 39,474 |
Rust crate for rendering images from css
Only px units are supported for now.
use css_image::render;
fn main() {
let css = r#"
body {
background-color: red;
width: 100px;
height: 100px;
}
"#;
let images = render(css).unwrap(); // Returns a hashmap of css selector -> Image
}
use css_image::{render, Styles};
let css = r#"
body {
background-color: red;
width: 100px;
height: 100px;
}
"#;
let mut styles = css.parse::<Styles>().unwrap(); // Parse css string to Styles for easier access
styles.get_mut("body").unwrap().content.replace("Hello world!".into()); // Set content of body to "Hello world!"
let images = render(styles).unwrap(); // Returns a hashmap of css selector -> Image