Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
uber_sdf_parameters.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_CONTENTS_UBER_SDF_PARAMETERS_H_
6#define FLUTTER_IMPELLER_ENTITY_CONTENTS_UBER_SDF_PARAMETERS_H_
7
8#include <optional>
9
16
17namespace impeller {
18
19/// Parameters for rendering shapes using the UberSDF shader.
21 /// The amount by which the UberSDF shader fades the edge of the drawn shapes,
22 /// in pixels.
23 static constexpr Scalar kAntialiasPixels = 1.0f;
24
25 /// The type of primitive shape.
26 enum class Type {
27 kCircle,
28 kRect,
29 kOval,
32 };
33
34 /// Creates UberSDFParameters for a rectangle.
36 const Rect& rect,
37 std::optional<StrokeParameters> stroke);
38
39 /// Creates UberSDFParameters for a circle.
41 const Point& center,
42 Scalar radius,
43 std::optional<StrokeParameters> stroke);
44
45 /// Creates UberSDFParameters for an Oval.
47 const Rect& bounds,
48 std::optional<StrokeParameters> stroke);
49
50 /// Creates UberSDFParameters for a rounded rectangle.
53 const Rect& rect,
54 const RoundingRadii& radii,
55 std::optional<StrokeParameters> stroke);
56
57 /// Creates UberSDFParameters for a symmetric round superellipse.
60 Rect bounds,
69 std::optional<StrokeParameters> stroke);
70
71 /// The type of shape to render.
73
74 /// The color used for filling or stroking the shape.
76
77 /// The center point of the shape in local coordinates.
79
80 /// For a rectangle, this is half the width and height.
81 /// For a circle, this is the radius in both dimensions.
82 /// For an oval, this is half the width and height of the bounds.
84
85 /// The stroke parameters. If std::nullopt, the shape is filled.
86 std::optional<StrokeParameters> stroke;
87
88 /// The corner radii for a rounded shapes.
89 ///
90 /// For RoundSuperellipse, the 'width' component holds the top-octant radius
91 /// and the 'height' component holds the right-octant radius.
93
94 /// The degrees of the top (.x) and right (.y) octants of a RoundSuperellipse.
96
97 /// The semi-axes of the top (.x) and right (.y) superellipse segments.
99
100 /// The spans of the top (.x) and right (.y) circular arcs.
102
103 /// The center of the top circular arc in a RoundSuperellipse.
105
106 /// The center of the right circular arc in a RoundSuperellipse.
108
109 /// The offset of the octants in a RoundSuperellipse.
111
112 /// The scale of the superellipse.
114};
115
116} // namespace impeller
117
118#endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_UBER_SDF_PARAMETERS_H_
float Scalar
Definition scalar.h:19
Parameters for rendering shapes using the UberSDF shader.
Point superellipse_a
The semi-axes of the top (.x) and right (.y) superellipse segments.
Color color
The color used for filling or stroking the shape.
Point corner_circle_center_right
The center of the right circular arc in a RoundSuperellipse.
Point superellipse_degree
The degrees of the top (.x) and right (.y) octants of a RoundSuperellipse.
static UberSDFParameters MakeCircle(Color color, const Point &center, Scalar radius, std::optional< StrokeParameters > stroke)
Creates UberSDFParameters for a circle.
static UberSDFParameters MakeOval(Color color, const Rect &bounds, std::optional< StrokeParameters > stroke)
Creates UberSDFParameters for an Oval.
Type type
The type of shape to render.
Point center
The center point of the shape in local coordinates.
static UberSDFParameters MakeRoundedRect(Color color, const Rect &rect, const RoundingRadii &radii, std::optional< StrokeParameters > stroke)
Creates UberSDFParameters for a rounded rectangle.
Type
The type of primitive shape.
Point corner_angle_span
The spans of the top (.x) and right (.y) circular arcs.
static constexpr Scalar kAntialiasPixels
Point superellipse_scale
The scale of the superellipse.
std::optional< StrokeParameters > stroke
The stroke parameters. If std::nullopt, the shape is filled.
Point corner_circle_center_top
The center of the top circular arc in a RoundSuperellipse.
static UberSDFParameters MakeRect(Color color, const Rect &rect, std::optional< StrokeParameters > stroke)
Creates UberSDFParameters for a rectangle.
static UberSDFParameters MakeRoundedSuperellipse(Color color, Rect bounds, Point superellipse_degree, Point superellipse_a, RoundingRadii radii, Point corner_angle_span, Point corner_circle_center_top, Point corner_circle_center_right, Scalar superellipse_c, Point superellipse_scale, std::optional< StrokeParameters > stroke)
Creates UberSDFParameters for a symmetric round superellipse.
Scalar superellipse_c
The offset of the octants in a RoundSuperellipse.