• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016 Google Inc.
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 SkSVGCircle_DEFINED
9 #define SkSVGCircle_DEFINED
10 
11 #include "experimental/svg/model/SkSVGShape.h"
12 #include "experimental/svg/model/SkSVGTypes.h"
13 
14 struct SkPoint;
15 
16 class SkSVGCircle final : public SkSVGShape {
17 public:
18     ~SkSVGCircle() override = default;
Make()19     static sk_sp<SkSVGCircle> Make() { return sk_sp<SkSVGCircle>(new SkSVGCircle()); }
20 
21     void setCx(const SkSVGLength&);
22     void setCy(const SkSVGLength&);
23     void setR(const SkSVGLength&);
24 
25 protected:
26     void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
27 
28     void onDraw(SkCanvas*, const SkSVGLengthContext&, const SkPaint&,
29                 SkPath::FillType) const override;
30 
31     SkPath onAsPath(const SkSVGRenderContext&) const override;
32 
33 private:
34     SkSVGCircle();
35 
36     // resolve and return the center and radius values
37     std::tuple<SkPoint, SkScalar> resolve(const SkSVGLengthContext&) const;
38 
39     SkSVGLength fCx = SkSVGLength(0);
40     SkSVGLength fCy = SkSVGLength(0);
41     SkSVGLength fR  = SkSVGLength(0);
42 
43     typedef SkSVGShape INHERITED;
44 };
45 
46 #endif // SkSVGCircle_DEFINED
47