5 #include "gtest/gtest.h"
12 TEST(UberSDFParametersTest, MakeFillRect) {
18 EXPECT_EQ(params.center,
Point(150, 150));
19 EXPECT_EQ(params.size,
Point(50, 50));
20 EXPECT_FALSE(params.stroke.has_value());
23 TEST(UberSDFParametersTest, MakeStrokeRect) {
30 EXPECT_EQ(params.center,
Point(150, 150));
31 EXPECT_EQ(params.size,
Point(50, 50));
32 EXPECT_EQ(params.stroke, stroke);
35 TEST(UberSDFParametersTest, MakeStrokeRectLowMiterLimitBecomesBevel) {
43 EXPECT_EQ(params.center,
Point(150, 150));
44 EXPECT_EQ(params.size,
Point(50, 50));
46 EXPECT_EQ(params.stroke, expected_stroke);
49 TEST(UberSDFParametersTest, MakeFillCircle) {
50 Point center = {50, 50};
56 EXPECT_EQ(params.center, center);
57 EXPECT_EQ(params.size,
Point(10.0f, 10.0f));
58 EXPECT_FALSE(params.stroke.has_value());
61 TEST(UberSDFParametersTest, MakeStrokeCircle) {
62 Point center = {50, 50};
69 EXPECT_EQ(params.center, center);
70 EXPECT_EQ(params.size,
Point(10.0f, 10.0f));
71 EXPECT_EQ(params.stroke, stroke);
74 TEST(UberSDFParametersTest, MakeFillOval) {
75 Point center = {25, 25};
83 EXPECT_EQ(params.center, center);
84 EXPECT_EQ(params.size,
Point(size) * 0.5f);
85 EXPECT_FALSE(params.stroke.has_value());
88 TEST(UberSDFParametersTest, MakeStrokeOval) {
89 Point center = {25, 25};
98 EXPECT_EQ(params.center, center);
99 EXPECT_EQ(params.size,
Point(size) * 0.5f);
100 EXPECT_EQ(params.stroke, stroke);
103 TEST(UberSDFParametersTest, MakeRoundedRect) {
107 .top_right =
Size(2.0f, 2.0f),
108 .bottom_left =
Size(3.0f, 3.0f),
109 .bottom_right =
Size(4.0f, 4.0f),
117 EXPECT_EQ(params.center,
Point(60, 70));
118 EXPECT_EQ(params.size,
Point(50, 50));
119 EXPECT_EQ(params.radii.w, 1.0f);
120 EXPECT_EQ(params.radii.y, 2.0f);
121 EXPECT_EQ(params.radii.z, 3.0f);
122 EXPECT_EQ(params.radii.x, 4.0f);
123 EXPECT_FALSE(params.stroke.has_value());
126 TEST(UberSDFParametersTest, MakeRoundedSuperellipse) {
130 .top_right =
Size(10.0f, 10.0f),
131 .bottom_left =
Size(10.0f, 10.0f),
132 .bottom_right =
Size(10.0f, 10.0f),
134 auto round_superellipse_params =
138 round_superellipse_params,
141 EXPECT_EQ(params.type,
144 EXPECT_EQ(params.center,
Point(60, 70));
145 EXPECT_EQ(params.size,
Point(50, 50));
146 EXPECT_FALSE(params.stroke.has_value());
148 EXPECT_EQ(params.radii.x,
149 round_superellipse_params.top_right.top.circle_radius);
150 EXPECT_EQ(params.radii.y,
151 round_superellipse_params.top_right.right.circle_radius);
153 EXPECT_EQ(params.superellipse_degree.x,
154 round_superellipse_params.top_right.top.se_n);
155 EXPECT_EQ(params.superellipse_degree.y,
156 round_superellipse_params.top_right.right.se_n);
158 EXPECT_EQ(params.superellipse_scale.x,
159 round_superellipse_params.top_right.signed_scale.Abs().x);
160 EXPECT_EQ(params.superellipse_scale.y,
161 round_superellipse_params.top_right.signed_scale.Abs().y);
TEST(AllocationSizeTest, CanCreateTypedAllocations)
static constexpr Color Red()
static RoundSuperellipseParam MakeBoundsRadii(const Rect &bounds, const RoundingRadii &radii)
A structure to store all of the parameters related to stroking a path or basic geometry object.
constexpr static TRect MakeOriginSize(const TPoint< Type > &origin, const TSize< Type > &size)
constexpr static TRect MakeXYWH(Type x, Type y, Type width, Type height)
constexpr static TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
static UberSDFParameters MakeCircle(Color color, const Point ¢er, Scalar radius, std::optional< StrokeParameters > stroke)
Creates UberSDFParameters for a circle.
static UberSDFParameters MakeOval(Color color, const Rect &bounds, std::optional< StrokeParameters > stroke)
Creates UberSDFParameters for an Oval.
static UberSDFParameters MakeRoundedRect(Color color, const Rect &rect, const RoundingRadii &radii, std::optional< StrokeParameters > stroke)
Creates UberSDFParameters for a rounded rectangle.
@ kRoundedSuperellipseSymmetric
static UberSDFParameters MakeRoundedSuperellipse(Color color, const Rect &bounds, const RoundSuperellipseParam &round_superellipse_params, std::optional< StrokeParameters > stroke)
Creates UberSDFParameters for an asymmetric round superellipse.
static UberSDFParameters MakeRect(Color color, const Rect &rect, std::optional< StrokeParameters > stroke)
Creates UberSDFParameters for a rectangle.