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 "SkSVGEllipse.h" michael@0: #include "SkSVGParser.h" michael@0: #include "SkParse.h" michael@0: #include michael@0: michael@0: const SkSVGAttribute SkSVGEllipse::gAttributes[] = { michael@0: SVG_ATTRIBUTE(cx), michael@0: SVG_ATTRIBUTE(cy), michael@0: SVG_ATTRIBUTE(rx), michael@0: SVG_ATTRIBUTE(ry) michael@0: }; michael@0: michael@0: DEFINE_SVG_INFO(Ellipse) michael@0: michael@0: void SkSVGEllipse::translate(SkSVGParser& parser, bool defState) { michael@0: parser._startElement("oval"); michael@0: INHERITED::translate(parser, defState); michael@0: SkScalar cx, cy, rx, ry; michael@0: SkParse::FindScalar(f_cx.c_str(), &cx); michael@0: SkParse::FindScalar(f_cy.c_str(), &cy); michael@0: SkParse::FindScalar(f_rx.c_str(), &rx); michael@0: SkParse::FindScalar(f_ry.c_str(), &ry); michael@0: SkScalar left, top, right, bottom; michael@0: left = cx - rx; michael@0: top = cy - ry; michael@0: right = cx + rx; michael@0: bottom = cy + ry; 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: }