-
-
Save torokati44/8e61f8553bb1c405d30f93740812db29 to your computer and use it in GitHub Desktop.
Regression test for https://github.com/RazrFalcon/tiny-skia/pull/91
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use tiny_skia::{Paint, PathBuilder, Pixmap, Stroke, Transform, LineJoin}; | |
fn main() { | |
let path_sharp = { | |
let mut pb = PathBuilder::new(); | |
pb.move_to(40.0, 155.0); | |
pb.cubic_to(98.0, 140.0, 99.0, 105.0, 100.0, 40.0); | |
pb.cubic_to(101.0, 105.0, 102.0, 140.0, 160.0, 160.0); | |
pb.finish().unwrap() | |
}; | |
let path_nearly180 = { | |
let mut pb = PathBuilder::new(); | |
pb.move_to(40.0, 155.0); | |
pb.cubic_to(95.0, 140.0, 100.0, 105.0, 100.0, 40.0); | |
pb.cubic_to(100.0, 105.0, 105.0, 140.0, 160.0, 160.0); | |
pb.finish().unwrap() | |
}; | |
let path_pivotline = { | |
let mut pb = PathBuilder::new(); | |
pb.move_to(0.0, 40.0); | |
pb.line_to(600.0, 40.0); | |
pb.finish().unwrap() | |
}; | |
let toprow = Transform::from_translate(0.0, 0.0); | |
let bottomrow = Transform::from_translate(0.0, 300.0); | |
let mut pixmap = Pixmap::new(900, 600).unwrap(); | |
let mut paint = Paint::default(); | |
paint.set_color_rgba8(255, 0, 0, 255); | |
let thin_stroke = Stroke::default(); | |
pixmap.stroke_path(&path_pivotline, &paint, &thin_stroke, toprow, None); | |
pixmap.stroke_path(&path_pivotline, &paint, &thin_stroke, bottomrow, None); | |
paint.set_color_rgba8(0, 128, 0, 255); | |
let mut miter = Stroke::default(); | |
miter.width = 10.0; | |
miter.line_join = LineJoin::Miter; | |
let mut miterclip_small = Stroke::default(); | |
miterclip_small.width = 10.0; | |
miterclip_small.line_join = LineJoin::MiterClip; | |
miterclip_small.miter_limit = 0.5; | |
let mut miterclip_medium = Stroke::default(); | |
miterclip_medium.width = 10.0; | |
miterclip_medium.line_join = LineJoin::MiterClip; | |
miterclip_medium.miter_limit = 2.5; | |
let mut miterclip_large = Stroke::default(); | |
miterclip_large.width = 10.0; | |
miterclip_large.line_join = LineJoin::MiterClip; | |
miterclip_large.miter_limit = 7.5; | |
pixmap.stroke_path(&path_sharp, &paint, &miter, toprow, None); | |
pixmap.stroke_path(&path_nearly180, &paint, &miter, bottomrow, None); | |
pixmap.stroke_path(&path_sharp, &paint, &miterclip_small, toprow.post_translate(150.0, 0.0), None); | |
pixmap.stroke_path(&path_nearly180, &paint, &miterclip_small, bottomrow.post_translate(150.0, 0.0), None); | |
pixmap.stroke_path(&path_sharp, &paint, &miterclip_medium, toprow.post_translate(300.0, 0.0), None); | |
pixmap.stroke_path(&path_nearly180, &paint, &miterclip_medium, bottomrow.post_translate(300.0, 0.0), None); | |
pixmap.stroke_path(&path_sharp, &paint, &miterclip_large, toprow.post_translate(450.0, 0.0), None); | |
pixmap.stroke_path(&path_nearly180, &paint, &miterclip_large, bottomrow.post_translate(450.0, 0.0), None); | |
pixmap.save_png("image.png").unwrap(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment