Vendor things
This commit is contained in:
parent
5deceec006
commit
977e3c17e5
19434 changed files with 10682014 additions and 0 deletions
30
third-party/vendor/tiny-skia/examples/stroke.rs
vendored
Normal file
30
third-party/vendor/tiny-skia/examples/stroke.rs
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
use tiny_skia::*;
|
||||
|
||||
// Based on https://fiddle.skia.org/c/@compose_path
|
||||
|
||||
fn main() {
|
||||
let mut paint = Paint::default();
|
||||
paint.set_color_rgba8(0, 127, 0, 200);
|
||||
paint.anti_alias = true;
|
||||
|
||||
let path = {
|
||||
let mut pb = PathBuilder::new();
|
||||
const RADIUS: f32 = 250.0;
|
||||
const CENTER: f32 = 250.0;
|
||||
pb.move_to(CENTER + RADIUS, CENTER);
|
||||
for i in 1..8 {
|
||||
let a = 2.6927937 * i as f32;
|
||||
pb.line_to(CENTER + RADIUS * a.cos(), CENTER + RADIUS * a.sin());
|
||||
}
|
||||
pb.finish().unwrap()
|
||||
};
|
||||
|
||||
let mut stroke = Stroke::default();
|
||||
stroke.width = 6.0;
|
||||
stroke.line_cap = LineCap::Round;
|
||||
stroke.dash = StrokeDash::new(vec![20.0, 40.0], 0.0);
|
||||
|
||||
let mut pixmap = Pixmap::new(500, 500).unwrap();
|
||||
pixmap.stroke_path(&path, &paint, &stroke, Transform::identity(), None);
|
||||
pixmap.save_png("image.png").unwrap();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue