| Flutter Impeller |

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_SUPERELLIPSE_GEOMETRY_H_
6 #define FLUTTER_IMPELLER_ENTITY_GEOMETRY_SUPERELLIPSE_GEOMETRY_H_
7
8 #include "impeller/entity/geometry/geometry.h"
9
10 namespace impeller {
11
12 /// Geometry class that can generate vertices for a superellipse.
13 ///
14 /// A Superellipse is an ellipse-like shape that is defined by the parameters N,
15 /// alpha, and beta:
16 ///
17 /// 1 = |x / b| ^n + |y / a| ^n
18 ///
19 /// The radius and center apply a uniform scaling and offset that is separate
20 /// from alpha or beta. When n = 4, the shape is referred to as a rectellipse.
21 ///
22 /// See also: https://en.wikipedia.org/wiki/Superellipse
23 class SuperellipseGeometry final : public Geometry {
24 public:
25 explicit SuperellipseGeometry(const Point& center,
26 Scalar radius,
27 Scalar degree,
28 Scalar alpha,
29 Scalar beta);
30
31 ~SuperellipseGeometry() override;
32
33 // |Geometry|
34 bool CoversArea(const Matrix& transform, const Rect& rect) const override;
35
36 // |Geometry|
37 bool IsAxisAlignedRect() const override;
38
39 private:
40 // |Geometry|
41 GeometryResult GetPositionBuffer(const ContentContext& renderer,
42 const Entity& entity,
43 RenderPass& pass) const override;
44
45 // |Geometry|
46 std::optional<Rect> GetCoverage(const Matrix& transform) const override;
47
48 Point center_;
49 // 4 is a rectellipse
50 Scalar degree_;
51 Scalar radius_;
52 Scalar alpha_;
53 Scalar beta_;
54
55 SuperellipseGeometry(const SuperellipseGeometry&) = delete;
56
57 SuperellipseGeometry& operator=(const SuperellipseGeometry&) = delete;
58 };
59
60 } // namespace impeller
61
62 #endif // FLUTTER_IMPELLER_ENTITY_GEOMETRY_SUPERELLIPSE_GEOMETRY_H_
impeller::Scalar
float Scalar
Definition: scalar.h:18
geometry.h
impeller::SuperellipseGeometry::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: superellipse_geometry.cc:104
impeller::SuperellipseGeometry::SuperellipseGeometry
SuperellipseGeometry(const Point &center, Scalar radius, Scalar degree, Scalar alpha, Scalar beta)
Definition: superellipse_geometry.cc:13
impeller::Entity
Definition: entity.h:20
impeller::SuperellipseGeometry::IsAxisAlignedRect
bool IsAxisAlignedRect() const override
Definition: superellipse_geometry.cc:109
transform
Matrix transform
Definition: gaussian_blur_filter_contents.cc:213
impeller::GeometryResult
Definition: geometry.h:26
impeller::SuperellipseGeometry::~SuperellipseGeometry
~SuperellipseGeometry() override
Definition: superellipse_geometry.cc:24
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:33
impeller::Geometry
Definition: geometry.h:55
impeller::TPoint< Scalar >
impeller::SuperellipseGeometry
Definition: superellipse_geometry.h:23
impeller
Definition: allocation.cc:12
impeller::ContentContext
Definition: content_context.h:366
impeller::TRect< Scalar >
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37