Flutter Impeller
round_superellipse_param.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
6 
7 namespace impeller {
8 
9 namespace {
10 
11 // Return the value that splits the range from `left` to `right` into two
12 // portions whose ratio equals to `ratio_left` : `ratio_right`.
13 Scalar Split(Scalar left, Scalar right, Scalar ratio_left, Scalar ratio_right) {
14  if (ratio_left == 0 && ratio_right == 0) {
15  return (left + right) / 2;
16  }
17  return (left * ratio_right + right * ratio_left) / (ratio_left + ratio_right);
18 }
19 
20 // Return the same Point, but each NaN coordinate is replaced by that of
21 // `default_size`.
22 inline Point ReplanceNaNWithDefault(Point in, Size default_size) {
23  return Point{std::isnan(in.x) ? default_size.width : in.x,
24  std::isnan(in.y) ? default_size.height : in.y};
25 }
26 
27 // Swap the x and y coordinate of a point.
28 //
29 // Effectively mirrors the point by the y=x line.
30 inline Point Flip(Point a) {
31  return Point{a.y, a.x};
32 }
33 
34 // A look up table with precomputed variables.
35 //
36 // The columns represent the following variabls respectively:
37 //
38 // * n
39 // * k_xJ, which is defined as 1 / (1 - xJ / a)
40 //
41 // For definition of the variables, see ComputeOctant.
42 constexpr Scalar kPrecomputedVariables[][2] = {
43  /*ratio=2.00*/ {2.00000000, 1.13276676},
44  /*ratio=2.10*/ {2.18349805, 1.20311921},
45  /*ratio=2.20*/ {2.33888662, 1.28698796},
46  /*ratio=2.30*/ {2.48660575, 1.36351941},
47  /*ratio=2.40*/ {2.62226596, 1.44717976},
48  /*ratio=2.50*/ {2.75148990, 1.53385819},
49  /*ratio=3.00*/ {3.36298265, 1.98288283},
50  /*ratio=3.50*/ {4.08649929, 2.23811846},
51  /*ratio=4.00*/ {4.85481134, 2.47563463},
52  /*ratio=4.50*/ {5.62945551, 2.72948597},
53  /*ratio=5.00*/ {6.43023796, 2.98020421}};
54 
55 constexpr Scalar kMinRatio = 2.00;
56 
57 // The curve is split into 3 parts:
58 // * The first part uses a denser look up table.
59 // * The second part uses a sparser look up table.
60 // * The third part uses a straight line.
61 constexpr Scalar kFirstStepInverse = 10; // = 1 / 0.10
62 constexpr Scalar kFirstMaxRatio = 2.50;
63 constexpr Scalar kFirstNumRecords = 6;
64 
65 constexpr Scalar kSecondStepInverse = 2; // = 1 / 0.50
66 constexpr Scalar kSecondMaxRatio = 5.00;
67 
68 constexpr Scalar kThirdNSlope = 1.559599389;
69 constexpr Scalar kThirdKxjSlope = 0.522807185;
70 
71 constexpr size_t kNumRecords =
72  sizeof(kPrecomputedVariables) / sizeof(kPrecomputedVariables[0]);
73 
74 // Compute the `n` and `xJ / a` for the given ratio.
75 std::array<Scalar, 2> ComputeNAndXj(Scalar ratio) {
76  if (ratio > kSecondMaxRatio) {
77  Scalar n = kThirdNSlope * (ratio - kSecondMaxRatio) +
78  kPrecomputedVariables[kNumRecords - 1][0];
79  Scalar k_xJ = kThirdKxjSlope * (ratio - kSecondMaxRatio) +
80  kPrecomputedVariables[kNumRecords - 1][1];
81  return {n, 1 - 1 / k_xJ};
82  }
83  ratio = std::clamp(ratio, kMinRatio, kSecondMaxRatio);
84  Scalar steps;
85  if (ratio < kFirstMaxRatio) {
86  steps = (ratio - kMinRatio) * kFirstStepInverse;
87  } else {
88  steps =
89  (ratio - kFirstMaxRatio) * kSecondStepInverse + kFirstNumRecords - 1;
90  }
91 
92  size_t left = std::clamp<size_t>(static_cast<size_t>(std::floor(steps)), 0,
93  kNumRecords - 2);
94  Scalar frac = steps - left;
95 
96  Scalar n = (1 - frac) * kPrecomputedVariables[left][0] +
97  frac * kPrecomputedVariables[left + 1][0];
98  Scalar k_xJ = (1 - frac) * kPrecomputedVariables[left][1] +
99  frac * kPrecomputedVariables[left + 1][1];
100  return {n, 1 - 1 / k_xJ};
101 }
102 
103 // Find the center of the circle that passes the given two points and have the
104 // given radius.
105 Point FindCircleCenter(Point a, Point b, Scalar r) {
106  /* Denote the middle point of A and B as M. The key is to find the center of
107  * the circle.
108  * A --__
109  * / ⟍ `、
110  * / M ⟍\
111  * / ⟋ B
112  * / ⟋ ↗
113  * / ⟋
114  * / ⟋ r
115  * C ᜱ ↙
116  */
117 
118  Point a_to_b = b - a;
119  Point m = (a + b) / 2;
120  Point c_to_m = Point(-a_to_b.y, a_to_b.x);
121  Scalar distance_am = a_to_b.GetLength() / 2;
122  Scalar distance_cm = sqrt(r * r - distance_am * distance_am);
123  return m - distance_cm * c_to_m.Normalize();
124 }
125 
126 // Compute parameters for a square-like rounded superellipse with a symmetrical
127 // radius.
128 RoundSuperellipseParam::Octant ComputeOctant(Point center,
129  Scalar a,
130  Scalar radius) {
131  /* The following figure shows the first quadrant of a square-like rounded
132  * superellipse.
133  *
134  * superelipse
135  * A ↓ circular arc
136  * ---------...._J ↙
137  * | / `⟍ M (where x=y)
138  * | / ⟋ ⟍
139  * | / ⟋ \
140  * | / ⟋ |
141  * | ᜱD |
142  * | ⟋ |
143  * | ⟋ |
144  * |⟋ |
145  * +--------------------| A'
146  * O
147  * ←-------- a ---------→
148  */
149 
150  if (radius <= 0) {
151  return RoundSuperellipseParam::Octant{
152  .offset = center,
153 
154  .se_a = a,
155  .se_n = 0,
156 
157  .circle_start = {a, a},
158  };
159  }
160 
161  Scalar ratio = a * 2 / radius;
163 
164  auto precomputed_vars = ComputeNAndXj(ratio);
165  Scalar n = precomputed_vars[0];
166  Scalar xJ = precomputed_vars[1] * a;
167  Scalar yJ = pow(1 - pow(precomputed_vars[1], n), 1 / n) * a;
168  Scalar max_theta = asinf(pow(precomputed_vars[1], n / 2));
169 
170  Scalar tan_phiJ = pow(xJ / yJ, n - 1);
171  Scalar d = (xJ - tan_phiJ * yJ) / (1 - tan_phiJ);
172  Scalar R = (a - d - g) * sqrt(2);
173 
174  Point pointM{a - g, a - g};
175  Point pointJ = Point{xJ, yJ};
176  Point circle_center =
177  radius == 0 ? pointM : FindCircleCenter(pointJ, pointM, R);
178  Radians circle_max_angle =
179  radius == 0 ? Radians(0)
180  : (pointM - circle_center).AngleTo(pointJ - circle_center);
181 
182  return RoundSuperellipseParam::Octant{
183  .offset = center,
184 
185  .se_a = a,
186  .se_n = n,
187  .se_max_theta = max_theta,
188 
189  .circle_start = pointJ,
190  .circle_center = circle_center,
191  .circle_max_angle = circle_max_angle,
192  };
193 }
194 
195 // Compute parameters for a quadrant of a rounded superellipse with asymmetrical
196 // radii.
197 //
198 // The `corner` is the coordinate of the corner point in the same coordinate
199 // space as `center`, which specifies the half size of the bounding box.
200 //
201 // The `sign` is a vector of {±1, ±1} that specifies which quadrant the curve
202 // should be, which should have the same sign as `corner - center` except that
203 // the latter may have a 0.
204 RoundSuperellipseParam::Quadrant ComputeQuadrant(Point center,
205  Point corner,
206  Size in_radii,
207  Size sign) {
208  Point corner_vector = corner - center;
209  Size radii = in_radii.Abs();
210 
211  // The prefix "norm" is short for "normalized".
212  //
213  // Be extra careful to avoid NaNs in cases that some coordinates of `in_radii`
214  // or `corner_vector` are zero.
215  Scalar norm_radius = radii.MinDimension();
216  Size forward_scale = norm_radius == 0 ? Size{1, 1} : radii / norm_radius;
217  Point norm_half_size = corner_vector.Abs() / forward_scale;
218  Point signed_scale =
219  ReplanceNaNWithDefault(corner_vector / norm_half_size, sign);
220 
221  // Each quadrant curve is composed of two octant curves, each of which belongs
222  // to a square-like rounded rectangle. For the two octants to connect at the
223  // circular arc, the centers these two square-like rounded rectangle must be
224  // offset from the quadrant center by a same distance in different directions.
225  // The distance is denoted as `c`.
226  Scalar c = norm_half_size.x - norm_half_size.y;
227 
228  return RoundSuperellipseParam::Quadrant{
229  .offset = center,
230  .signed_scale = signed_scale,
231  .top = ComputeOctant(Point{0, -c}, norm_half_size.x, norm_radius),
232  .right = ComputeOctant(Point{c, 0}, norm_half_size.y, norm_radius),
233  };
234 }
235 
236 // Checks whether the given point is contained in the first octant of the given
237 // square-like rounded superellipse.
238 //
239 // The first octant refers to the region that spans from 0 to pi/4 starting from
240 // positive Y axis clockwise.
241 //
242 // If the point is not within this octant at all, then this function always
243 // returns true. Otherwise this function returns whether the point is contained
244 // within the rounded superellipse.
245 //
246 // The `param.offset` is ignored. The input point should have been transformed
247 // to the coordinate space where the rounded superellipse is centered at the
248 // origin.
249 bool OctantContains(const RoundSuperellipseParam::Octant& param,
250  const Point& p) {
251  // Check whether the point is within the octant.
252  if (p.x < 0 || p.y < 0 || p.y < p.x) {
253  return true;
254  }
255  // Check if the point is within the superellipsoid segment.
256  if (p.x <= param.circle_start.x) {
257  Point p_se = p / param.se_a;
258  return powf(p_se.x, param.se_n) + powf(p_se.y, param.se_n) <= 1;
259  }
260  Scalar circle_radius =
261  param.circle_start.GetDistanceSquared(param.circle_center);
262  Point p_circle = p - param.circle_center;
263  return p_circle.GetDistanceSquared(Point()) < circle_radius;
264 }
265 
266 // Determine if p is inside the corner curve defined by the indicated corner
267 // param.
268 //
269 // The coordinates of p should be within the same coordinate space with
270 // `param.offset`.
271 //
272 // If `check_quadrant` is true, then this function first checks if the point is
273 // within the quadrant of given corner. If not, this function returns true,
274 // otherwise this method continues to check whether the point is contained in
275 // the rounded superellipse.
276 //
277 // If `check_quadrant` is false, then the first step above is skipped, and the
278 // function checks whether the absolute (relative to the center) coordinate of p
279 // is contained in the rounded superellipse.
280 bool CornerContains(const RoundSuperellipseParam::Quadrant& param,
281  const Point& p,
282  bool check_quadrant = true) {
283  Point norm_point = (p - param.offset) / param.signed_scale;
284  if (check_quadrant) {
285  if (norm_point.x < 0 || norm_point.y < 0) {
286  return true;
287  }
288  } else {
289  norm_point = norm_point.Abs();
290  }
291  if (param.top.se_n < 2 || param.right.se_n < 2) {
292  // A rectangular corner. The top and left sides contain the borders
293  // while the bottom and right sides don't (see `Rect.contains`).
294  Scalar x_delta = param.right.offset.x + param.right.se_a - norm_point.x;
295  Scalar y_delta = param.top.offset.y + param.top.se_a - norm_point.y;
296  bool x_within = x_delta > 0 || (x_delta == 0 && param.signed_scale.x < 0);
297  bool y_within = y_delta > 0 || (y_delta == 0 && param.signed_scale.y < 0);
298  return x_within && y_within;
299  }
300  return OctantContains(param.top, norm_point - param.top.offset) &&
301  OctantContains(param.right, Flip(norm_point - param.right.offset));
302 }
303 
304 class RoundSuperellipseBuilder {
305  public:
306  explicit RoundSuperellipseBuilder(PathReceiver& receiver)
307  : receiver_(receiver) {}
308 
309  // Draws an arc representing 1/4 of a rounded superellipse.
310  //
311  // If `reverse` is false, the resulting arc spans from 0 to pi/2, moving
312  // clockwise starting from the positive Y-axis. Otherwise it moves from pi/2
313  // to 0.
314  //
315  // The `scale_sign` is an additional scaling transformation that potentially
316  // flips the result. This is useful for uniform radii where the same quadrant
317  // parameter set should be drawn to 4 quadrants.
318  void AddQuadrant(const RoundSuperellipseParam::Quadrant& param,
319  bool reverse,
320  Point scale_sign = Point(1, 1)) {
321  auto transform = Matrix::MakeTranslateScale(param.signed_scale * scale_sign,
322  param.offset);
323  if (param.top.se_n < 2 || param.right.se_n < 2) {
324  receiver_.LineTo(transform * (param.top.offset +
325  Point(param.top.se_a, param.top.se_a)));
326  if (!reverse) {
327  receiver_.LineTo(transform *
328  (param.right.offset + Point(param.right.se_a, 0)));
329  } else {
330  receiver_.LineTo(transform *
331  (param.top.offset + Point(0, param.top.se_a)));
332  }
333  return;
334  }
335  if (!reverse) {
336  AddOctant(param.top, /*reverse=*/false, /*flip=*/false, transform);
337  AddOctant(param.right, /*reverse=*/true, /*flip=*/true, transform);
338  } else {
339  AddOctant(param.right, /*reverse=*/false, /*flip=*/true, transform);
340  AddOctant(param.top, /*reverse=*/true, /*flip=*/false, transform);
341  }
342  }
343 
344  private:
345  std::array<Point, 4> SuperellipseArcPoints(
346  const RoundSuperellipseParam::Octant& param) {
347  Point start = {0, param.se_a};
348  const Point& end = param.circle_start;
349  constexpr Point start_tangent = {1, 0};
350  Point circle_start_vector = param.circle_start - param.circle_center;
351  Point end_tangent =
352  Point{-circle_start_vector.y, circle_start_vector.x}.Normalize();
353 
354  std::array<Scalar, 2> factors = SuperellipseBezierFactors(param.se_n);
355 
356  return std::array<Point, 4>{
357  start, start + start_tangent * factors[0] * param.se_a,
358  end + end_tangent * factors[1] * param.se_a, end};
359  };
360 
361  std::array<Point, 4> CircularArcPoints(
362  const RoundSuperellipseParam::Octant& param) {
363  Point start_vector = param.circle_start - param.circle_center;
364  Point end_vector =
365  start_vector.Rotate(Radians(-param.circle_max_angle.radians));
366  Point circle_end = param.circle_center + end_vector;
367  Point start_tangent = Point{start_vector.y, -start_vector.x}.Normalize();
368  Point end_tangent = Point{-end_vector.y, end_vector.x}.Normalize();
369  Scalar bezier_factor = std::tan(param.circle_max_angle.radians / 4) * 4 / 3;
370  Scalar radius = start_vector.GetLength();
371 
372  return std::array<Point, 4>{
373  param.circle_start,
374  param.circle_start + start_tangent * bezier_factor * radius,
375  circle_end + end_tangent * bezier_factor * radius, circle_end};
376  };
377 
378  // Draws an arc representing 1/8 of a rounded superellipse.
379  //
380  // If `reverse` is false, the resulting arc spans from 0 to pi/4, moving
381  // clockwise starting from the positive Y-axis. Otherwise it moves from pi/4
382  // to 0.
383  //
384  // If `flip` is true, all points have their X and Y coordinates swapped,
385  // effectively mirrowing each point by the y=x line.
386  //
387  // All points are transformed by `external_transform` after the optional
388  // flipping before being used as control points for the cubic curves.
389  void AddOctant(const RoundSuperellipseParam::Octant& param,
390  bool reverse,
391  bool flip,
392  const Matrix& external_transform) {
393  Matrix transform =
394  external_transform * Matrix::MakeTranslation(param.offset);
395  if (flip) {
396  transform = transform * kFlip;
397  }
398 
399  auto circle_points = CircularArcPoints(param);
400  auto se_points = SuperellipseArcPoints(param);
401 
402  if (!reverse) {
403  receiver_.CubicTo(transform * se_points[1], transform * se_points[2],
404  transform * se_points[3]);
405  receiver_.CubicTo(transform * circle_points[1],
406  transform * circle_points[2],
407  transform * circle_points[3]);
408  } else {
409  receiver_.CubicTo(transform * circle_points[2],
410  transform * circle_points[1],
411  transform * circle_points[0]);
412  receiver_.CubicTo(transform * se_points[2], transform * se_points[1],
413  transform * se_points[0]);
414  }
415  };
416 
417  // Get the Bezier factor for the superellipse arc in a rounded superellipse.
418  //
419  // The result will be assigned to output, where [0] will be the factor for the
420  // starting tangent and [1] for the ending tangent.
421  //
422  // These values are computed by brute-force searching for the minimal distance
423  // on a rounded superellipse and are not for general purpose superellipses.
424  std::array<Scalar, 2> SuperellipseBezierFactors(Scalar n) {
425  constexpr Scalar kPrecomputedVariables[][2] = {
426  /*n=2.0*/ {0.01339448, 0.05994973},
427  /*n=3.0*/ {0.13664115, 0.13592082},
428  /*n=4.0*/ {0.24545546, 0.14099516},
429  /*n=5.0*/ {0.32353151, 0.12808021},
430  /*n=6.0*/ {0.39093068, 0.11726264},
431  /*n=7.0*/ {0.44847800, 0.10808278},
432  /*n=8.0*/ {0.49817452, 0.10026175},
433  /*n=9.0*/ {0.54105583, 0.09344429},
434  /*n=10.0*/ {0.57812578, 0.08748984},
435  /*n=11.0*/ {0.61050961, 0.08224722},
436  /*n=12.0*/ {0.63903989, 0.07759639},
437  /*n=13.0*/ {0.66416338, 0.07346530},
438  /*n=14.0*/ {0.68675338, 0.06974996},
439  /*n=15.0*/ {0.70678034, 0.06529512}};
440  constexpr size_t kNumRecords =
441  sizeof(kPrecomputedVariables) / sizeof(kPrecomputedVariables[0]);
442  constexpr Scalar kStep = 1.00f;
443  constexpr Scalar kMinN = 2.00f;
444  constexpr Scalar kMaxN = kMinN + (kNumRecords - 1) * kStep;
445 
446  if (n >= kMaxN) {
447  // Heuristic formula derived from fitting.
448  return {1.07f - expf(1.307649835) * powf(n, -0.8568516731),
449  -0.01f + expf(-0.9287690322) * powf(n, -0.6120901398)};
450  }
451 
452  Scalar steps = std::clamp<Scalar>((n - kMinN) / kStep, 0, kNumRecords - 1);
453  size_t left = std::clamp<size_t>(static_cast<size_t>(std::floor(steps)), 0,
454  kNumRecords - 2);
455  Scalar frac = steps - left;
456 
457  return std::array<Scalar, 2>{(1 - frac) * kPrecomputedVariables[left][0] +
458  frac * kPrecomputedVariables[left + 1][0],
459  (1 - frac) * kPrecomputedVariables[left][1] +
460  frac * kPrecomputedVariables[left + 1][1]};
461  }
462 
463  PathReceiver& receiver_;
464 
465  // A matrix that swaps the coordinates of a point.
466  // clang-format off
467  static constexpr Matrix kFlip = Matrix(
468  0.0f, 1.0f, 0.0f, 0.0f,
469  1.0f, 0.0f, 0.0f, 0.0f,
470  0.0f, 0.0f, 1.0f, 0.0f,
471  0.0f, 0.0f, 0.0f, 1.0f);
472  // clang-format on
473 };
474 
475 } // namespace
476 
478  const Rect& bounds,
479  Scalar radius) {
480  return RoundSuperellipseParam{
481  .top_right = ComputeQuadrant(bounds.GetCenter(), bounds.GetRightTop(),
482  {radius, radius}, {-1, 1}),
483  .all_corners_same = true,
484  };
485 }
486 
488  const Rect& bounds,
489  const RoundingRadii& radii) {
490  if (radii.AreAllCornersSame() && !radii.top_left.IsEmpty()) {
491  // Having four empty corners indicate a rectangle, which needs special
492  // treatment on border containment and therefore is not `all_corners_same`.
493  return RoundSuperellipseParam{
494  .top_right = ComputeQuadrant(bounds.GetCenter(), bounds.GetRightTop(),
495  radii.top_right, {-1, 1}),
496  .all_corners_same = true,
497  };
498  }
499  Scalar top_split = Split(bounds.GetLeft(), bounds.GetRight(),
500  radii.top_left.width, radii.top_right.width);
501  Scalar right_split = Split(bounds.GetTop(), bounds.GetBottom(),
502  radii.top_right.height, radii.bottom_right.height);
503  Scalar bottom_split =
504  Split(bounds.GetLeft(), bounds.GetRight(), radii.bottom_left.width,
505  radii.bottom_right.width);
506  Scalar left_split = Split(bounds.GetTop(), bounds.GetBottom(),
507  radii.top_left.height, radii.bottom_left.height);
508 
509  return RoundSuperellipseParam{
510  .top_right =
511  ComputeQuadrant(Point{top_split, right_split}, bounds.GetRightTop(),
512  radii.top_right, {1, -1}),
513  .bottom_right =
514  ComputeQuadrant(Point{bottom_split, right_split},
515  bounds.GetRightBottom(), radii.bottom_right, {1, 1}),
516  .bottom_left =
517  ComputeQuadrant(Point{bottom_split, left_split},
518  bounds.GetLeftBottom(), radii.bottom_left, {-1, 1}),
519  .top_left =
520  ComputeQuadrant(Point{top_split, left_split}, bounds.GetLeftTop(),
521  radii.top_left, {-1, -1}),
522  .all_corners_same = false,
523  };
524 }
525 
526 void RoundSuperellipseParam::Dispatch(PathReceiver& path_receiver) const {
527  RoundSuperellipseBuilder builder(path_receiver);
528 
532  path_receiver.MoveTo(start, true);
533 
534  if (all_corners_same) {
535  builder.AddQuadrant(top_right, /*reverse=*/false, Point(1, 1));
536  builder.AddQuadrant(top_right, /*reverse=*/true, Point(1, -1));
537  builder.AddQuadrant(top_right, /*reverse=*/false, Point(-1, -1));
538  builder.AddQuadrant(top_right, /*reverse=*/true, Point(-1, 1));
539  } else {
540  builder.AddQuadrant(top_right, /*reverse=*/false);
541  builder.AddQuadrant(bottom_right, /*reverse=*/true);
542  builder.AddQuadrant(bottom_left, /*reverse=*/false);
543  builder.AddQuadrant(top_left, /*reverse=*/true);
544  }
545 
546  path_receiver.LineTo(start);
547  path_receiver.Close();
548 }
549 
550 bool RoundSuperellipseParam::Contains(const Point& point) const {
551  if (all_corners_same) {
552  return CornerContains(top_right, point, /*check_quadrant=*/false);
553  }
554  return CornerContains(top_right, point) &&
555  CornerContains(bottom_right, point) &&
557 }
558 
559 } // namespace impeller
Collection of functions to receive path segments from the underlying path representation via the DlPa...
Definition: path_source.h:42
virtual void LineTo(const Point &p2)=0
virtual void Close()=0
virtual void MoveTo(const Point &p2, bool will_be_closed)=0
float Scalar
Definition: scalar.h:19
static bool CornerContains(const Point &p, const Point &corner, const Point &direction, const Size &radii)
Definition: round_rect.cc:30
TPoint< Scalar > Point
Definition: point.h:327
TSize< Scalar > Size
Definition: size.h:159
static constexpr Matrix MakeTranslation(const Vector3 &t)
Definition: matrix.h:95
static constexpr Matrix MakeTranslateScale(const Vector3 &s, const Vector3 &t)
Definition: matrix.h:113
static RoundSuperellipseParam MakeBoundsRadii(const Rect &bounds, const RoundingRadii &radii)
void Dispatch(PathReceiver &receiver) const
bool Contains(const Point &point) const
static RoundSuperellipseParam MakeBoundsRadius(const Rect &bounds, Scalar radius)
constexpr bool AreAllCornersSame(Scalar tolerance=kEhCloseEnough) const
constexpr TPoint Abs() const
Definition: point.h:216
constexpr TPoint Rotate(const Radians &angle) const
Definition: point.h:226
constexpr Type GetDistanceSquared(const TPoint &p) const
Definition: point.h:180
constexpr auto GetBottom() const
Definition: rect.h:361
constexpr auto GetTop() const
Definition: rect.h:357
constexpr auto GetLeft() const
Definition: rect.h:355
constexpr auto GetRight() const
Definition: rect.h:359
constexpr TPoint< T > GetLeftBottom() const
Definition: rect.h:371
constexpr TPoint< T > GetRightTop() const
Definition: rect.h:367
constexpr TPoint< T > GetRightBottom() const
Definition: rect.h:375
constexpr Point GetCenter() const
Get the center point as a |Point|.
Definition: rect.h:386
constexpr TPoint< T > GetLeftTop() const
Definition: rect.h:363
constexpr TSize Abs() const
Definition: size.h:108
Type height
Definition: size.h:29
Type width
Definition: size.h:28
constexpr bool IsEmpty() const
Returns true if either of the width or height are 0, negative, or NaN.
Definition: size.h:123
const size_t start
const size_t end