OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2006 The Android Open Source Project | |
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 | |
9 #include "SkSVGCircle.h" | |
10 #include "SkSVGParser.h" | |
11 #include "SkParse.h" | |
12 #include <stdio.h> | |
13 | |
14 const SkSVGAttribute SkSVGCircle::gAttributes[] = { | |
15 SVG_ATTRIBUTE(cx), | |
16 SVG_ATTRIBUTE(cy), | |
17 SVG_ATTRIBUTE(r) | |
18 }; | |
19 | |
20 DEFINE_SVG_INFO(Circle) | |
21 | |
22 void SkSVGCircle::translate(SkSVGParser& parser, bool defState) { | |
23 parser._startElement("oval"); | |
24 INHERITED::translate(parser, defState); | |
25 SkScalar cx, cy, r; | |
26 SkParse::FindScalar(f_cx.c_str(), &cx); | |
27 SkParse::FindScalar(f_cy.c_str(), &cy); | |
28 SkParse::FindScalar(f_r.c_str(), &r); | |
29 SkScalar left, top, right, bottom; | |
30 left = cx - r; | |
31 top = cy - r; | |
32 right = cx + r; | |
33 bottom = cy + r; | |
34 char scratch[16]; | |
35 sprintf(scratch, "%g", SkScalarToDouble(left)); | |
36 parser._addAttribute("left", scratch); | |
37 sprintf(scratch, "%g", SkScalarToDouble(top)); | |
38 parser._addAttribute("top", scratch); | |
39 sprintf(scratch, "%g", SkScalarToDouble(right)); | |
40 parser._addAttribute("right", scratch); | |
41 sprintf(scratch, "%g", SkScalarToDouble(bottom)); | |
42 parser._addAttribute("bottom", scratch); | |
43 parser._endElement(); | |
44 } | |
OLD | NEW |