1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/svg/SkSVGCircle.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,45 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2006 The Android Open Source Project 1.7 + * 1.8 + * Use of this source code is governed by a BSD-style license that can be 1.9 + * found in the LICENSE file. 1.10 + */ 1.11 + 1.12 + 1.13 +#include "SkSVGCircle.h" 1.14 +#include "SkSVGParser.h" 1.15 +#include "SkParse.h" 1.16 +#include <stdio.h> 1.17 + 1.18 +const SkSVGAttribute SkSVGCircle::gAttributes[] = { 1.19 + SVG_ATTRIBUTE(cx), 1.20 + SVG_ATTRIBUTE(cy), 1.21 + SVG_ATTRIBUTE(r) 1.22 +}; 1.23 + 1.24 +DEFINE_SVG_INFO(Circle) 1.25 + 1.26 +void SkSVGCircle::translate(SkSVGParser& parser, bool defState) { 1.27 + parser._startElement("oval"); 1.28 + INHERITED::translate(parser, defState); 1.29 + SkScalar cx, cy, r; 1.30 + SkParse::FindScalar(f_cx.c_str(), &cx); 1.31 + SkParse::FindScalar(f_cy.c_str(), &cy); 1.32 + SkParse::FindScalar(f_r.c_str(), &r); 1.33 + SkScalar left, top, right, bottom; 1.34 + left = cx - r; 1.35 + top = cy - r; 1.36 + right = cx + r; 1.37 + bottom = cy + r; 1.38 + char scratch[16]; 1.39 + sprintf(scratch, "%g", SkScalarToDouble(left)); 1.40 + parser._addAttribute("left", scratch); 1.41 + sprintf(scratch, "%g", SkScalarToDouble(top)); 1.42 + parser._addAttribute("top", scratch); 1.43 + sprintf(scratch, "%g", SkScalarToDouble(right)); 1.44 + parser._addAttribute("right", scratch); 1.45 + sprintf(scratch, "%g", SkScalarToDouble(bottom)); 1.46 + parser._addAttribute("bottom", scratch); 1.47 + parser._endElement(); 1.48 +}