| 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 554 of file round_superellipse_param.cc.

554 {
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) &&
560 CornerContains(bottom_left, point) && CornerContains(top_left, point);
561 }
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 530 of file round_superellipse_param.cc.

530 {
531 RoundSuperellipseBuilder builder(path_receiver);
532
533 Point start = top_right.offset +
534 top_right.signed_scale *
535 (top_right.top.offset + Point(0, top_right.top.se_a));
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 }
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 491 of file round_superellipse_param.cc.

493 {
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 }
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 481 of file round_superellipse_param.cc.

483 {
484 return RoundSuperellipseParam{
485 .top_right = ComputeQuadrant(bounds.GetCenter(), bounds.GetRightTop(),
486 {radius, radius}, {-1, 1}),
487 .all_corners_same = true,
488 };
489 }

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
| static constexpr

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