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

638 {
639 if (all_corners_same) {
640 return CornerContains(top_right, point, /*check_quadrant=*/false);
641 }
642 return CornerContains(top_right, point) &&
643 CornerContains(bottom_right, point) &&
644 CornerContains(bottom_left, point) && CornerContains(top_left, point);
645 }
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 614 of file round_superellipse_param.cc.

614 {
615 RoundSuperellipseBuilder builder(path_receiver);
616
617 Point start = top_right.offset +
618 top_right.signed_scale *
619 (top_right.top.offset + Point(0, top_right.top.se_a));
620 path_receiver.MoveTo(start, true);
621
622 if (all_corners_same) {
623 builder.AddQuadrant(top_right, /*reverse=*/false, Point(1, 1));
624 builder.AddQuadrant(top_right, /*reverse=*/true, Point(1, -1));
625 builder.AddQuadrant(top_right, /*reverse=*/false, Point(-1, -1));
626 builder.AddQuadrant(top_right, /*reverse=*/true, Point(-1, 1));
627 } else {
628 builder.AddQuadrant(top_right, /*reverse=*/false);
629 builder.AddQuadrant(bottom_right, /*reverse=*/true);
630 builder.AddQuadrant(bottom_left, /*reverse=*/false);
631 builder.AddQuadrant(top_left, /*reverse=*/true);
632 }
633
634 path_receiver.LineTo(start);
635 path_receiver.Close();
636 }
impeller::Point
TPoint< Scalar > Point
Definition: point.h:425
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 575 of file round_superellipse_param.cc.

577 {
578 if (radii.AreAllCornersSame() && !radii.top_left.IsEmpty()) {
579 // Having four empty corners indicate a rectangle, which needs special
580 // treatment on border containment and therefore is not `all_corners_same`.
581 return RoundSuperellipseParam{
582 .top_right = ComputeQuadrant(bounds.GetCenter(), bounds.GetRightTop(),
583 radii.top_right, {-1, 1}),
584 .all_corners_same = true,
585 };
586 }
587 Scalar top_split = Split(bounds.GetLeft(), bounds.GetRight(),
588 radii.top_left.width, radii.top_right.width);
589 Scalar right_split = Split(bounds.GetTop(), bounds.GetBottom(),
590 radii.top_right.height, radii.bottom_right.height);
591 Scalar bottom_split =
592 Split(bounds.GetLeft(), bounds.GetRight(), radii.bottom_left.width,
593 radii.bottom_right.width);
594 Scalar left_split = Split(bounds.GetTop(), bounds.GetBottom(),
595 radii.top_left.height, radii.bottom_left.height);
596
597 return RoundSuperellipseParam{
598 .top_right =
599 ComputeQuadrant(Point{top_split, right_split}, bounds.GetRightTop(),
600 radii.top_right, {1, -1}),
601 .bottom_right =
602 ComputeQuadrant(Point{bottom_split, right_split},
603 bounds.GetRightBottom(), radii.bottom_right, {1, 1}),
604 .bottom_left =
605 ComputeQuadrant(Point{bottom_split, left_split},
606 bounds.GetLeftBottom(), radii.bottom_left, {-1, 1}),
607 .top_left =
608 ComputeQuadrant(Point{top_split, left_split}, bounds.GetLeftTop(),
609 radii.top_left, {-1, -1}),
610 .all_corners_same = false,
611 };
612 }
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 565 of file round_superellipse_param.cc.

567 {
568 return RoundSuperellipseParam{
569 .top_right = ComputeQuadrant(bounds.GetCenter(), bounds.GetRightTop(),
570 {radius, radius}, {-1, 1}),
571 .all_corners_same = true,
572 };
573 }

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

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

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