diff options
author | Gunnar Sletta <gunnar.sletta@digia.com> | 2013-05-26 20:31:40 +0200 |
---|---|---|
committer | Gunnar Sletta <gunnar.sletta@digia.com> | 2013-05-28 09:29:08 +0200 |
commit | 1837bafc23d252fc7a7e9b86618d6e688063b17f (patch) | |
tree | f7c03c3e1cb5062b6dad1668770e0aeaaa45c4c6 /shapes/tools/maskmaker/maskmaker.cpp | |
parent | baaa6d691a1820c80670ee7cfd727fb1c2c7b832 (diff) |
Say hello to Qt.labs.shapes 0.1
The shapes plugin provies three element types.
1. TriangleSet - which encapsulates a set of triangles
including read/save logic to a very basic textual
format. Binary can of course be added later... It
also contains a set of path commands and uses Qt's
triangulator internally to convert a path into
triangles.
2. Polygon - Renders a flat shaded triangle set.
3. MaskedImage - Reads two triangle sets in addition
to an image and splits the image into a opaque and
blended part, making it possible to greatly reduce
the blending needed for drawing large bitmaps which are
largely opaque.
There is also a maskmaker tool in the tools subdirectory
which provides a simple means of generating masks for the
MaskedImage
Change-Id: Ia00f059fb81872e6ca1dca78baf3073c9581acab
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Diffstat (limited to 'shapes/tools/maskmaker/maskmaker.cpp')
-rw-r--r-- | shapes/tools/maskmaker/maskmaker.cpp | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/shapes/tools/maskmaker/maskmaker.cpp b/shapes/tools/maskmaker/maskmaker.cpp new file mode 100644 index 0000000..3f092cb --- /dev/null +++ b/shapes/tools/maskmaker/maskmaker.cpp @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Scenegraph Playground module 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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 Digia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore/QDebug> +#include <QtGui/QGuiApplication> +#include <QtQml/QQmlContext> +#include <QtQuick/QQuickView> + +class Engine : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QString source READ source CONSTANT) +public: + + QString source() const { return m_source; } + void setSource(const QString &src) { m_source = src; } + +private: + QString m_source; +}; + +void printHelp() { + qDebug("Usage:\n" + " > maskmaker [options] filename\n" + "\n" + "Options:\n" + " -h --help This help.."); +} + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + Engine engine; + + QStringList args = app.arguments(); + + for (int i=0; i<args.size(); ++i) { + if (args.at(i) == QStringLiteral("--help") || args.at(i) == QStringLiteral("-h")) { + printHelp(); + return 0; + } else if (i == args.size() - 1 && i > 0) { + engine.setSource(args.at(i)); + } + } + + QQuickView view; + view.rootContext()->setContextProperty("engine", &engine); + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl("qrc:/Main.qml")); + view.show(); + + QObject::connect((QObject *) view.engine(), SIGNAL(quit()), &app, SLOT(quit())); + + app.exec(); +} + +#include "maskmaker.moc" |