Flutter Impeller
round_superellipse_geometry.h
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
5
#ifndef FLUTTER_IMPELLER_ENTITY_GEOMETRY_ROUND_SUPERELLIPSE_GEOMETRY_H_
6
#define FLUTTER_IMPELLER_ENTITY_GEOMETRY_ROUND_SUPERELLIPSE_GEOMETRY_H_
7
8
#include "
impeller/entity/geometry/geometry.h
"
9
#include "
impeller/geometry/rounding_radii.h
"
10
11
namespace
impeller
{
12
13
/// Geometry class that can generate vertices for a rounded superellipse.
14
///
15
/// A superellipse is an ellipse-like shape that is defined by the parameters N,
16
/// alpha, and beta:
17
///
18
/// 1 = |x / b| ^n + |y / a| ^n
19
///
20
/// A rounded superellipse is a square-like superellipse (a=b) with its four
21
/// corners replaced by circular arcs. It replicates the `RoundedRectangle`
22
/// shape in SwiftUI with corner style `.continuous`.
23
///
24
/// The `bounds` defines the position and size of the shape. The `corner_radius`
25
/// corresponds to SwiftUI's `cornerRadius` parameter, which is close to, but
26
/// not exactly equals to, the radius of the corner circles.
27
class
RoundSuperellipseGeometry
final :
public
Geometry
{
28
public
:
29
RoundSuperellipseGeometry
(
const
Rect
& bounds,
const
RoundingRadii
& radii);
30
RoundSuperellipseGeometry
(
const
Rect
& bounds,
float
corner_radius);
31
32
~RoundSuperellipseGeometry
()
override
;
33
34
// |Geometry|
35
bool
CoversArea
(
const
Matrix
&
transform
,
const
Rect
& rect)
const override
;
36
37
// |Geometry|
38
bool
IsAxisAlignedRect
()
const override
;
39
40
private
:
41
// |Geometry|
42
GeometryResult
GetPositionBuffer(
const
ContentContext
& renderer,
43
const
Entity
& entity,
44
RenderPass
& pass)
const override
;
45
46
// |Geometry|
47
std::optional<Rect> GetCoverage(
const
Matrix
&
transform
)
const override
;
48
49
const
Rect
bounds_;
50
const
RoundingRadii
radii_;
51
52
RoundSuperellipseGeometry
(
const
RoundSuperellipseGeometry
&) =
delete
;
53
54
RoundSuperellipseGeometry
& operator=(
const
RoundSuperellipseGeometry
&) =
55
delete
;
56
};
57
58
}
// namespace impeller
59
60
#endif
// FLUTTER_IMPELLER_ENTITY_GEOMETRY_ROUND_SUPERELLIPSE_GEOMETRY_H_
impeller::ContentContext
Definition:
content_context.h:371
impeller::Entity
Definition:
entity.h:20
impeller::Geometry
Definition:
geometry.h:50
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition:
render_pass.h:30
impeller::RoundSuperellipseGeometry
Definition:
round_superellipse_geometry.h:27
impeller::RoundSuperellipseGeometry::~RoundSuperellipseGeometry
~RoundSuperellipseGeometry() override
Definition:
round_superellipse_geometry.cc:508
impeller::RoundSuperellipseGeometry::CoversArea
bool CoversArea(const Matrix &transform, const Rect &rect) const override
Determines if this geometry, transformed by the given transform, will completely cover all surface ar...
Definition:
round_superellipse_geometry.cc:592
impeller::RoundSuperellipseGeometry::IsAxisAlignedRect
bool IsAxisAlignedRect() const override
Definition:
round_superellipse_geometry.cc:611
impeller::RoundSuperellipseGeometry::RoundSuperellipseGeometry
RoundSuperellipseGeometry(const Rect &bounds, const RoundingRadii &radii)
Definition:
round_superellipse_geometry.cc:499
transform
Matrix transform
Definition:
gaussian_blur_filter_contents.cc:214
geometry.h
impeller
Definition:
allocation.cc:12
rounding_radii.h
impeller::GeometryResult
Definition:
geometry.h:21
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition:
matrix.h:37
impeller::RoundingRadii
Definition:
rounding_radii.h:14
impeller::TRect< Scalar >
impeller
entity
geometry
round_superellipse_geometry.h
Generated by
1.9.1