gfx/skia/trunk/src/svg/SkSVGEllipse.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/src/svg/SkSVGEllipse.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,47 @@
     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 "SkSVGEllipse.h"
    1.14 +#include "SkSVGParser.h"
    1.15 +#include "SkParse.h"
    1.16 +#include <stdio.h>
    1.17 +
    1.18 +const SkSVGAttribute SkSVGEllipse::gAttributes[] = {
    1.19 +    SVG_ATTRIBUTE(cx),
    1.20 +    SVG_ATTRIBUTE(cy),
    1.21 +    SVG_ATTRIBUTE(rx),
    1.22 +    SVG_ATTRIBUTE(ry)
    1.23 +};
    1.24 +
    1.25 +DEFINE_SVG_INFO(Ellipse)
    1.26 +
    1.27 +void SkSVGEllipse::translate(SkSVGParser& parser, bool defState) {
    1.28 +    parser._startElement("oval");
    1.29 +    INHERITED::translate(parser, defState);
    1.30 +    SkScalar cx, cy, rx, ry;
    1.31 +    SkParse::FindScalar(f_cx.c_str(), &cx);
    1.32 +    SkParse::FindScalar(f_cy.c_str(), &cy);
    1.33 +    SkParse::FindScalar(f_rx.c_str(), &rx);
    1.34 +    SkParse::FindScalar(f_ry.c_str(), &ry);
    1.35 +    SkScalar left, top, right, bottom;
    1.36 +    left = cx - rx;
    1.37 +    top = cy - ry;
    1.38 +    right = cx + rx;
    1.39 +    bottom = cy + ry;
    1.40 +    char scratch[16];
    1.41 +    sprintf(scratch, "%g", SkScalarToDouble(left));
    1.42 +    parser._addAttribute("left", scratch);
    1.43 +    sprintf(scratch, "%g", SkScalarToDouble(top));
    1.44 +    parser._addAttribute("top", scratch);
    1.45 +    sprintf(scratch, "%g", SkScalarToDouble(right));
    1.46 +    parser._addAttribute("right", scratch);
    1.47 +    sprintf(scratch, "%g", SkScalarToDouble(bottom));
    1.48 +    parser._addAttribute("bottom", scratch);
    1.49 +    parser._endElement();
    1.50 +}

mercurial