mirror of
https://github.com/hannobraun/Fornjot
synced 2025-02-15 11:45:54 +00:00
Merge pull request #458 from hannobraun/math
Remove `color` field from `fj_math::Triangle`
This commit is contained in:
commit
0367e161cb
@ -8,7 +8,6 @@ use super::{Point, Scalar};
|
|||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct Triangle<const D: usize> {
|
pub struct Triangle<const D: usize> {
|
||||||
points: [Point<D>; 3],
|
points: [Point<D>; 3],
|
||||||
color: [u8; 4],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<const D: usize> Triangle<D> {
|
impl<const D: usize> Triangle<D> {
|
||||||
@ -25,10 +24,7 @@ impl<const D: usize> Triangle<D> {
|
|||||||
|
|
||||||
// A triangle is not valid if it doesn't span any area
|
// A triangle is not valid if it doesn't span any area
|
||||||
if area != Scalar::from(0.0) {
|
if area != Scalar::from(0.0) {
|
||||||
Self {
|
Self { points }
|
||||||
points,
|
|
||||||
color: [255, 0, 0, 255],
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
panic!("Invalid Triangle specified");
|
panic!("Invalid Triangle specified");
|
||||||
}
|
}
|
||||||
@ -39,11 +35,6 @@ impl<const D: usize> Triangle<D> {
|
|||||||
self.points
|
self.points
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the specified color of the triangle in RGBA
|
|
||||||
pub fn color(&self) -> [u8; 4] {
|
|
||||||
self.color
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Normalize the triangle
|
/// Normalize the triangle
|
||||||
///
|
///
|
||||||
/// Returns a new `Triangle` instance with the same points, but the points
|
/// Returns a new `Triangle` instance with the same points, but the points
|
||||||
@ -56,11 +47,6 @@ impl<const D: usize> Triangle<D> {
|
|||||||
self.points.sort();
|
self.points.sort();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set a new color for the particular triangle
|
|
||||||
pub fn set_color(&mut self, color: [u8; 4]) {
|
|
||||||
self.color = color;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Triangle<3> {
|
impl Triangle<3> {
|
||||||
@ -119,23 +105,4 @@ mod tests {
|
|||||||
let c = Point::from([2.0, 2.0, 2.0]);
|
let c = Point::from([2.0, 2.0, 2.0]);
|
||||||
let _triangle = Triangle::from([a, b, c]);
|
let _triangle = Triangle::from([a, b, c]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn triangle_default_color() {
|
|
||||||
let a = Point::from([0.0, 0.0]);
|
|
||||||
let b = Point::from([1.0, 1.0]);
|
|
||||||
let c = Point::from([1.0, 2.0]);
|
|
||||||
let triangle = Triangle::from([a, b, c]);
|
|
||||||
assert_eq!(triangle.color(), [255, 0, 0, 255]);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn triangle_set_color() {
|
|
||||||
let a = Point::from([0.0, 0.0]);
|
|
||||||
let b = Point::from([1.0, 1.0]);
|
|
||||||
let c = Point::from([1.0, 2.0]);
|
|
||||||
let mut triangle = Triangle::from([a, b, c]);
|
|
||||||
triangle.set_color([1, 2, 3, 4]);
|
|
||||||
assert_eq!(triangle.color(), [1, 2, 3, 4]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user