blob: e34e17959e83b124a708d571b88571bb53bdce8d [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
2/*
3 * Copyright 2006 The Android Open Source Project
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
reed@android.com8a1c16f2008-12-17 15:59:43 +00009
10#include "SkSVGCircle.h"
11#include "SkSVGParser.h"
12#include "SkParse.h"
13#include <stdio.h>
14
15const SkSVGAttribute SkSVGCircle::gAttributes[] = {
16 SVG_ATTRIBUTE(cx),
17 SVG_ATTRIBUTE(cy),
18 SVG_ATTRIBUTE(r)
19};
20
21DEFINE_SVG_INFO(Circle)
22
23void SkSVGCircle::translate(SkSVGParser& parser, bool defState) {
24 parser._startElement("oval");
25 INHERITED::translate(parser, defState);
26 SkScalar cx, cy, r;
27 SkParse::FindScalar(f_cx.c_str(), &cx);
28 SkParse::FindScalar(f_cy.c_str(), &cy);
29 SkParse::FindScalar(f_r.c_str(), &r);
30 SkScalar left, top, right, bottom;
31 left = cx - r;
32 top = cy - r;
33 right = cx + r;
34 bottom = cy + r;
35 char scratch[16];
reed@google.com84ef10f2012-02-16 13:18:48 +000036 sprintf(scratch, "%g", SkScalarToDouble(left));
reed@android.com8a1c16f2008-12-17 15:59:43 +000037 parser._addAttribute("left", scratch);
reed@google.com84ef10f2012-02-16 13:18:48 +000038 sprintf(scratch, "%g", SkScalarToDouble(top));
reed@android.com8a1c16f2008-12-17 15:59:43 +000039 parser._addAttribute("top", scratch);
reed@google.com84ef10f2012-02-16 13:18:48 +000040 sprintf(scratch, "%g", SkScalarToDouble(right));
reed@android.com8a1c16f2008-12-17 15:59:43 +000041 parser._addAttribute("right", scratch);
reed@google.com84ef10f2012-02-16 13:18:48 +000042 sprintf(scratch, "%g", SkScalarToDouble(bottom));
reed@android.com8a1c16f2008-12-17 15:59:43 +000043 parser._addAttribute("bottom", scratch);
44 parser._endElement();
45}