rough_piet

Crates.io Documentation License

This crate is an adapter crate between roughr and piet crates. Converts from roughr drawing primitives to piets path types. Also has convenience traits for drawing onto piet contexts. For more detailed information you can check roughr crate.

Below examples are output of rough_piet adapter.

📦 Cargo.toml

toml [dependencies] rough_piet = "0.1"

🔧 Example

Rectangle

```rust let options = OptionsBuilder::default() .stroke(Srgba::fromraw(&[114u8, 87u8, 82u8, 255u8]).intoformat()) .fill(Srgba::fromraw(&[254u8, 246u8, 201u8, 255u8]).intoformat()) .fillstyle(FillStyle::Hachure) .fillweight(DPI * 0.01) .build() .unwrap(); let generator = KurboGenerator::new(options); let rectwidth = 100.0; let rectheight = 50.0; let rect = generator.rectangle::( (WIDTH as f32 - rectwidth) / 2.0, (HEIGHT as f32 - rectheight) / 2.0, rectwidth, rectheight, ); let backgroundcolor = Color::fromhex_str("96C0B7").unwrap();

rc.fill( Rect::new(0.0, 0.0, WIDTH as f64, HEIGHT as f64), &background_color, ); rect.draw(&mut rc); ```

🖨️ Output Rectangle

rectangle

Circle

```rust let options = OptionsBuilder::default() .stroke(Srgba::fromraw(&[114u8, 87u8, 82u8, 255u8]).intoformat()) .fill(Srgba::fromraw(&[254u8, 246u8, 201u8, 255u8]).intoformat()) .fillstyle(FillStyle::Hachure) .fillweight(DPI * 0.01) .build() .unwrap(); let generator = KurboGenerator::new(options); let circlepaths = generator.circle::( (WIDTH as f32) / 2.0, (HEIGHT as f32) / 2.0, HEIGHT as f32 - 10.0f32, ); let backgroundcolor = Color::fromhexstr("96C0B7").unwrap();

rc.fill( Rect::new(0.0, 0.0, WIDTH as f64, HEIGHT as f64), &backgroundcolor, ); circlepaths.draw(&mut rc); ```

🖨️ Output Circle

circle

Ellipse

```rust let options = OptionsBuilder::default() .stroke(Srgba::fromraw(&[114u8, 87u8, 82u8, 255u8]).intoformat()) .fill(Srgba::fromraw(&[254u8, 246u8, 201u8, 255u8]).intoformat()) .fillstyle(FillStyle::Hachure) .fillweight(DPI * 0.01) .build() .unwrap(); let generator = KurboGenerator::new(options); let ellipsepaths = generator.ellipse::( (WIDTH as f32) / 2.0, (HEIGHT as f32) / 2.0, WIDTH as f32 - 10.0, HEIGHT as f32 - 10.0, ); let backgroundcolor = Color::fromhexstr("96C0B7").unwrap();

rc.fill( Rect::new(0.0, 0.0, WIDTH as f64, HEIGHT as f64), &backgroundcolor, ); ellipsepaths.draw(&mut rc); ```

🖨️ Output Ellipse

ellipse

Svg Path

```rust let options = OptionsBuilder::default() .stroke(Srgba::fromraw(&[114u8, 87u8, 82u8, 255u8]).intoformat()) .fill(Srgba::fromraw(&[254u8, 246u8, 201u8, 255u8]).intoformat()) .fillstyle(FillStyle::Hachure) .fillweight(DPI * 0.01) .build() .unwrap(); let generator = KurboGenerator::new(options); let heartsvgpath = "M140 20C73 20 20 74 20 140c0 135 136 170 228 303 88-132 229-173 229-303 0-66-54-120-120-120-48 0-90 28-109 69-19-41-60-69-108-69z".into(); let heartsvgpathdrawing = generator.path::(heartsvgpath); let backgroundcolor = Color::fromhexstr("96C0B7").unwrap();

rc.fill( Rect::new(0.0, 0.0, WIDTH as f64, HEIGHT as f64), &backgroundcolor, ); heartsvgpathdrawing.draw(&mut rc); ```

🖨️ Output Svg Path

svgheart

Filler Implementation Status

🔭 Examples

For more examples have a look at the examples folder.

📝 License

Licensed under MIT License (LICENSE).

🚧 Contributions

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the MIT license, shall be licensed as above, without any additional terms or conditions.