michael@0: michael@0: /* michael@0: * Copyright 2006 The Android Open Source Project michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: michael@0: #include "SkSVGCircle.h" michael@0: #include "SkSVGParser.h" michael@0: #include "SkParse.h" michael@0: #include michael@0: michael@0: const SkSVGAttribute SkSVGCircle::gAttributes[] = { michael@0: SVG_ATTRIBUTE(cx), michael@0: SVG_ATTRIBUTE(cy), michael@0: SVG_ATTRIBUTE(r) michael@0: }; michael@0: michael@0: DEFINE_SVG_INFO(Circle) michael@0: michael@0: void SkSVGCircle::translate(SkSVGParser& parser, bool defState) { michael@0: parser._startElement("oval"); michael@0: INHERITED::translate(parser, defState); michael@0: SkScalar cx, cy, r; michael@0: SkParse::FindScalar(f_cx.c_str(), &cx); michael@0: SkParse::FindScalar(f_cy.c_str(), &cy); michael@0: SkParse::FindScalar(f_r.c_str(), &r); michael@0: SkScalar left, top, right, bottom; michael@0: left = cx - r; michael@0: top = cy - r; michael@0: right = cx + r; michael@0: bottom = cy + r; michael@0: char scratch[16]; michael@0: sprintf(scratch, "%g", SkScalarToDouble(left)); michael@0: parser._addAttribute("left", scratch); michael@0: sprintf(scratch, "%g", SkScalarToDouble(top)); michael@0: parser._addAttribute("top", scratch); michael@0: sprintf(scratch, "%g", SkScalarToDouble(right)); michael@0: parser._addAttribute("right", scratch); michael@0: sprintf(scratch, "%g", SkScalarToDouble(bottom)); michael@0: parser._addAttribute("bottom", scratch); michael@0: parser._endElement(); michael@0: }