const STROKE_WIDTH: usize = 0;// A custom vertex constructor for collecting the output of the stroke tessellator.struct VariableWidthStrokeCtor;impl StrokeVertexConstructor<[f32; 2]> for VariableWidthStrokeCtor { fn new_vertex(&mut self, mut vertex: StrokeVertex) -> [f32; 2] { // Grab the width. The tessellator automatically (and lazily) did the work of
// interpolating the custom attributes
let width = vertex.interpolated_attributes()[STROKE_WIDTH]; // Instead of using `vertex.position()` compute the adjusted position manually.
let position = vertex.position_on_path() + vertex.normal() * width * 0.5;
position.to_array()
}
}// Create a path with one custom attribute per endpoint.let mut builder = Path::builder_width_attributes(1);
builder.begin(point(40.0, 100.0), &[5.0]);
builder.line_to(point(80.0, 20.0), &[30.0]);
builder.cubic_bezier_to(point(100.0, 220.0), point(150.0, 50.0), point(250.0, 100.0), &[2.0]);
builder.line_to(point(200.0, 50.0), &[40.0]);
builder.end(false);let path = builder.build();let mut geometry: VertexBuffers<[f32; 2], u16> = VertexBuffers::new();
stroke_tessellator.tessellate_path(
&path,
&StrokeOptions::tolerance(0.01).with_line_caps(LineCap::Round),
&mut BuffersBuilder::new(
&mut geometry,
VariableWidthStrokeCtor,
),
);

原文链接:https://nical.github.io/posts/lyon-1-0.html
fe2o3-amqp 是一个基于 serde 和 tokio 的AMQP 1.0协议的一个完整实现。原文作者:Rust语言中文社区;如有侵权,请联系管理员删除。