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 
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 
56 
57  SuperellipseGeometry& operator=(const SuperellipseGeometry&) = delete;
58 };
59 
60 } // namespace impeller
61 
62 #endif // FLUTTER_IMPELLER_ENTITY_GEOMETRY_SUPERELLIPSE_GEOMETRY_H_
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:30
SuperellipseGeometry(const Point &center, Scalar radius, Scalar degree, Scalar alpha, Scalar beta)
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...
float Scalar
Definition: scalar.h:19
A 4x4 matrix using column-major storage.
Definition: matrix.h:37