css-image 0.4.3

Library for rendering images from css
Documentation

css-image

Rust crate for rendering images from css

Build Status codecov

Features

Only px units are supported for now.

  • width/height
  • background-color, color
  • font-size, font-family, font-weight, font-style, content, text-align
  • margin
  • padding
  • * selector
  • border, border-radius, border-color, border-width, border-style
  • multiple selectors

Dependencies

  • cairo

Usage

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