[FEAT] Pattern: Add others pattern
This commit is contained in:
@@ -393,3 +393,122 @@ SCENARIO("A pattern with both an object and a pattern transformation", "[feature
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
SCENARIO("A gradient linearly interpolates between colors", "[features/patterns.feature]")
|
||||
{
|
||||
GIVEN("pattern <- gradient_pattern(white, black)")
|
||||
{
|
||||
GradientPattern pattern(Color::White(), Color::Black());
|
||||
THEN("pattern_at(pattern, point(0, 0, 0)) == white")
|
||||
{
|
||||
REQUIRE(pattern.pattern_at(Tuple::Point(0, 0, 0)) == Color::White());
|
||||
}
|
||||
AND_THEN("pattern_at(pattern, point(0.25, 0, 0)) == color(0.75, 0.75, 0.75)")
|
||||
{
|
||||
REQUIRE(pattern.pattern_at(Tuple::Point(0.25, 0, 0)) == Color(0.75, 0.75, 0.75));
|
||||
}
|
||||
AND_THEN("pattern_at(pattern, point(0.5, 0, 0)) == color(0.5, 0.5, 0.5)")
|
||||
{
|
||||
REQUIRE(pattern.pattern_at(Tuple::Point(0.5, 0, 0)) == Color(0.5, 0.5, 0.5));
|
||||
}
|
||||
AND_THEN("pattern_at(pattern, point(0.75, 0, 0)) == color(0,25, 0.25, 0.25)")
|
||||
{
|
||||
REQUIRE(pattern.pattern_at(Tuple::Point(0.75, 0, 0)) == Color(0.25, 0.25, 0.25));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
SCENARIO("A ring should extend in both x and z", "[features/patterns.feature]")
|
||||
{
|
||||
GIVEN("pattern <- ring_pattern(white, black)")
|
||||
{
|
||||
RingPattern pattern(Color::White(), Color::Black());
|
||||
THEN("pattern_at(pattern, point(0, 0, 0)) == white")
|
||||
{
|
||||
REQUIRE(pattern.pattern_at(Tuple::Point(0, 0, 0)) == Color::White());
|
||||
}
|
||||
AND_THEN("pattern_at(pattern, point(1, 0, 0)) == black")
|
||||
{
|
||||
REQUIRE(pattern.pattern_at(Tuple::Point(1, 0, 0)) == Color::Black());
|
||||
}
|
||||
AND_THEN("pattern_at(pattern, point(0, 0, 1)) == black")
|
||||
{
|
||||
REQUIRE(pattern.pattern_at(Tuple::Point(0, 0, 1)) == Color::Black());
|
||||
}
|
||||
// 0.708 = just slightly more than sqrt(2)2
|
||||
AND_THEN("pattern_at(pattern, point(0.708, 0, 0.708)) == black")
|
||||
{
|
||||
REQUIRE(pattern.pattern_at(Tuple::Point(0.708, 0, 0.708)) == Color::Black());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
SCENARIO("Checkers should repeat in x", "[features/patterns.feature]")
|
||||
{
|
||||
GIVEN("pattern <- checkers_pattern(white, black)")
|
||||
{
|
||||
CheckersPattern pattern(Color::White(), Color::Black());
|
||||
THEN("pattern_at(pattern, point(0, 0, 0)) == white")
|
||||
{
|
||||
REQUIRE(pattern.pattern_at(Tuple::Point(0, 0, 0)) == Color::White());
|
||||
}
|
||||
AND_THEN("pattern_at(pattern, point(0.99, 0, 0)) == white")
|
||||
{
|
||||
REQUIRE(pattern.pattern_at(Tuple::Point(0.99, 0, 0)) == Color::White());
|
||||
}
|
||||
AND_THEN("pattern_at(pattern, point(1.01, 0, 0)) == black")
|
||||
{
|
||||
REQUIRE(pattern.pattern_at(Tuple::Point(1.01, 0, 0)) == Color::Black());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
SCENARIO("Checkers should repeat in y", "[features/patterns.feature]")
|
||||
{
|
||||
GIVEN("pattern <- checkers_pattern(white, black)")
|
||||
{
|
||||
CheckersPattern pattern(Color::White(), Color::Black());
|
||||
THEN("pattern_at(pattern, point(0, 0, 0)) == white")
|
||||
{
|
||||
REQUIRE(pattern.pattern_at(Tuple::Point(0, 0, 0)) == Color::White());
|
||||
}
|
||||
AND_THEN("pattern_at(pattern, point(0, 0.99, 0)) == white")
|
||||
{
|
||||
REQUIRE(pattern.pattern_at(Tuple::Point(0, 0.99, 0)) == Color::White());
|
||||
}
|
||||
AND_THEN("pattern_at(pattern, point(0, 1.01, 0)) == black")
|
||||
{
|
||||
REQUIRE(pattern.pattern_at(Tuple::Point(0, 1.01, 0)) == Color::Black());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
SCENARIO("Checkers should repeat in z", "[features/patterns.feature]")
|
||||
{
|
||||
GIVEN("pattern <- checkers_pattern(white, black)")
|
||||
{
|
||||
CheckersPattern pattern(Color::White(), Color::Black());
|
||||
THEN("pattern_at(pattern, point(0, 0, 0)) == white")
|
||||
{
|
||||
REQUIRE(pattern.pattern_at(Tuple::Point(0, 0, 0)) == Color::White());
|
||||
}
|
||||
AND_THEN("pattern_at(pattern, point(0, 0, 0.99)) == white")
|
||||
{
|
||||
REQUIRE(pattern.pattern_at(Tuple::Point(0, 0, 0.99)) == Color::White());
|
||||
}
|
||||
AND_THEN("pattern_at(pattern, point(0, 0, 1.01)) == black")
|
||||
{
|
||||
REQUIRE(pattern.pattern_at(Tuple::Point(0, 0, 1.01)) == Color::Black());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user