Improve handwriting disk-format and decoding
This commit is contained in:
@ -72,15 +72,11 @@ pub fn rasterize_onto<'a, Blend: BlendFn>(
|
||||
|
||||
// If the pixel is within the triangle, fill it in.
|
||||
if point_in_triangle.inside {
|
||||
let c0 = triangle[0]
|
||||
.color
|
||||
.linear_multiply(point_in_triangle.weights[0]);
|
||||
let c1 = triangle[1]
|
||||
.color
|
||||
.linear_multiply(point_in_triangle.weights[1]);
|
||||
let c2 = triangle[2]
|
||||
.color
|
||||
.linear_multiply(point_in_triangle.weights[2]);
|
||||
let [c0, c1, c2] = [0, 1, 2].map(|i| {
|
||||
triangle[i]
|
||||
.color
|
||||
.linear_multiply(point_in_triangle.weights[i])
|
||||
});
|
||||
|
||||
let color = c0 + c1 + c2;
|
||||
|
||||
@ -169,6 +165,12 @@ fn point_in_triangle(point: Pos2, triangle: [&Vertex; 3]) -> PointInTriangle {
|
||||
// Normalize the weights.
|
||||
let weights = areas.map(|area| area / triangle_area);
|
||||
|
||||
if cfg!(debug_assertions) {
|
||||
if weights.into_iter().any(f32::is_nan) {
|
||||
panic!("weights must not be NaN! {weights:?} {triangle_area:?} {areas:?} {sides:?}");
|
||||
}
|
||||
}
|
||||
|
||||
PointInTriangle { inside, weights }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user