| 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 | Dispatch (PathReceiver &receiver) const

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

## 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

## ◆ Contains()

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

Definition at line 550 of file round_superellipse_param.cc.

550 {
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) &&
556 CornerContains(bottom_left, point) && CornerContains(top_left, point);
557 }
impeller::CornerContains
static bool CornerContains(const Point &p, const Point &corner, const Point &direction, const Size &radii)
Definition: round_rect.cc:30
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::CornerContains(), top_left, and top_right.

## ◆ Dispatch()

void impeller::RoundSuperellipseParam::Dispatch | ( | PathReceiver & | receiver | ) | const

Definition at line 526 of file round_superellipse_param.cc.

526 {
527 RoundSuperellipseBuilder builder(path_receiver);
528
529 Point start = top_right.offset +
530 top_right.signed_scale *
531 (top_right.top.offset + Point(0, top_right.top.se_a));
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 }
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
start
const size_t start
Definition: tessellator_libtess.cc:62

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

Referenced by impeller::testing::TEST().

## ◆ MakeBoundsRadii()

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

Definition at line 487 of file round_superellipse_param.cc.

489 {
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 }
impeller::Scalar
float Scalar
Definition: scalar.h:19

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::RoundSuperellipse::Contains(), impeller::RoundSuperellipsePathSource::Dispatch(), and impeller::testing::TEST().

## ◆ MakeBoundsRadius()

RoundSuperellipseParam impeller::RoundSuperellipseParam::MakeBoundsRadius | ( | const Rect & | bounds,
|  | Scalar | radius
| ) |  |
| static

Definition at line 477 of file round_superellipse_param.cc.

479 {
480 return RoundSuperellipseParam{
481 .top_right = ComputeQuadrant(bounds.GetCenter(), bounds.GetRightTop(),
482 {radius, radius}, {-1, 1}),
483 .all_corners_same = true,
484 };
485 }

References impeller::TRect< T >::GetCenter(), impeller::TRect< T >::GetRightTop(), and top_right.

## Member Data Documentation

## ◆ all_corners_same

bool impeller::RoundSuperellipseParam::all_corners_same

Definition at line 95 of file round_superellipse_param.h.

Referenced by Contains(), and Dispatch().

## ◆ bottom_left

Quadrant impeller::RoundSuperellipseParam::bottom_left

Definition at line 91 of file round_superellipse_param.h.

Referenced by Contains(), and Dispatch().

## ◆ bottom_right

Quadrant impeller::RoundSuperellipseParam::bottom_right

Definition at line 90 of file round_superellipse_param.h.

Referenced by Contains(), and Dispatch().

## ◆ kGapFactor

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

Definition at line 127 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 Contains(), and Dispatch().

## ◆ top_right

Quadrant impeller::RoundSuperellipseParam::top_right

Definition at line 89 of file round_superellipse_param.h.

Referenced by Contains(), Dispatch(), MakeBoundsRadii(), and MakeBoundsRadius().

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

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