epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
| 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.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 9 | |
| 10 | #include "SkSVGEllipse.h" |
| 11 | #include "SkSVGParser.h" |
| 12 | #include "SkParse.h" |
| 13 | #include <stdio.h> |
| 14 | |
| 15 | const SkSVGAttribute SkSVGEllipse::gAttributes[] = { |
| 16 | SVG_ATTRIBUTE(cx), |
| 17 | SVG_ATTRIBUTE(cy), |
| 18 | SVG_ATTRIBUTE(rx), |
| 19 | SVG_ATTRIBUTE(ry) |
| 20 | }; |
| 21 | |
| 22 | DEFINE_SVG_INFO(Ellipse) |
| 23 | |
| 24 | void SkSVGEllipse::translate(SkSVGParser& parser, bool defState) { |
| 25 | parser._startElement("oval"); |
| 26 | INHERITED::translate(parser, defState); |
| 27 | SkScalar cx, cy, rx, ry; |
| 28 | SkParse::FindScalar(f_cx.c_str(), &cx); |
| 29 | SkParse::FindScalar(f_cy.c_str(), &cy); |
| 30 | SkParse::FindScalar(f_rx.c_str(), &rx); |
| 31 | SkParse::FindScalar(f_ry.c_str(), &ry); |
| 32 | SkScalar left, top, right, bottom; |
| 33 | left = cx - rx; |
| 34 | top = cy - ry; |
| 35 | right = cx + rx; |
| 36 | bottom = cy + ry; |
| 37 | char scratch[16]; |
reed@google.com | 84ef10f | 2012-02-16 13:18:48 +0000 | [diff] [blame] | 38 | sprintf(scratch, "%g", SkScalarToDouble(left)); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 39 | parser._addAttribute("left", scratch); |
reed@google.com | 84ef10f | 2012-02-16 13:18:48 +0000 | [diff] [blame] | 40 | sprintf(scratch, "%g", SkScalarToDouble(top)); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 41 | parser._addAttribute("top", scratch); |
reed@google.com | 84ef10f | 2012-02-16 13:18:48 +0000 | [diff] [blame] | 42 | sprintf(scratch, "%g", SkScalarToDouble(right)); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 43 | parser._addAttribute("right", scratch); |
reed@google.com | 84ef10f | 2012-02-16 13:18:48 +0000 | [diff] [blame] | 44 | sprintf(scratch, "%g", SkScalarToDouble(bottom)); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 45 | parser._addAttribute("bottom", scratch); |
| 46 | parser._endElement(); |
| 47 | } |