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 <= kEhCloseEnough) {
151  // Corners with really small radii are treated as sharp corners, since they
152  // might lead to NaNs due to `ratio` being too large.
153  return RoundSuperellipseParam::Octant{
154  .offset = center,
155 
156  .se_a = a,
157  .se_n = 0,
158 
159  .circle_start = {a, a},
160  };
161  }
162 
163  Scalar ratio = a * 2 / radius;
165 
166  auto precomputed_vars = ComputeNAndXj(ratio);
167  Scalar n = precomputed_vars[0];
168  Scalar xJ = precomputed_vars[1] * a;
169  Scalar yJ = pow(1 - pow(precomputed_vars[1], n), 1 / n) * a;
170  Scalar max_theta = asinf(pow(precomputed_vars[1], n / 2));
171 
172  Scalar tan_phiJ = pow(xJ / yJ, n - 1);
173  Scalar d = (xJ - tan_phiJ * yJ) / (1 - tan_phiJ);
174  Scalar R = (a - d - g) * sqrt(2);
175 
176  Point pointM{a - g, a - g};
177  Point pointJ = Point{xJ, yJ};
178  Point circle_center =
179  radius == 0 ? pointM : FindCircleCenter(pointJ, pointM, R);
180  Radians circle_max_angle =
181  radius == 0 ? Radians(0)
182  : (pointM - circle_center).AngleTo(pointJ - circle_center);
183 
184  return RoundSuperellipseParam::Octant{
185  .offset = center,
186 
187  .se_a = a,
188  .se_n = n,
189  .se_max_theta = max_theta,
190 
191  .circle_start = pointJ,
192  .circle_center = circle_center,
193  .circle_max_angle = circle_max_angle,
194  };
195 }
196 
197 // Compute parameters for a quadrant of a rounded superellipse with asymmetrical
198 // radii.
199 //
200 // The `corner` is the coordinate of the corner point in the same coordinate
201 // space as `center`, which specifies the half size of the bounding box.
202 //
203 // The `sign` is a vector of {±1, ±1} that specifies which quadrant the curve
204 // should be, which should have the same sign as `corner - center` except that
205 // the latter may have a 0.
206 RoundSuperellipseParam::Quadrant ComputeQuadrant(Point center,
207  Point corner,
208  Size in_radii,
209  Size sign) {
210  Point corner_vector = corner - center;
211  Size radii = {std::min(std::abs(in_radii.width), std::abs(corner_vector.x)),
212  std::min(std::abs(in_radii.height), std::abs(corner_vector.y))};
213 
214  // The prefix "norm" is short for "normalized", meaning a rounded superellipse
215  // that has a uniform radius. The quadrant is scaled from this normalized one.
216  //
217  // Be extra careful to avoid NaNs in cases that some coordinates of `in_radii`
218  // or `corner_vector` are zero.
219  Scalar norm_radius = radii.MinDimension();
220  Size forward_scale = norm_radius == 0 ? Size{1, 1} : radii / norm_radius;
221  Point norm_half_size = corner_vector.Abs() / forward_scale;
222  Point signed_scale =
223  ReplanceNaNWithDefault(corner_vector / norm_half_size, sign);
224 
225  // Each quadrant curve is composed of two octant curves, each of which belongs
226  // to a square-like rounded rectangle. For the two octants to connect at the
227  // circular arc, the centers these two square-like rounded rectangle must be
228  // offset from the quadrant center by a same distance in different directions.
229  // The distance is denoted as `c`.
230  Scalar c = norm_half_size.x - norm_half_size.y;
231 
232  return RoundSuperellipseParam::Quadrant{
233  .offset = center,
234  .signed_scale = signed_scale,
235  .top = ComputeOctant(Point{0, -c}, norm_half_size.x, norm_radius),
236  .right = ComputeOctant(Point{c, 0}, norm_half_size.y, norm_radius),
237  };
238 }
239 
240 // Checks whether the given point is contained in the first octant of the given
241 // square-like rounded superellipse.
242 //
243 // The first octant refers to the region that spans from 0 to pi/4 starting from
244 // positive Y axis clockwise.
245 //
246 // If the point is not within this octant at all, then this function always
247 // returns true. Otherwise this function returns whether the point is contained
248 // within the rounded superellipse.
249 //
250 // The `param.offset` is ignored. The input point should have been transformed
251 // to the coordinate space where the rounded superellipse is centered at the
252 // origin.
253 bool OctantContains(const RoundSuperellipseParam::Octant& param,
254  const Point& p) {
255  // Check whether the point is within the octant.
256  if (p.x < 0 || p.y < 0 || p.y < p.x) {
257  return true;
258  }
259  // Check if the point is within the superellipsoid segment.
260  if (p.x <= param.circle_start.x) {
261  Point p_se = p / param.se_a;
262  return powf(p_se.x, param.se_n) + powf(p_se.y, param.se_n) <= 1;
263  }
264  Scalar circle_radius =
265  param.circle_start.GetDistanceSquared(param.circle_center);
266  Point p_circle = p - param.circle_center;
267  return p_circle.GetDistanceSquared(Point()) < circle_radius;
268 }
269 
270 // Determine if p is inside the corner curve defined by the indicated corner
271 // param.
272 //
273 // The coordinates of p should be within the same coordinate space with
274 // `param.offset`.
275 //
276 // If `check_quadrant` is true, then this function first checks if the point is
277 // within the quadrant of given corner. If not, this function returns true,
278 // otherwise this method continues to check whether the point is contained in
279 // the rounded superellipse.
280 //
281 // If `check_quadrant` is false, then the first step above is skipped, and the
282 // function checks whether the absolute (relative to the center) coordinate of p
283 // is contained in the rounded superellipse.
284 bool CornerContains(const RoundSuperellipseParam::Quadrant& param,
285  const Point& p,
286  bool check_quadrant = true) {
287  Point norm_point = (p - param.offset) / param.signed_scale;
288  if (check_quadrant) {
289  if (norm_point.x < 0 || norm_point.y < 0) {
290  return true;
291  }
292  } else {
293  norm_point = norm_point.Abs();
294  }
295  if (param.top.se_n < 2 || param.right.se_n < 2) {
296  // A rectangular corner. The top and left sides contain the borders
297  // while the bottom and right sides don't (see `Rect.contains`).
298  Scalar x_delta = param.right.offset.x + param.right.se_a - norm_point.x;
299  Scalar y_delta = param.top.offset.y + param.top.se_a - norm_point.y;
300  bool x_within = x_delta > 0 || (x_delta == 0 && param.signed_scale.x < 0);
301  bool y_within = y_delta > 0 || (y_delta == 0 && param.signed_scale.y < 0);
302  return x_within && y_within;
303  }
304  return OctantContains(param.top, norm_point - param.top.offset) &&
305  OctantContains(param.right, Flip(norm_point - param.right.offset));
306 }
307 
308 class RoundSuperellipseBuilder {
309  public:
310  explicit RoundSuperellipseBuilder(PathReceiver& receiver)
311  : receiver_(receiver) {}
312 
313  // Draws an arc representing 1/4 of a rounded superellipse.
314  //
315  // If `reverse` is false, the resulting arc spans from 0 to pi/2, moving
316  // clockwise starting from the positive Y-axis. Otherwise it moves from pi/2
317  // to 0.
318  //
319  // The `scale_sign` is an additional scaling transformation that potentially
320  // flips the result. This is useful for uniform radii where the same quadrant
321  // parameter set should be drawn to 4 quadrants.
322  void AddQuadrant(const RoundSuperellipseParam::Quadrant& param,
323  bool reverse,
324  Point scale_sign = Point(1, 1)) {
325  auto transform = Matrix::MakeTranslateScale(param.signed_scale * scale_sign,
326  param.offset);
327  if (param.top.se_n < 2 || param.right.se_n < 2) {
328  receiver_.LineTo(transform * (param.top.offset +
329  Point(param.top.se_a, param.top.se_a)));
330  if (!reverse) {
331  receiver_.LineTo(transform *
332  (param.right.offset + Point(param.right.se_a, 0)));
333  } else {
334  receiver_.LineTo(transform *
335  (param.top.offset + Point(0, param.top.se_a)));
336  }
337  return;
338  }
339  if (!reverse) {
340  AddOctant(param.top, /*reverse=*/false, /*flip=*/false, transform);
341  AddOctant(param.right, /*reverse=*/true, /*flip=*/true, transform);
342  } else {
343  AddOctant(param.right, /*reverse=*/false, /*flip=*/true, transform);
344  AddOctant(param.top, /*reverse=*/true, /*flip=*/false, transform);
345  }
346  }
347 
348  private:
349  std::array<Point, 4> SuperellipseArcPoints(
350  const RoundSuperellipseParam::Octant& param) {
351  Point start = {0, param.se_a};
352  const Point& end = param.circle_start;
353  constexpr Point start_tangent = {1, 0};
354  Point circle_start_vector = param.circle_start - param.circle_center;
355  Point end_tangent =
356  Point{-circle_start_vector.y, circle_start_vector.x}.Normalize();
357 
358  std::array<Scalar, 2> factors = SuperellipseBezierFactors(param.se_n);
359 
360  return std::array<Point, 4>{
361  start, start + start_tangent * factors[0] * param.se_a,
362  end + end_tangent * factors[1] * param.se_a, end};
363  };
364 
365  std::array<Point, 4> CircularArcPoints(
366  const RoundSuperellipseParam::Octant& param) {
367  Point start_vector = param.circle_start - param.circle_center;
368  Point end_vector =
369  start_vector.Rotate(Radians(-param.circle_max_angle.radians));
370  Point circle_end = param.circle_center + end_vector;
371  Point start_tangent = Point{start_vector.y, -start_vector.x}.Normalize();
372  Point end_tangent = Point{-end_vector.y, end_vector.x}.Normalize();
373  Scalar bezier_factor = std::tan(param.circle_max_angle.radians / 4) * 4 / 3;
374  Scalar radius = start_vector.GetLength();
375 
376  return std::array<Point, 4>{
377  param.circle_start,
378  param.circle_start + start_tangent * bezier_factor * radius,
379  circle_end + end_tangent * bezier_factor * radius, circle_end};
380  };
381 
382  // Draws an arc representing 1/8 of a rounded superellipse.
383  //
384  // If `reverse` is false, the resulting arc spans from 0 to pi/4, moving
385  // clockwise starting from the positive Y-axis. Otherwise it moves from pi/4
386  // to 0.
387  //
388  // If `flip` is true, all points have their X and Y coordinates swapped,
389  // effectively mirrowing each point by the y=x line.
390  //
391  // All points are transformed by `external_transform` after the optional
392  // flipping before being used as control points for the cubic curves.
393  void AddOctant(const RoundSuperellipseParam::Octant& param,
394  bool reverse,
395  bool flip,
396  const Matrix& external_transform) {
397  Matrix transform =
398  external_transform * Matrix::MakeTranslation(param.offset);
399  if (flip) {
400  transform = transform * kFlip;
401  }
402 
403  auto circle_points = CircularArcPoints(param);
404  auto se_points = SuperellipseArcPoints(param);
405 
406  if (!reverse) {
407  receiver_.CubicTo(transform * se_points[1], transform * se_points[2],
408  transform * se_points[3]);
409  receiver_.CubicTo(transform * circle_points[1],
410  transform * circle_points[2],
411  transform * circle_points[3]);
412  } else {
413  receiver_.CubicTo(transform * circle_points[2],
414  transform * circle_points[1],
415  transform * circle_points[0]);
416  receiver_.CubicTo(transform * se_points[2], transform * se_points[1],
417  transform * se_points[0]);
418  }
419  };
420 
421  // Get the Bezier factor for the superellipse arc in a rounded superellipse.
422  //
423  // The result will be assigned to output, where [0] will be the factor for the
424  // starting tangent and [1] for the ending tangent.
425  //
426  // These values are computed by brute-force searching for the minimal distance
427  // on a rounded superellipse and are not for general purpose superellipses.
428  std::array<Scalar, 2> SuperellipseBezierFactors(Scalar n) {
429  constexpr Scalar kPrecomputedVariables[][2] = {
430  /*n=2.0*/ {0.01339448, 0.05994973},
431  /*n=3.0*/ {0.13664115, 0.13592082},
432  /*n=4.0*/ {0.24545546, 0.14099516},
433  /*n=5.0*/ {0.32353151, 0.12808021},
434  /*n=6.0*/ {0.39093068, 0.11726264},
435  /*n=7.0*/ {0.44847800, 0.10808278},
436  /*n=8.0*/ {0.49817452, 0.10026175},
437  /*n=9.0*/ {0.54105583, 0.09344429},
438  /*n=10.0*/ {0.57812578, 0.08748984},
439  /*n=11.0*/ {0.61050961, 0.08224722},
440  /*n=12.0*/ {0.63903989, 0.07759639},
441  /*n=13.0*/ {0.66416338, 0.07346530},
442  /*n=14.0*/ {0.68675338, 0.06974996},
443  /*n=15.0*/ {0.70678034, 0.06529512}};
444  constexpr size_t kNumRecords =
445  sizeof(kPrecomputedVariables) / sizeof(kPrecomputedVariables[0]);
446  constexpr Scalar kStep = 1.00f;
447  constexpr Scalar kMinN = 2.00f;
448  constexpr Scalar kMaxN = kMinN + (kNumRecords - 1) * kStep;
449 
450  if (n >= kMaxN) {
451  // Heuristic formula derived from fitting.
452  return {1.07f - expf(1.307649835) * powf(n, -0.8568516731),
453  -0.01f + expf(-0.9287690322) * powf(n, -0.6120901398)};
454  }
455 
456  Scalar steps = std::clamp<Scalar>((n - kMinN) / kStep, 0, kNumRecords - 1);
457  size_t left = std::clamp<size_t>(static_cast<size_t>(std::floor(steps)), 0,
458  kNumRecords - 2);
459  Scalar frac = steps - left;
460 
461  return std::array<Scalar, 2>{(1 - frac) * kPrecomputedVariables[left][0] +
462  frac * kPrecomputedVariables[left + 1][0],
463  (1 - frac) * kPrecomputedVariables[left][1] +
464  frac * kPrecomputedVariables[left + 1][1]};
465  }
466 
467  PathReceiver& receiver_;
468 
469  // A matrix that swaps the coordinates of a point.
470  // clang-format off
471  static constexpr Matrix kFlip = Matrix(
472  0.0f, 1.0f, 0.0f, 0.0f,
473  1.0f, 0.0f, 0.0f, 0.0f,
474  0.0f, 0.0f, 1.0f, 0.0f,
475  0.0f, 0.0f, 0.0f, 1.0f);
476  // clang-format on
477 };
478 
479 } // namespace
480 
482  const Rect& bounds,
483  Scalar radius) {
484  return RoundSuperellipseParam{
485  .top_right = ComputeQuadrant(bounds.GetCenter(), bounds.GetRightTop(),
486  {radius, radius}, {-1, 1}),
487  .all_corners_same = true,
488  };
489 }
490 
492  const Rect& bounds,
493  const RoundingRadii& radii) {
494  if (radii.AreAllCornersSame() && !radii.top_left.IsEmpty()) {
495  // Having four empty corners indicate a rectangle, which needs special
496  // treatment on border containment and therefore is not `all_corners_same`.
497  return RoundSuperellipseParam{
498  .top_right = ComputeQuadrant(bounds.GetCenter(), bounds.GetRightTop(),
499  radii.top_right, {-1, 1}),
500  .all_corners_same = true,
501  };
502  }
503  Scalar top_split = Split(bounds.GetLeft(), bounds.GetRight(),
504  radii.top_left.width, radii.top_right.width);
505  Scalar right_split = Split(bounds.GetTop(), bounds.GetBottom(),
506  radii.top_right.height, radii.bottom_right.height);
507  Scalar bottom_split =
508  Split(bounds.GetLeft(), bounds.GetRight(), radii.bottom_left.width,
509  radii.bottom_right.width);
510  Scalar left_split = Split(bounds.GetTop(), bounds.GetBottom(),
511  radii.top_left.height, radii.bottom_left.height);
512 
513  return RoundSuperellipseParam{
514  .top_right =
515  ComputeQuadrant(Point{top_split, right_split}, bounds.GetRightTop(),
516  radii.top_right, {1, -1}),
517  .bottom_right =
518  ComputeQuadrant(Point{bottom_split, right_split},
519  bounds.GetRightBottom(), radii.bottom_right, {1, 1}),
520  .bottom_left =
521  ComputeQuadrant(Point{bottom_split, left_split},
522  bounds.GetLeftBottom(), radii.bottom_left, {-1, 1}),
523  .top_left =
524  ComputeQuadrant(Point{top_split, left_split}, bounds.GetLeftTop(),
525  radii.top_left, {-1, -1}),
526  .all_corners_same = false,
527  };
528 }
529 
530 void RoundSuperellipseParam::Dispatch(PathReceiver& path_receiver) const {
531  RoundSuperellipseBuilder builder(path_receiver);
532 
536  path_receiver.MoveTo(start, true);
537 
538  if (all_corners_same) {
539  builder.AddQuadrant(top_right, /*reverse=*/false, Point(1, 1));
540  builder.AddQuadrant(top_right, /*reverse=*/true, Point(1, -1));
541  builder.AddQuadrant(top_right, /*reverse=*/false, Point(-1, -1));
542  builder.AddQuadrant(top_right, /*reverse=*/true, Point(-1, 1));
543  } else {
544  builder.AddQuadrant(top_right, /*reverse=*/false);
545  builder.AddQuadrant(bottom_right, /*reverse=*/true);
546  builder.AddQuadrant(bottom_left, /*reverse=*/false);
547  builder.AddQuadrant(top_left, /*reverse=*/true);
548  }
549 
550  path_receiver.LineTo(start);
551  path_receiver.Close();
552 }
553 
554 bool RoundSuperellipseParam::Contains(const Point& point) const {
555  if (all_corners_same) {
556  return CornerContains(top_right, point, /*check_quadrant=*/false);
557  }
558  return CornerContains(top_right, point) &&
559  CornerContains(bottom_right, point) &&
561 }
562 
563 } // 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
constexpr float kEhCloseEnough
Definition: constants.h:57
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:425
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:293
constexpr TPoint Rotate(const Radians &angle) const
Definition: point.h:314
constexpr Type GetDistanceSquared(const TPoint &p) const
Definition: point.h:181
constexpr auto GetBottom() const
Definition: rect.h:357
constexpr auto GetTop() const
Definition: rect.h:353
constexpr auto GetLeft() const
Definition: rect.h:351
constexpr auto GetRight() const
Definition: rect.h:355
constexpr TPoint< T > GetLeftBottom() const
Definition: rect.h:367
constexpr TPoint< T > GetRightTop() const
Definition: rect.h:363
constexpr TPoint< T > GetRightBottom() const
Definition: rect.h:371
constexpr Point GetCenter() const
Get the center point as a |Point|.
Definition: rect.h:382
constexpr TPoint< T > GetLeftTop() const
Definition: rect.h:359
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