Flutter Engine
The Flutter Engine
SkSVGCircle.cpp
Go to the documentation of this file.
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
12
13SkSVGCircle::SkSVGCircle() : INHERITED(SkSVGTag::kCircle) {}
14
15bool SkSVGCircle::parseAndSetAttribute(const char* n, const char* v) {
17 this->setCx(SkSVGAttributeParser::parse<SkSVGLength>("cx", n, v)) ||
18 this->setCy(SkSVGAttributeParser::parse<SkSVGLength>("cy", n, v)) ||
19 this->setR(SkSVGAttributeParser::parse<SkSVGLength>("r", n, v));
20}
21
22std::tuple<SkPoint, SkScalar> SkSVGCircle::resolve(const SkSVGLengthContext& lctx) const {
24 const auto cy = lctx.resolve(fCy, SkSVGLengthContext::LengthType::kVertical);
25 const auto r = lctx.resolve(fR , SkSVGLengthContext::LengthType::kOther);
26
27 return std::make_tuple(SkPoint::Make(cx, cy), r);
28}
30 const SkPaint& paint, SkPathFillType) const {
32 SkScalar r;
33 std::tie(pos, r) = this->resolve(lctx);
34
35 if (r > 0) {
36 canvas->drawCircle(pos.x(), pos.y(), r, paint);
37 }
38}
39
42 SkScalar r;
43 std::tie(pos, r) = this->resolve(ctx.lengthContext());
44
45 SkPath path = SkPath::Circle(pos.x(), pos.y(), r);
46 this->mapToParent(&path);
47
48 return path;
49}
50
52 const auto [pos, r] = this->resolve(ctx.lengthContext());
53 return SkRect::MakeXYWH(pos.fX - r, pos.fY - r, 2 * r, 2 * r);
54}
SkPoint pos
SkPathFillType
Definition: SkPathTypes.h:11
#define INHERITED(method,...)
Definition: SkRecorder.cpp:128
SkSVGTag
Definition: SkSVGNode.h:23
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint)
Definition: SkCanvas.cpp:2707
Definition: SkPath.h:59
static SkPath Circle(SkScalar center_x, SkScalar center_y, SkScalar radius, SkPathDirection dir=SkPathDirection::kCW)
Definition: SkPath.cpp:3598
void onDraw(SkCanvas *, const SkSVGLengthContext &, const SkPaint &, SkPathFillType) const override
Definition: SkSVGCircle.cpp:29
SkRect onObjectBoundingBox(const SkSVGRenderContext &) const override
Definition: SkSVGCircle.cpp:51
SkPath onAsPath(const SkSVGRenderContext &) const override
Definition: SkSVGCircle.cpp:40
bool parseAndSetAttribute(const char *, const char *) override
Definition: SkSVGCircle.cpp:15
SkScalar resolve(const SkSVGLength &, LengthType) const
virtual bool parseAndSetAttribute(const char *name, const char *value)
Definition: SkSVGNode.cpp:90
const SkSVGLengthContext & lengthContext() const
void mapToParent(SkPath *) const
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
float fX
x-axis value
Definition: SkPoint_impl.h:164
static constexpr SkPoint Make(float x, float y)
Definition: SkPoint_impl.h:173
float fY
y-axis value
Definition: SkPoint_impl.h:165
constexpr float y() const
Definition: SkPoint_impl.h:187
constexpr float x() const
Definition: SkPoint_impl.h:181
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659