diff options
Diffstat (limited to 'examples/embedded/embeddedsvgviewer')
9 files changed, 720 insertions, 0 deletions
diff --git a/examples/embedded/embeddedsvgviewer/embeddedsvgviewer.cpp b/examples/embedded/embeddedsvgviewer/embeddedsvgviewer.cpp new file mode 100644 index 0000000..4980cf4 --- /dev/null +++ b/examples/embedded/embeddedsvgviewer/embeddedsvgviewer.cpp @@ -0,0 +1,181 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QPainter> +#include <QApplication> + +#include "embeddedsvgviewer.h" + + + +EmbeddedSvgViewer::EmbeddedSvgViewer(const QString &filePath) +{ + qApp->setStyleSheet(" QSlider:vertical { width: 50px; } \ + QSlider::groove:vertical { border: 1px solid black; border-radius: 3px; width: 6px; } \ + QSlider::handle:vertical { height: 25px; margin: 0 -22px; image: url(':/files/v-slider-handle.svg'); } \ + "); + + m_renderer = new QSvgRenderer(filePath); + m_imageSize = m_renderer->viewBox().size(); + + m_viewBoxCenter = (QPointF(m_imageSize.width() / qreal(2.0), m_imageSize.height() / qreal(2.0))); + + m_zoomSlider = new QSlider(Qt::Vertical, this); + m_zoomSlider->setMaximum(150); + m_zoomSlider->setMinimum(1); + + connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(setZoom(int))); + m_zoomSlider->setValue(100); + + m_quitButton = new QPushButton("Quit", this); + + connect(m_quitButton, SIGNAL(pressed()), QApplication::instance(), SLOT(quit())); + + if (m_renderer->animated()) + connect(m_renderer, SIGNAL(repaintNeeded()), this, SLOT(update())); + +} + +void EmbeddedSvgViewer::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event) + QPainter painter(this); + m_renderer->setViewBox(m_viewBox); + m_renderer->render(&painter); +} + + +void EmbeddedSvgViewer::mouseMoveEvent ( QMouseEvent * event ) +{ + int incX = int((event->globalX() - m_mousePress.x()) * m_imageScale); + int incY = int((event->globalY() - m_mousePress.y()) * m_imageScale); + + QPointF newCenter; + newCenter.setX(m_viewBoxCenterOnMousePress.x() - incX); + newCenter.setY(m_viewBoxCenterOnMousePress.y() - incY); + + QRectF newViewBox = getViewBox(newCenter); + + + // Do a bounded move on the horizontal: + if ( (newViewBox.left() >= m_viewBoxBounds.left()) && + (newViewBox.right() <= m_viewBoxBounds.right()) ) + { + m_viewBoxCenter.setX(newCenter.x()); + m_viewBox.setLeft(newViewBox.left()); + m_viewBox.setRight(newViewBox.right()); + } + + // do a bounded move on the vertical: + if ( (newViewBox.top() >= m_viewBoxBounds.top()) && + (newViewBox.bottom() <= m_viewBoxBounds.bottom()) ) + { + m_viewBoxCenter.setY(newCenter.y()); + m_viewBox.setTop(newViewBox.top()); + m_viewBox.setBottom(newViewBox.bottom()); + } + + update(); +} + +void EmbeddedSvgViewer::mousePressEvent ( QMouseEvent * event ) +{ + m_viewBoxCenterOnMousePress = m_viewBoxCenter; + m_mousePress = event->globalPos(); +} + + +QRectF EmbeddedSvgViewer::getViewBox(QPointF viewBoxCenter) +{ + QRectF result; + result.setLeft(viewBoxCenter.x() - (m_viewBoxSize.width() / 2)); + result.setTop(viewBoxCenter.y() - (m_viewBoxSize.height() / 2)); + result.setRight(viewBoxCenter.x() + (m_viewBoxSize.width() / 2)); + result.setBottom(viewBoxCenter.y() + (m_viewBoxSize.height() / 2)); + return result; +} + +void EmbeddedSvgViewer::updateImageScale() +{ + m_imageScale = qMax( (qreal)m_imageSize.width() / (qreal)width(), + (qreal)m_imageSize.height() / (qreal)height())*m_zoomLevel; + + m_viewBoxSize.setWidth((qreal)width() * m_imageScale); + m_viewBoxSize.setHeight((qreal)height() * m_imageScale); +} + + +void EmbeddedSvgViewer::resizeEvent ( QResizeEvent * /* event */ ) +{ + qreal origZoom = m_zoomLevel; + + // Get the new bounds: + m_zoomLevel = 1.0; + updateImageScale(); + m_viewBoxBounds = getViewBox(QPointF(m_imageSize.width() / 2.0, m_imageSize.height() / 2.0)); + + m_zoomLevel = origZoom; + updateImageScale(); + m_viewBox = getViewBox(m_viewBoxCenter); + + QRect sliderRect; + sliderRect.setLeft(width() - m_zoomSlider->sizeHint().width()); + sliderRect.setRight(width()); + sliderRect.setTop(height()/4); + sliderRect.setBottom(height() - (height()/4)); + m_zoomSlider->setGeometry(sliderRect); +} + + +void EmbeddedSvgViewer::setZoom(int newZoom) +{ + m_zoomLevel = qreal(newZoom) / qreal(100); + + updateImageScale(); + m_viewBox = getViewBox(m_viewBoxCenter); + + update(); +} + + + + + diff --git a/examples/embedded/embeddedsvgviewer/embeddedsvgviewer.h b/examples/embedded/embeddedsvgviewer/embeddedsvgviewer.h new file mode 100644 index 0000000..a9bdfdf --- /dev/null +++ b/examples/embedded/embeddedsvgviewer/embeddedsvgviewer.h @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef EMBEDDED_SVG_VIEWER_H +#define EMBEDDED_SVG_VIEWER_H + +#include <QWidget> +#include <QString> +#include <QSvgRenderer> +#include <QSize> +#include <QMouseEvent> +#include <QSlider> +#include <QPushButton> + +class EmbeddedSvgViewer : public QWidget +{ + Q_OBJECT +public: + EmbeddedSvgViewer(const QString& filePath); + virtual void paintEvent(QPaintEvent *event); + void mouseMoveEvent ( QMouseEvent * event ); + void mousePressEvent ( QMouseEvent * event ); + void resizeEvent ( QResizeEvent * event ); + +public slots: + void setZoom(int); // 100 <= newZoom < 0 + +private: + QSvgRenderer* m_renderer; + QSlider* m_zoomSlider; + QPushButton* m_quitButton; + QSize m_imageSize; + qreal m_zoomLevel; + qreal m_imageScale; // How many Image coords 1 widget pixel is worth + + QRectF m_viewBox; + QRectF m_viewBoxBounds; + QSizeF m_viewBoxSize; + QPointF m_viewBoxCenter; + QPointF m_viewBoxCenterOnMousePress; + QPoint m_mousePress; + + void updateImageScale(); + QRectF getViewBox(QPointF viewBoxCenter); +}; + + + +#endif diff --git a/examples/embedded/embeddedsvgviewer/embeddedsvgviewer.pro b/examples/embedded/embeddedsvgviewer/embeddedsvgviewer.pro new file mode 100644 index 0000000..b55aee2 --- /dev/null +++ b/examples/embedded/embeddedsvgviewer/embeddedsvgviewer.pro @@ -0,0 +1,21 @@ +TEMPLATE = app +QT += svg + +# Input +HEADERS += embeddedsvgviewer.h +SOURCES += embeddedsvgviewer.cpp main.cpp +RESOURCES += embeddedsvgviewer.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/embedded/embeddedsvgviewer +sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.html *.svg files +sources.path = $$[QT_INSTALL_EXAMPLES]/qtsvg/embedded/embeddedsvgviewer +INSTALLS += target sources + +wince* { + DEPLOYMENT_PLUGIN += qsvg +} + +symbian { + TARGET.UID3 = 0xA000A640 + CONFIG += qt_demo +} diff --git a/examples/embedded/embeddedsvgviewer/embeddedsvgviewer.qrc b/examples/embedded/embeddedsvgviewer/embeddedsvgviewer.qrc new file mode 100644 index 0000000..bb02118 --- /dev/null +++ b/examples/embedded/embeddedsvgviewer/embeddedsvgviewer.qrc @@ -0,0 +1,7 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="/"> + <file>files/v-slider-handle.svg</file> + <file>files/default.svg</file> +</qresource> +</RCC> + diff --git a/examples/embedded/embeddedsvgviewer/files/default.svg b/examples/embedded/embeddedsvgviewer/files/default.svg new file mode 100644 index 0000000..c28a711 --- /dev/null +++ b/examples/embedded/embeddedsvgviewer/files/default.svg @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://web.resource.org/cc/" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="400px" + height="400px" + baseProfile="tiny" + id="svg8268" + sodipodi:version="0.32" + inkscape:version="0.45.1" + sodipodi:docname="simple2.svg" + sodipodi:docbase="/nfs/OpenMoko/SVGs" + inkscape:output_extension="org.inkscape.output.svg.inkscape"> + <metadata + id="metadata8283"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + </cc:Work> + </rdf:RDF> + </metadata> + <defs + id="defs8281" /> + <sodipodi:namedview + inkscape:window-height="917" + inkscape:window-width="1324" + inkscape:pageshadow="2" + inkscape:pageopacity="0.0" + guidetolerance="10.0" + gridtolerance="10.0" + objecttolerance="10.0" + borderopacity="1.0" + bordercolor="#666666" + pagecolor="#ffffff" + id="base" + inkscape:zoom="2.1452345" + inkscape:cx="185.25" + inkscape:cy="214.75" + inkscape:window-x="0" + inkscape:window-y="30" + inkscape:current-layer="svg8268" /> + <g + stroke="DarkBlue" + stroke-width="10" + id="g8270"> + <rect + fill="blue" + fill-opacity="0.5" + x="25" + y="25" + width="175" + height="175" + id="rect8272" /> + </g> + <circle + cx="200" + cy="200" + r="75" + id="circle8274" + sodipodi:cx="200" + sodipodi:cy="200" + sodipodi:rx="75" + sodipodi:ry="75" + transform="translate(-26.104372,21.909027)" + style="fill:#ffff00;fill-opacity:0.5;stroke:#000000" /> + <polygon + fill="green" + stroke="black" + fill-opacity="0.5" + stroke-width="1" + points="200,225 350,225 275,350" + id="polygon8276" /> + <path + style="fill:#000000;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:0.50196081" + d="M 303.7037,50.705207 C 173.88522,56.588264 90.320951,92.710345 162.85059,120.82533 C 211.91719,139.84524 196.63811,214.12391 233.86243,192.59259 C 284.31755,163.4083 299.34345,193.75691 311.11111,187.30159 C 347.88407,167.12924 269.34382,134.85785 303.81608,114.5167 C 394.71183,60.881583 332.47907,46.043712 303.7037,50.705207 z " + id="path8289" + sodipodi:nodetypes="cssssc" /> +</svg> diff --git a/examples/embedded/embeddedsvgviewer/files/v-slider-handle.svg b/examples/embedded/embeddedsvgviewer/files/v-slider-handle.svg new file mode 100644 index 0000000..4ee87f8 --- /dev/null +++ b/examples/embedded/embeddedsvgviewer/files/v-slider-handle.svg @@ -0,0 +1,100 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://web.resource.org/cc/" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="50" + height="25" + id="svg2" + sodipodi:version="0.32" + inkscape:version="0.45.1" + version="1.0" + sodipodi:docbase="/home/tcooksey/Projects/qt-4.4/demos/embedded/embeddedsvgviewer/files" + sodipodi:docname="v-slider-handle.svg" + inkscape:output_extension="org.inkscape.output.svg.inkscape"> + <defs + id="defs4"> + <linearGradient + inkscape:collect="always" + id="linearGradient2158"> + <stop + style="stop-color:#000000;stop-opacity:1;" + offset="0" + id="stop2160" /> + <stop + style="stop-color:#000000;stop-opacity:0;" + offset="1" + id="stop2162" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient2158" + id="linearGradient2164" + x1="26.10779" + y1="9.1025448" + x2="26.10779" + y2="-0.01334004" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.9876687,0,0,2.5969342,0.3086332,-0.476397)" /> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + gridtolerance="10000" + guidetolerance="10" + objecttolerance="10" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="12.256878" + inkscape:cx="42.920885" + inkscape:cy="4.2252457" + inkscape:document-units="px" + inkscape:current-layer="layer1" + width="50px" + height="25px" + inkscape:window-width="1282" + inkscape:window-height="879" + inkscape:window-x="137" + inkscape:window-y="30" /> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1"> + <path + style="fill:url(#linearGradient2164);fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.60153389px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 10.191803,24.254577 C 26.804559,24.254577 25.309299,24.303278 39.985656,24.303278 C 52.503796,24.303278 51.963217,0.91536797 40.722957,0.91536797 C 13.837108,0.91536797 16.298612,0.86901372 10.385089,0.86901372 C -2.0345215,0.86901372 -2.5249912,24.254577 10.191803,24.254577 z " + id="path2162" + sodipodi:nodetypes="csssc" /> + <path + sodipodi:type="arc" + style="fill:#ff0000;fill-opacity:1;fill-rule:nonzero;stroke:#868686;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" + id="path2166" + sodipodi:cx="9.4232807" + sodipodi:cy="13.169908" + sodipodi:rx="2.2436383" + sodipodi:ry="1.9580842" + d="M 9.4232808,15.127992 A 2.2436383,1.9580842 0 1 1 9.4232808,11.211823 L 9.4232807,13.169908 z" + sodipodi:start="1.5707963" + sodipodi:end="4.712389" + transform="matrix(4.3804554,0,0,2.228386,-25.247974,-16.463284)" /> + </g> +</svg> diff --git a/examples/embedded/embeddedsvgviewer/main.cpp b/examples/embedded/embeddedsvgviewer/main.cpp new file mode 100644 index 0000000..d1f07b9 --- /dev/null +++ b/examples/embedded/embeddedsvgviewer/main.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QApplication> +#include <QDebug> + +#include "embeddedsvgviewer.h" + +int main(int argc, char** argv) +{ + QApplication app(argc, argv); + Q_INIT_RESOURCE(embeddedsvgviewer); + + QString filePath; + + if (argc == 1) + filePath = QLatin1String(":/files/default.svg"); + else if (argc == 2) + filePath = argv[1]; + else { + qDebug() << QLatin1String("Please specify an svg file!"); + return -1; + } + + EmbeddedSvgViewer viewer(filePath); + + viewer.showFullScreen(); + +#ifdef QT_KEYPAD_NAVIGATION + QApplication::setNavigationMode(Qt::NavigationModeCursorAuto); +#endif + return app.exec(); +} diff --git a/examples/embedded/embeddedsvgviewer/shapes.svg b/examples/embedded/embeddedsvgviewer/shapes.svg new file mode 100644 index 0000000..c28a711 --- /dev/null +++ b/examples/embedded/embeddedsvgviewer/shapes.svg @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://web.resource.org/cc/" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="400px" + height="400px" + baseProfile="tiny" + id="svg8268" + sodipodi:version="0.32" + inkscape:version="0.45.1" + sodipodi:docname="simple2.svg" + sodipodi:docbase="/nfs/OpenMoko/SVGs" + inkscape:output_extension="org.inkscape.output.svg.inkscape"> + <metadata + id="metadata8283"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + </cc:Work> + </rdf:RDF> + </metadata> + <defs + id="defs8281" /> + <sodipodi:namedview + inkscape:window-height="917" + inkscape:window-width="1324" + inkscape:pageshadow="2" + inkscape:pageopacity="0.0" + guidetolerance="10.0" + gridtolerance="10.0" + objecttolerance="10.0" + borderopacity="1.0" + bordercolor="#666666" + pagecolor="#ffffff" + id="base" + inkscape:zoom="2.1452345" + inkscape:cx="185.25" + inkscape:cy="214.75" + inkscape:window-x="0" + inkscape:window-y="30" + inkscape:current-layer="svg8268" /> + <g + stroke="DarkBlue" + stroke-width="10" + id="g8270"> + <rect + fill="blue" + fill-opacity="0.5" + x="25" + y="25" + width="175" + height="175" + id="rect8272" /> + </g> + <circle + cx="200" + cy="200" + r="75" + id="circle8274" + sodipodi:cx="200" + sodipodi:cy="200" + sodipodi:rx="75" + sodipodi:ry="75" + transform="translate(-26.104372,21.909027)" + style="fill:#ffff00;fill-opacity:0.5;stroke:#000000" /> + <polygon + fill="green" + stroke="black" + fill-opacity="0.5" + stroke-width="1" + points="200,225 350,225 275,350" + id="polygon8276" /> + <path + style="fill:#000000;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:0.50196081" + d="M 303.7037,50.705207 C 173.88522,56.588264 90.320951,92.710345 162.85059,120.82533 C 211.91719,139.84524 196.63811,214.12391 233.86243,192.59259 C 284.31755,163.4083 299.34345,193.75691 311.11111,187.30159 C 347.88407,167.12924 269.34382,134.85785 303.81608,114.5167 C 394.71183,60.881583 332.47907,46.043712 303.7037,50.705207 z " + id="path8289" + sodipodi:nodetypes="cssssc" /> +</svg> diff --git a/examples/embedded/embeddedsvgviewer/spheres.svg b/examples/embedded/embeddedsvgviewer/spheres.svg new file mode 100644 index 0000000..e108777 --- /dev/null +++ b/examples/embedded/embeddedsvgviewer/spheres.svg @@ -0,0 +1,81 @@ +<?xml version="1.0" standalone="no"?> +<svg width="8cm" height="8cm" viewBox="0 0 400 400" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink/" + baseProfile="tiny" version="1.2"> + <title>Spheres</title> + <desc>Gradient filled spheres with different colors.</desc> + <defs> + <!-- Create radial gradients for each circle to make them look like + spheres. --> + <radialGradient id="blueSphere" gradientUnits="userSpaceOnUse" + cx="0" cy="0" r="100" fx="-50" fy="-50"> + <stop offset="0%" stop-color="white" /> + <stop offset="75%" stop-color="blue" /> + <stop offset="100%" stop-color="#222244" /> + </radialGradient> + <radialGradient id="redSphere" gradientUnits="userSpaceOnUse" + cx="0" cy="0" r="100" fx="-50" fy="-50"> + <stop offset="0%" stop-color="white" /> + <stop offset="75%" stop-color="red" /> + <stop offset="100%" stop-color="#442222" /> + </radialGradient> + <radialGradient id="greenSphere" gradientUnits="userSpaceOnUse" + cx="0" cy="0" r="100" fx="-50" fy="-50"> + <stop offset="0%" stop-color="white" /> + <stop offset="75%" stop-color="green" /> + <stop offset="100%" stop-color="#113311" /> + </radialGradient> + <radialGradient id="yellowSphere" gradientUnits="userSpaceOnUse" + cx="0" cy="0" r="100" fx="-50" fy="-50"> + <stop offset="0%" stop-color="white" /> + <stop offset="75%" stop-color="yellow" /> + <stop offset="100%" stop-color="#444422" /> + </radialGradient> + <radialGradient id="shadowGrad" gradientUnits="userSpaceOnUse" + cx="0" cy="0" r="100" fx="-50" fy="50"> + <stop offset="0%" stop-color="black" stop-opacity="1.0" /> + <stop offset="100%" stop-color="white" stop-opacity="0.0" /> + </radialGradient> + + <!-- Define a shadow for each sphere. --> + <circle id="shadow" fill="url(#shadowGrad)" cx="0" cy="0" r="100" /> + </defs> + <g fill="#ffee99" stroke="none" > + <rect x="0" y="0" width="400" height="400" /> + </g> + <g fill="white" stroke="none" > + <rect x="0" y="175" width="400" height="225" /> + </g> + <g transform="translate(200,290) scale(2.0,1.0) rotate(45)" > + <rect fill="#a6ce39" x="-69" y="-69" width="138" height="138" /> + <circle fill="black" cx="0" cy="0" r="50" /> + <circle fill="#a6ce39" cx="0" cy="0" r="33" /> + <path fill="black" d="M 37,50 L 50,37 L 12,-1 L 22,-11 L 10,-24 L -24,10 + L -11,22 L -1,12 Z" /> + <animateTransform attributeName="transform" type="rotate" values="0; 360" + begin="0s" dur="10s" fill="freeze" /> + </g> + <g transform="translate(200,175)"> + <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" /> + <circle fill="url(#blueSphere)" cx="0" cy="0" r="100" /> + </g> + <g transform="translate(315,240)"> + <g transform="scale(0.5,0.5)"> + <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" /> + <circle fill="url(#redSphere)" cx="0" cy="0" r="100" /> + </g> + </g> + <g transform="translate(80,275)"> + <g transform="scale(0.65,0.65)"> + <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" /> + <circle fill="url(#greenSphere)" cx="0" cy="0" r="100" /> + </g> + </g> + <g transform="translate(255,325)"> + <g transform="scale(0.3,0.3)"> + <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" /> + <circle fill="url(#yellowSphere)" cx="0" cy="0" r="100" /> + </g> + </g> +</svg> |