Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
416 changes: 372 additions & 44 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ members = [
"crates/pixels_window_renderer",
"crates/softbuffer_window_renderer",
"examples/player",
"crates/rough_anyrender",
"examples/bunnymark",
"examples/serialize",
]
Expand Down
28 changes: 28 additions & 0 deletions crates/rough_anyrender/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "rough_anyrender"
version = "0.1.0"
edition = "2021"
authors = ["orhanbalci@gmail.com <orhanbalci@gmail.com>"]
description = "Draw Hand Sketched 2D Drawings Using Vello"
repository = "https://github.com/orhanbalci/rough-rs.git"
homepage = "https://github.com/orhanbalci"
keywords = ["graphics", "bezier", "sketch", "2D", "vello"]
categories = ["graphics"]
license = "MIT"
readme = "README.md"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyrender = { workspace = true }
kurbo = { workspace = true }
peniko = { workspace = true }
roughr = { version = "0.12.0" }
num-traits = "0.2"
euclid = "0.22"
palette = "0.7"

[dev-dependencies]
anyrender_vello_hybrid = { workspace = true }
winit = { workspace = true }
svg_path_ops = { version = "0.11.0" }
90 changes: 90 additions & 0 deletions crates/rough_anyrender/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# rough_anyrender

[![Crates.io](https://img.shields.io/crates/v/rough_vello.svg)](https://crates.io/crates/rough_vello)
[![Documentation](https://docs.rs/rough_vello/badge.svg)](https://docs.rs/rough_vello)
[![License](https://img.shields.io/github/license/orhanbalci/rough-rs.svg)](https://github.com/orhanbalci/rough-rs/LICENSE)

<!-- cargo-sync-readme start -->


This crate is an adapter crate between [roughr](https://github.com/orhanbalci/rough-rs/tree/main/roughr) and
[anyrender](https://github.com/dioxuslabs/anyrender). It converts roughr drawing
primitives into calls on AnyRender's `PaintScene`, so hand-sketched shapes can be
rendered with any AnyRender backend. For more detailed information you can check the
roughr crate.

## 📦 Cargo.toml

```toml
[dependencies]
rough_anyrender = "0.1"
# Plus any AnyRender backend, e.g.:
anyrender_vello_hybrid = "0.8"
```

## 🔧 Example

### Rust Logo

```rust
use anyrender::{PaintScene, Scene};
use palette::Srgba;
use rough_anyrender::VelloGenerator;
use roughr::core::{FillStyle, OptionsBuilder};

let options = OptionsBuilder::default()
.stroke(Srgba::from_components((114u8, 87u8, 82u8, 255u8)).into_format())
.fill(Srgba::from_components((254u8, 246u8, 201u8, 255)).into_format())
.fill_style(FillStyle::Hachure)
.fill_weight(1.0)
.bowing(0.8)
.build()
.unwrap();

let generator = VelloGenerator::new(options);
let rust_logo_svg_path = "..."; // SVG path data for the Rust logo
let rust_logo_drawing = generator.path::<f32>(rust_logo_svg_path.to_string());

// `draw` accepts any `anyrender::PaintScene`. Here we record into a `Scene`, but you
// can also draw straight into the scene painter handed to a `WindowRenderer::render`
// closure (see the examples).
let mut scene = Scene::new();
rust_logo_drawing.draw(&mut scene);
```

### 🖨️ Output Rust Logo
![rust_logo](https://raw.githubusercontent.com/orhanbalci/rough-rs/main/rough_vello/assets/rust_logo.png)

## Filler Implementation Status
- [x] Hachure
- [x] Zigzag
- [x] Cross-Hatch
- [x] Dots
- [x] Dashed
- [x] Zigzag-Line

## 🔭 Examples

Runnable [winit](https://docs.rs/winit) examples live in the `examples/` directory
(`rectangle`, `rust_logo` and `animate`). Run one with, for example:

```sh
cargo run --example rust_logo
```

## 🔌 Integration

Because drawing targets AnyRender's `PaintScene`, `rough_anyrender` works with any
AnyRender backend, including `anyrender_vello`, `anyrender_vello_hybrid`,
`anyrender_vello_cpu` and `anyrender_skia`. The bundled examples use
`anyrender_vello_hybrid` together with `winit`.

<!-- cargo-sync-readme end -->

## 📝 License

Licensed under MIT License ([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.
Binary file added crates/rough_anyrender/assets/rust_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading