1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com 2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com/* 3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2006 The Android Open Source Project 4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * 5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be 6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file. 7ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com */ 8ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com 98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkSVGEllipse.h" 118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkSVGParser.h" 128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkParse.h" 138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include <stdio.h> 148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comconst SkSVGAttribute SkSVGEllipse::gAttributes[] = { 168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SVG_ATTRIBUTE(cx), 178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SVG_ATTRIBUTE(cy), 188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SVG_ATTRIBUTE(rx), 198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SVG_ATTRIBUTE(ry) 208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comDEFINE_SVG_INFO(Ellipse) 238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkSVGEllipse::translate(SkSVGParser& parser, bool defState) { 258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com parser._startElement("oval"); 268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com INHERITED::translate(parser, defState); 278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar cx, cy, rx, ry; 288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkParse::FindScalar(f_cx.c_str(), &cx); 298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkParse::FindScalar(f_cy.c_str(), &cy); 308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkParse::FindScalar(f_rx.c_str(), &rx); 318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkParse::FindScalar(f_ry.c_str(), &ry); 328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar left, top, right, bottom; 338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com left = cx - rx; 348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com top = cy - ry; 358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com right = cx + rx; 368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bottom = cy + ry; 378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com char scratch[16]; 3884ef10f8f91a48936db6e6742b4203fdc6a91b7areed@google.com sprintf(scratch, "%g", SkScalarToDouble(left)); 398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com parser._addAttribute("left", scratch); 4084ef10f8f91a48936db6e6742b4203fdc6a91b7areed@google.com sprintf(scratch, "%g", SkScalarToDouble(top)); 418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com parser._addAttribute("top", scratch); 4284ef10f8f91a48936db6e6742b4203fdc6a91b7areed@google.com sprintf(scratch, "%g", SkScalarToDouble(right)); 438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com parser._addAttribute("right", scratch); 4484ef10f8f91a48936db6e6742b4203fdc6a91b7areed@google.com sprintf(scratch, "%g", SkScalarToDouble(bottom)); 458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com parser._addAttribute("bottom", scratch); 468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com parser._endElement(); 478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 48