Flutter Engine
The Flutter Engine
SkArc.h
Go to the documentation of this file.
1/*
2 * Copyright 2024 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkArc_DEFINED
9#define SkArc_DEFINED
10
11#include "include/core/SkRect.h"
13
14// Represents an arc along an oval boundary, or a closed wedge of the oval.
15struct SkArc {
16 enum class Type : bool {
17 kArc, // An arc along the perimeter of the oval
18 kWedge // A closed wedge that includes the oval's center
19 };
20
21 SkArc() = default;
22 SkArc(const SkArc& arc) = default;
23 SkArc& operator=(const SkArc& arc) = default;
24
25 const SkRect& oval() const { return fOval; }
26 SkScalar startAngle() const { return fStartAngle; }
27 SkScalar sweepAngle() const { return fSweepAngle; }
28 bool isWedge() const { return fType == Type::kWedge; }
29
30 friend bool operator==(const SkArc& a, const SkArc& b) {
31 return a.fOval == b.fOval && a.fStartAngle == b.fStartAngle &&
32 a.fSweepAngle == b.fSweepAngle && a.fType == b.fType;
33 }
34
35 friend bool operator!=(const SkArc& a, const SkArc& b) { return !(a == b); }
36
37 // Preferred factory that explicitly states which type of arc
38 static SkArc Make(const SkRect& oval,
39 SkScalar startAngleDegrees,
40 SkScalar sweepAngleDegrees,
41 Type type) {
42 return SkArc(oval, startAngleDegrees, sweepAngleDegrees, type);
43 }
44
45 // Deprecated factory to assist with legacy code based on `useCenter`
46 static SkArc Make(const SkRect& oval,
47 SkScalar startAngleDegrees,
48 SkScalar sweepAngleDegrees,
49 bool useCenter) {
50 return SkArc(
51 oval, startAngleDegrees, sweepAngleDegrees, useCenter ? Type::kWedge : Type::kArc);
52 }
53
54 // Bounds of oval containing the arc.
56
57 // Angle in degrees where the arc begins. Zero means horizontally to the right.
59 // Sweep angle in degrees; positive is clockwise.
61
63
64private:
67};
68
69#endif
GLenum type
float SkScalar
Definition: extension.cpp:12
static bool b
struct MyStruct a[10]
Definition: SkArc.h:15
SkScalar startAngle() const
Definition: SkArc.h:26
friend bool operator==(const SkArc &a, const SkArc &b)
Definition: SkArc.h:30
Type fType
Definition: SkArc.h:62
SkScalar fSweepAngle
Definition: SkArc.h:60
SkScalar sweepAngle() const
Definition: SkArc.h:27
static SkArc Make(const SkRect &oval, SkScalar startAngleDegrees, SkScalar sweepAngleDegrees, bool useCenter)
Definition: SkArc.h:46
const SkRect & oval() const
Definition: SkArc.h:25
SkScalar fStartAngle
Definition: SkArc.h:58
Type
Definition: SkArc.h:16
SkArc()=default
SkArc & operator=(const SkArc &arc)=default
SkRect fOval
Definition: SkArc.h:55
bool isWedge() const
Definition: SkArc.h:28
static SkArc Make(const SkRect &oval, SkScalar startAngleDegrees, SkScalar sweepAngleDegrees, Type type)
Definition: SkArc.h:38
SkArc(const SkArc &arc)=default
friend bool operator!=(const SkArc &a, const SkArc &b)
Definition: SkArc.h:35
static constexpr SkRect MakeEmpty()
Definition: SkRect.h:595