Skip to content
프로젝트

소개

draw handy sketches from your rust applications

디자인 및 미디어

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
+1
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

rough-rs

rustroughlogo

roughtext

This repository contains a set of crates which in result resembles functionality in Rough.js

🚀 Quick Start

roughr generates the sketchy shapes; an adapter crate draws them with your graphics library. With rough_tiny_skia, drawing to a PNG looks like this:

[dependencies]
roughr = "0.14"
rough_tiny_skia = "0.14"
palette = "0.7"
tiny-skia = "0.11"
use palette::Srgba;
use rough_tiny_skia::SkiaGenerator;
use roughr::core::{FillStyle, OptionsBuilder};
use tiny_skia::Pixmap;

fn main() {
    let options = OptionsBuilder::default()
        .stroke(Srgba::from_components((114u8, 87u8, 82u8, 255u8)).into_format())
        .fill(Srgba::from_components((254u8, 246u8, 201u8, 255u8)).into_format())
        .fill_style(FillStyle::Hachure)
        .fill_weight(1.0)
        .roughness(1.5)
        .build()
        .unwrap();
    let generator = SkiaGenerator::new(options);

    let mut pixmap = Pixmap::new(300, 200).unwrap();
    pixmap.fill(tiny_skia::Color::from_rgba8(150, 192, 183, 255));
    generator.rectangle::<f32>(50.0, 50.0, 200.0, 100.0).draw(&mut pixmap.as_mut());
    generator.circle::<f32>(150.0, 100.0, 60.0).draw(&mut pixmap.as_mut());
    pixmap.save_png("sketch.png").unwrap();
}

The other adapters work the same way: build Options, create the adapter's generator, then draw the shapes it returns.

🎛️ Options

Options controls how every shape is sketched. All fields have defaults, so set only what you want to change. Each image draws the same shape with one option changed, from left to right.

roughness

fill_style

All options

bowing

max_randomness_offset

stroke_width

disable_multi_stroke

preserve_vertices

stroke_line_dash

seed

curve_fitting

curve_step_count

curve_tightness

simplification

hachure_angle

hachure_gap

fill_weight

dash_offset

dash_gap

zigzag_offset

disable_multi_stroke_fill

Every option and its default is described in the Options docs. To try them interactively, run the drawing_app example: cargo run -p rough_iced --example drawing_app.

🧾 Drawing SVG Files

roughr can sketch SVG path data, and with usvg whole SVG files, including shapes like <rect> and <circle>, transforms and colors:

svg

cargo run -p rough_tiny_skia --example svg -- input.svg output.png

See the svg example and the roughr docs for how it works.

📦 Crate Versions

The table below shows the current version of each crate and the versions of the other workspace crates it depends on. A — means there is no dependency.

Crate Version points_on_curve svg_path_ops roughr
points_on_curve 0.7.0 — — —
svg_path_ops 0.12.0 — — —
roughr 0.14.0 0.7.0 0.12.0 —
rough_piet 0.15.0 — 0.12.0 0.14.0
rough_tiny_skia 0.14.1 — 0.12.0 0.14.0
rough_vello 0.16.0 — 0.12.0 0.14.0
rough_iced 0.15.0 — 0.12.0 0.14.0
rough_plotters_svg 0.3.0 — — 0.14.0

Dependency requirements use Cargo's default caret semantics, so a requirement of 0.11.0 resolves to any 0.11.x — the svg_path_ops 0.11.1 bug-fix release is picked up automatically without republishing the dependent crates.

📝 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.

관련 프로젝트 살펴보기

불러오는 중…