| Flutter Impeller |

Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
impeller::RoundSuperellipseParam Struct Reference

`#include <round_superellipse_param.h>`

## Classes
struct | Octant
struct | Quadrant

## Public Member Functions
bool | Contains (const Point &point) const
void | AddToPath (PathBuilder &path) const

## Static Public Member Functions
static RoundSuperellipseParam | MakeBoundsRadii (const Rect &bounds, const RoundingRadii &radii)

## Public Attributes
Quadrant | top_right
Quadrant | bottom_right
Quadrant | bottom_left
Quadrant | top_left
bool | all_corners_same

## Static Public Attributes
static constexpr Scalar | kGapFactor = 0.29289321881f

## Detailed Description

Definition at line 18 of file round_superellipse_param.h.

## Member Function Documentation

## ◆ AddToPath()

void impeller::RoundSuperellipseParam::AddToPath | ( | PathBuilder & | path | ) | const

Definition at line 499 of file round_superellipse_param.cc.

499 {
500 RoundSuperellipseBuilder builder(path_builder);
501
502 Point start = top_right.offset +
503 top_right.signed_scale *
504 (top_right.top.offset + Point(0, top_right.top.se_a));
505 path_builder.MoveTo(start);
506
507 if (all_corners_same) {
508 builder.AddQuadrant(top_right, /*reverse=*/false, Point(1, 1));
509 builder.AddQuadrant(top_right, /*reverse=*/true, Point(1, -1));
510 builder.AddQuadrant(top_right, /*reverse=*/false, Point(-1, -1));
511 builder.AddQuadrant(top_right, /*reverse=*/true, Point(-1, 1));
512 } else {
513 builder.AddQuadrant(top_right, /*reverse=*/false);
514 builder.AddQuadrant(bottom_right, /*reverse=*/true);
515 builder.AddQuadrant(bottom_left, /*reverse=*/false);
516 builder.AddQuadrant(top_left, /*reverse=*/true);
517 }
518
519 path_builder.LineTo(start);
520 path_builder.Close();
521 }
impeller::Point
TPoint< Scalar > Point
Definition: point.h:327
impeller::RoundSuperellipseParam::Octant::offset
Point offset
Definition: round_superellipse_param.h:31
impeller::RoundSuperellipseParam::Octant::se_a
Scalar se_a
Definition: round_superellipse_param.h:34
impeller::RoundSuperellipseParam::Quadrant::signed_scale
Point signed_scale
Definition: round_superellipse_param.h:78
impeller::RoundSuperellipseParam::Quadrant::top
Octant top
Definition: round_superellipse_param.h:82
impeller::RoundSuperellipseParam::Quadrant::offset
Point offset
Definition: round_superellipse_param.h:63
impeller::RoundSuperellipseParam::top_left
Quadrant top_left
Definition: round_superellipse_param.h:92
impeller::RoundSuperellipseParam::bottom_left
Quadrant bottom_left
Definition: round_superellipse_param.h:91
impeller::RoundSuperellipseParam::all_corners_same
bool all_corners_same
Definition: round_superellipse_param.h:95
impeller::RoundSuperellipseParam::top_right
Quadrant top_right
Definition: round_superellipse_param.h:89
impeller::RoundSuperellipseParam::bottom_right
Quadrant bottom_right
Definition: round_superellipse_param.h:90

References all_corners_same, bottom_left, bottom_right, impeller::PathBuilder::Close(), impeller::PathBuilder::LineTo(), impeller::PathBuilder::MoveTo(), impeller::RoundSuperellipseParam::Octant::offset, impeller::RoundSuperellipseParam::Quadrant::offset, impeller::RoundSuperellipseParam::Octant::se_a, impeller::RoundSuperellipseParam::Quadrant::signed_scale, impeller::RoundSuperellipseParam::Quadrant::top, top_left, and top_right.

Referenced by impeller::PathBuilder::AddRoundSuperellipse().

## ◆ Contains()

bool impeller::RoundSuperellipseParam::Contains | ( | const Point & | point | ) | const

Definition at line 523 of file round_superellipse_param.cc.

523 {
524 if (all_corners_same) {
525 return CornerContains(top_right, point, /*check_quadrant=*/false);
526 }
527 return CornerContains(top_right, point) &&
528 CornerContains(bottom_right, point) &&
529 CornerContains(bottom_left, point) && CornerContains(top_left, point);
530 }
impeller::CornerContains
static bool CornerContains(const Point &p, const Point &corner, const Point &direction, const Size &radii)
Definition: round_rect.cc:30

References all_corners_same, bottom_left, bottom_right, impeller::CornerContains(), top_left, and top_right.

## ◆ MakeBoundsRadii()

RoundSuperellipseParam impeller::RoundSuperellipseParam::MakeBoundsRadii | ( | const Rect & | bounds,
|  | const RoundingRadii & | radii
| ) |  |
| static

Definition at line 463 of file round_superellipse_param.cc.

465 {
466 if (radii.AreAllCornersSame() && !radii.top_left.IsEmpty()) {
467 // Having four empty corners indicate a rectangle, which needs special
468 // treatment on border containment and therefore is not `all_corners_same`.
469 return RoundSuperellipseParam{
470 .top_right = ComputeQuadrant(bounds.GetCenter(), bounds.GetRightTop(),
471 radii.top_right),
472 .all_corners_same = true,
473 };
474 }
475 Scalar top_split = Split(bounds.GetLeft(), bounds.GetRight(),
476 radii.top_left.width, radii.top_right.width);
477 Scalar right_split = Split(bounds.GetTop(), bounds.GetBottom(),
478 radii.top_right.height, radii.bottom_right.height);
479 Scalar bottom_split =
480 Split(bounds.GetLeft(), bounds.GetRight(), radii.bottom_left.width,
481 radii.bottom_right.width);
482 Scalar left_split = Split(bounds.GetTop(), bounds.GetBottom(),
483 radii.top_left.height, radii.bottom_left.height);
484
485 return RoundSuperellipseParam{
486 .top_right = ComputeQuadrant(Point{top_split, right_split},
487 bounds.GetRightTop(), radii.top_right),
488 .bottom_right =
489 ComputeQuadrant(Point{bottom_split, right_split},
490 bounds.GetRightBottom(), radii.bottom_right),
491 .bottom_left = ComputeQuadrant(Point{bottom_split, left_split},
492 bounds.GetLeftBottom(), radii.bottom_left),
493 .top_left = ComputeQuadrant(Point{top_split, left_split},
494 bounds.GetLeftTop(), radii.top_left),
495 .all_corners_same = false,
496 };
497 }
impeller::Scalar
float Scalar
Definition: scalar.h:18

References impeller::RoundingRadii::AreAllCornersSame(), impeller::RoundingRadii::bottom_left, impeller::RoundingRadii::bottom_right, impeller::TRect< T >::GetBottom(), impeller::TRect< T >::GetCenter(), impeller::TRect< T >::GetLeft(), impeller::TRect< T >::GetLeftBottom(), impeller::TRect< T >::GetLeftTop(), impeller::TRect< T >::GetRight(), impeller::TRect< T >::GetRightBottom(), impeller::TRect< T >::GetRightTop(), impeller::TRect< T >::GetTop(), impeller::TSize< T >::height, impeller::TSize< T >::IsEmpty(), impeller::RoundingRadii::top_left, top_right, impeller::RoundingRadii::top_right, and impeller::TSize< T >::width.

Referenced by impeller::PathBuilder::AddRoundSuperellipse(), and impeller::RoundSuperellipse::Contains().

## Member Data Documentation

## ◆ all_corners_same

bool impeller::RoundSuperellipseParam::all_corners_same

Definition at line 95 of file round_superellipse_param.h.

Referenced by AddToPath(), and Contains().

## ◆ bottom_left

Quadrant impeller::RoundSuperellipseParam::bottom_left

Definition at line 91 of file round_superellipse_param.h.

Referenced by AddToPath(), and Contains().

## ◆ bottom_right

Quadrant impeller::RoundSuperellipseParam::bottom_right

Definition at line 90 of file round_superellipse_param.h.

Referenced by AddToPath(), and Contains().

## ◆ kGapFactor

constexpr Scalar impeller::RoundSuperellipseParam::kGapFactor = 0.29289321881f
| static constexpr

Definition at line 123 of file round_superellipse_param.h.

## ◆ top_left

Quadrant impeller::RoundSuperellipseParam::top_left

Definition at line 92 of file round_superellipse_param.h.

Referenced by AddToPath(), and Contains().

## ◆ top_right

Quadrant impeller::RoundSuperellipseParam::top_right

Definition at line 89 of file round_superellipse_param.h.

Referenced by AddToPath(), Contains(), and MakeBoundsRadii().

The documentation for this struct was generated from the following files:

- impeller/geometry/round_superellipse_param.h
- impeller/geometry/round_superellipse_param.cc