diff options
Diffstat (limited to 'examples')
195 files changed, 4232 insertions, 0 deletions
diff --git a/examples/examples.pro b/examples/examples.pro new file mode 100644 index 0000000..bac3f26 --- /dev/null +++ b/examples/examples.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS += graphicsview diff --git a/examples/graphicsview/graphicsview.pro b/examples/graphicsview/graphicsview.pro new file mode 100644 index 0000000..4157e99 --- /dev/null +++ b/examples/graphicsview/graphicsview.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS += portedcanvas portedasteroids diff --git a/examples/graphicsview/portedasteroids/animateditem.cpp b/examples/graphicsview/portedasteroids/animateditem.cpp new file mode 100644 index 0000000..489ef34 --- /dev/null +++ b/examples/graphicsview/portedasteroids/animateditem.cpp @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "animateditem.h" + +#include <QtGui/qbitmap.h> +#include <QtGui/qpainter.h> + +AnimatedPixmapItem::AnimatedPixmapItem(const QList<QPixmap> &animation, + QGraphicsScene *scene) + : QGraphicsItem(0, scene), currentFrame(0), vx(0), vy(0) +{ + for (int i = 0; i < animation.size(); ++i) { + QPixmap pixmap = animation.at(i); + Frame frame; + frame.pixmap = pixmap; + frame.shape = QPainterPath(); + frame.boundingRect = pixmap.rect(); + frames << frame; + } +} + +void AnimatedPixmapItem::setFrame(int frame) +{ + if (!frames.isEmpty()) { + prepareGeometryChange(); + currentFrame = frame % frames.size(); + } +} + +void AnimatedPixmapItem::advance(int phase) +{ + if (phase == 1) + moveBy(vx, vy); +} + +QRectF AnimatedPixmapItem::boundingRect() const +{ + return frames.at(currentFrame).boundingRect; +} + +QPainterPath AnimatedPixmapItem::shape() const +{ + const Frame &f = frames.at(currentFrame); + if (f.shape.isEmpty()) { + QPainterPath path; + path.addRegion(f.pixmap.createHeuristicMask()); + const_cast<Frame &>(f).shape = path; + } + return f.shape; +} + +void AnimatedPixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, + QWidget * /*widget*/) +{ + painter->drawPixmap(0, 0, frames.at(currentFrame).pixmap); +} diff --git a/examples/graphicsview/portedasteroids/animateditem.h b/examples/graphicsview/portedasteroids/animateditem.h new file mode 100644 index 0000000..712d70d --- /dev/null +++ b/examples/graphicsview/portedasteroids/animateditem.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef ANIMATEDPIXMAPITEM_H +#define ANIMATEDPIXMAPITEM_H + +#include <QGraphicsItem> + +class AnimatedPixmapItem : public QGraphicsItem +{ +public: + AnimatedPixmapItem(const QList<QPixmap> &animation, QGraphicsScene *scene = 0); + + void setFrame(int frame); + inline int frame() const + { return currentFrame; } + inline int frameCount() const + { return frames.size(); } + inline QPixmap image(int frame) const + { return frames.isEmpty() ? QPixmap() : frames.at(frame % frames.size()).pixmap; } + inline void setVelocity(qreal xvel, qreal yvel) + { vx = xvel; vy = yvel; } + inline qreal xVelocity() const + { return vx; } + inline qreal yVelocity() const + { return vy; } + + QRectF boundingRect() const; + QPainterPath shape() const; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + + void advance(int phase); + +private: + struct Frame { + QPixmap pixmap; + QPainterPath shape; + QRectF boundingRect; + }; + + int currentFrame; + QList<Frame> frames; + qreal vx, vy; +}; + +#endif diff --git a/examples/graphicsview/portedasteroids/bg.png b/examples/graphicsview/portedasteroids/bg.png Binary files differnew file mode 100644 index 0000000..1201172 --- /dev/null +++ b/examples/graphicsview/portedasteroids/bg.png diff --git a/examples/graphicsview/portedasteroids/ledmeter.cpp b/examples/graphicsview/portedasteroids/ledmeter.cpp new file mode 100644 index 0000000..9653fc6 --- /dev/null +++ b/examples/graphicsview/portedasteroids/ledmeter.cpp @@ -0,0 +1,160 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/* + * KAsteroids - Copyright (c) Martin R. Jones 1997 + * + * Part of the KDE project + */ + +#include <qpainter.h> +//Added by qt3to4: +#include <QResizeEvent> +#include <Q3Frame> +#include "ledmeter.h" + +KALedMeter::KALedMeter( QWidget *parent ) : Q3Frame( parent ) +{ + mCRanges.setAutoDelete( TRUE ); + mRange = 100; + mCount = 20; + mCurrentCount = 0; + mValue = 0; + setMinimumWidth( mCount * 2 + frameWidth() ); +} + +void KALedMeter::setRange( int r ) +{ + mRange = r; + if ( mRange < 1 ) + mRange = 1; + setValue( mValue ); + update(); +} + +void KALedMeter::setCount( int c ) +{ + mCount = c; + if ( mCount < 1 ) + mCount = 1; + setMinimumWidth( mCount * 2 + frameWidth() ); + calcColorRanges(); + setValue( mValue ); + update(); +} + +void KALedMeter::setValue( int v ) +{ + mValue = v; + if ( mValue > mRange ) + mValue = mRange; + else if ( mValue < 0 ) + mValue = 0; + int c = ( mValue + mRange / mCount - 1 ) * mCount / mRange; + if ( c != mCurrentCount ) + { + mCurrentCount = c; + update(); + } +} + +void KALedMeter::addColorRange( int pc, const QColor &c ) +{ + ColorRange *cr = new ColorRange; + cr->mPc = pc; + cr->mColor = c; + mCRanges.append( cr ); + calcColorRanges(); +} + +void KALedMeter::resizeEvent( QResizeEvent *e ) +{ + Q3Frame::resizeEvent( e ); + int w = ( width() - frameWidth() - 2 ) / mCount * mCount; + w += frameWidth() + 2; + setFrameRect( QRect( 0, 0, w, height() ) ); +} + +void KALedMeter::drawContents( QPainter *p ) +{ + QRect b = contentsRect(); + + unsigned cidx = 0; + int ncol = mCount; + QColor col = colorGroup().foreground(); + + if ( !mCRanges.isEmpty() ) + { + col = mCRanges.at( cidx )->mColor; + ncol = mCRanges.at( cidx )->mValue; + } + p->setBrush( col ); + p->setPen( col ); + + int lw = b.width() / mCount; + int lx = b.left() + 1; + for ( int i = 0; i < mCurrentCount; i++, lx += lw ) + { + if ( i > ncol ) + { + if ( ++cidx < mCRanges.count() ) + { + col = mCRanges.at( cidx )->mColor; + ncol = mCRanges.at( cidx )->mValue; + p->setBrush( col ); + p->setPen( col ); + } + } + + p->drawRect( lx, b.top() + 1, lw - 1, b.height() - 2 ); + } +} + +void KALedMeter::calcColorRanges() +{ + int prev = 0; + ColorRange *cr; + for ( cr = mCRanges.first(); cr; cr = mCRanges.next() ) + { + cr->mValue = prev + cr->mPc * mCount / 100; + prev = cr->mValue; + } +} + diff --git a/examples/graphicsview/portedasteroids/ledmeter.h b/examples/graphicsview/portedasteroids/ledmeter.h new file mode 100644 index 0000000..2d4ae23 --- /dev/null +++ b/examples/graphicsview/portedasteroids/ledmeter.h @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/* + * KAsteroids - Copyright (c) Martin R. Jones 1997 + * + * Part of the KDE project + */ + +#ifndef __LEDMETER_H__ +#define __LEDMETER_H__ + +#include <q3frame.h> +#include <q3ptrlist.h> +//Added by qt3to4: +#include <QResizeEvent> + + +class KALedMeter : public Q3Frame +{ + Q_OBJECT +public: + KALedMeter( QWidget *parent ); + + int range() const { return mRange; } + void setRange( int r ); + + int count() const { return mCount; } + void setCount( int c ); + + int value () const { return mValue; } + + void addColorRange( int pc, const QColor &c ); + +public slots: + void setValue( int v ); + +protected: + virtual void resizeEvent( QResizeEvent * ); + virtual void drawContents( QPainter * ); + void calcColorRanges(); + +protected: + struct ColorRange + { + int mPc; + int mValue; + QColor mColor; + }; + + int mRange; + int mCount; + int mCurrentCount; + int mValue; + Q3PtrList<ColorRange> mCRanges; +}; + +#endif diff --git a/examples/graphicsview/portedasteroids/main.cpp b/examples/graphicsview/portedasteroids/main.cpp new file mode 100644 index 0000000..4ed4e9f --- /dev/null +++ b/examples/graphicsview/portedasteroids/main.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> + +#include "toplevel.h" + +int main(int argc, char **argv) +{ + Q_INIT_RESOURCE(portedasteroids); + + QApplication app(argc, argv); + + qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); + + KAstTopLevel topLevel; + topLevel.setWindowTitle("Ported Asteroids Game"); + topLevel.show(); + + app.setQuitOnLastWindowClosed(true); + return app.exec(); +} diff --git a/examples/graphicsview/portedasteroids/portedasteroids.pro b/examples/graphicsview/portedasteroids/portedasteroids.pro new file mode 100644 index 0000000..795be49 --- /dev/null +++ b/examples/graphicsview/portedasteroids/portedasteroids.pro @@ -0,0 +1,21 @@ +TEMPLATE = app +INCLUDEPATH += . + +# Input +HEADERS += ledmeter.h sprites.h toplevel.h view.h +SOURCES += ledmeter.cpp main.cpp toplevel.cpp view.cpp +#The following line was inserted by qt3to4 +QT += qt3support + +HEADERS += animateditem.h +SOURCES += animateditem.cpp + +RESOURCES += portedasteroids.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/qt3support/graphicsview/portedasteroids +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS portedasteroids.pro bg.png sounds sprites +sources.path = $$[QT_INSTALL_EXAMPLES]/qt3support/graphicsview/portedasteroids +INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/graphicsview/portedasteroids/portedasteroids.qrc b/examples/graphicsview/portedasteroids/portedasteroids.qrc new file mode 100644 index 0000000..1780828 --- /dev/null +++ b/examples/graphicsview/portedasteroids/portedasteroids.qrc @@ -0,0 +1,163 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="/trolltech/examples/graphicsview/portedasteroids"> +<file>bg.png</file> +<file>sprites/bits/bits0000.png</file> +<file>sprites/bits/bits0001.png</file> +<file>sprites/bits/bits0002.png</file> +<file>sprites/bits/bits0003.png</file> +<file>sprites/bits/bits0004.png</file> +<file>sprites/bits/bits0005.png</file> +<file>sprites/bits/bits0006.png</file> +<file>sprites/bits/bits0007.png</file> +<file>sprites/bits/bits0008.png</file> +<file>sprites/bits/bits0009.png</file> +<file>sprites/bits/bits0010.png</file> +<file>sprites/bits/bits0011.png</file> +<file>sprites/bits/bits0012.png</file> +<file>sprites/bits/bits0013.png</file> +<file>sprites/bits/bits0014.png</file> +<file>sprites/bits/bits0015.png</file> +<file>sprites/ship/ship0000.png</file> +<file>sprites/ship/ship0001.png</file> +<file>sprites/ship/ship0002.png</file> +<file>sprites/ship/ship0003.png</file> +<file>sprites/ship/ship0004.png</file> +<file>sprites/ship/ship0005.png</file> +<file>sprites/ship/ship0006.png</file> +<file>sprites/ship/ship0007.png</file> +<file>sprites/ship/ship0008.png</file> +<file>sprites/ship/ship0009.png</file> +<file>sprites/ship/ship0010.png</file> +<file>sprites/ship/ship0011.png</file> +<file>sprites/ship/ship0012.png</file> +<file>sprites/ship/ship0013.png</file> +<file>sprites/ship/ship0014.png</file> +<file>sprites/ship/ship0015.png</file> +<file>sprites/ship/ship0016.png</file> +<file>sprites/ship/ship0017.png</file> +<file>sprites/ship/ship0018.png</file> +<file>sprites/ship/ship0019.png</file> +<file>sprites/ship/ship0020.png</file> +<file>sprites/ship/ship0021.png</file> +<file>sprites/ship/ship0022.png</file> +<file>sprites/ship/ship0023.png</file> +<file>sprites/ship/ship0024.png</file> +<file>sprites/ship/ship0025.png</file> +<file>sprites/ship/ship0026.png</file> +<file>sprites/ship/ship0027.png</file> +<file>sprites/ship/ship0028.png</file> +<file>sprites/ship/ship0029.png</file> +<file>sprites/ship/ship0030.png</file> +<file>sprites/ship/ship0031.png</file> +<file>sprites/rock1/rock10016.png</file> +<file>sprites/rock1/rock10017.png</file> +<file>sprites/rock1/rock10018.png</file> +<file>sprites/rock1/rock10019.png</file> +<file>sprites/rock1/rock10020.png</file> +<file>sprites/rock1/rock10021.png</file> +<file>sprites/rock1/rock10022.png</file> +<file>sprites/rock1/rock10023.png</file> +<file>sprites/rock1/rock10024.png</file> +<file>sprites/rock1/rock10025.png</file> +<file>sprites/rock1/rock10026.png</file> +<file>sprites/rock1/rock10027.png</file> +<file>sprites/rock1/rock10028.png</file> +<file>sprites/rock1/rock10029.png</file> +<file>sprites/rock1/rock10030.png</file> +<file>sprites/rock1/rock10031.png</file> +<file>sprites/rock1/rock10000.png</file> +<file>sprites/rock1/rock10001.png</file> +<file>sprites/rock1/rock10002.png</file> +<file>sprites/rock1/rock10003.png</file> +<file>sprites/rock1/rock10004.png</file> +<file>sprites/rock1/rock10005.png</file> +<file>sprites/rock1/rock10006.png</file> +<file>sprites/rock1/rock10007.png</file> +<file>sprites/rock1/rock10008.png</file> +<file>sprites/rock1/rock10009.png</file> +<file>sprites/rock1/rock10010.png</file> +<file>sprites/rock1/rock10011.png</file> +<file>sprites/rock1/rock10012.png</file> +<file>sprites/rock1/rock10013.png</file> +<file>sprites/rock1/rock10014.png</file> +<file>sprites/rock1/rock10015.png</file> +<file>sprites/rock2/rock20000.png</file> +<file>sprites/rock2/rock20001.png</file> +<file>sprites/rock2/rock20002.png</file> +<file>sprites/rock2/rock20003.png</file> +<file>sprites/rock2/rock20004.png</file> +<file>sprites/rock2/rock20005.png</file> +<file>sprites/rock2/rock20006.png</file> +<file>sprites/rock2/rock20007.png</file> +<file>sprites/rock2/rock20008.png</file> +<file>sprites/rock2/rock20009.png</file> +<file>sprites/rock2/rock20010.png</file> +<file>sprites/rock2/rock20011.png</file> +<file>sprites/rock2/rock20012.png</file> +<file>sprites/rock2/rock20013.png</file> +<file>sprites/rock2/rock20014.png</file> +<file>sprites/rock2/rock20015.png</file> +<file>sprites/rock2/rock20016.png</file> +<file>sprites/rock2/rock20017.png</file> +<file>sprites/rock2/rock20018.png</file> +<file>sprites/rock2/rock20019.png</file> +<file>sprites/rock2/rock20020.png</file> +<file>sprites/rock2/rock20021.png</file> +<file>sprites/rock2/rock20022.png</file> +<file>sprites/rock2/rock20023.png</file> +<file>sprites/rock2/rock20024.png</file> +<file>sprites/rock2/rock20025.png</file> +<file>sprites/rock2/rock20026.png</file> +<file>sprites/rock2/rock20027.png</file> +<file>sprites/rock2/rock20028.png</file> +<file>sprites/rock2/rock20029.png</file> +<file>sprites/rock2/rock20030.png</file> +<file>sprites/rock2/rock20031.png</file> +<file>sprites/rock3/rock30000.png</file> +<file>sprites/rock3/rock30001.png</file> +<file>sprites/rock3/rock30002.png</file> +<file>sprites/rock3/rock30003.png</file> +<file>sprites/rock3/rock30004.png</file> +<file>sprites/rock3/rock30005.png</file> +<file>sprites/rock3/rock30006.png</file> +<file>sprites/rock3/rock30007.png</file> +<file>sprites/rock3/rock30008.png</file> +<file>sprites/rock3/rock30009.png</file> +<file>sprites/rock3/rock30010.png</file> +<file>sprites/rock3/rock30011.png</file> +<file>sprites/rock3/rock30012.png</file> +<file>sprites/rock3/rock30013.png</file> +<file>sprites/rock3/rock30014.png</file> +<file>sprites/rock3/rock30015.png</file> +<file>sprites/rock3/rock30016.png</file> +<file>sprites/rock3/rock30017.png</file> +<file>sprites/rock3/rock30018.png</file> +<file>sprites/rock3/rock30019.png</file> +<file>sprites/rock3/rock30020.png</file> +<file>sprites/rock3/rock30021.png</file> +<file>sprites/rock3/rock30022.png</file> +<file>sprites/rock3/rock30023.png</file> +<file>sprites/rock3/rock30024.png</file> +<file>sprites/rock3/rock30025.png</file> +<file>sprites/rock3/rock30026.png</file> +<file>sprites/rock3/rock30027.png</file> +<file>sprites/rock3/rock30028.png</file> +<file>sprites/rock3/rock30029.png</file> +<file>sprites/rock3/rock30030.png</file> +<file>sprites/rock3/rock30031.png</file> +<file>sprites/missile/missile.png</file> +<file>sprites/exhaust/exhaust.png</file> +<file>sprites/powerups/shield.png</file> +<file>sprites/powerups/shoot.png</file> +<file>sprites/powerups/teleport.png</file> +<file>sprites/powerups/brake.png</file> +<file>sprites/powerups/energy.png</file> +<file>sprites/shield/shield0000.png</file> +<file>sprites/shield/shield0001.png</file> +<file>sprites/shield/shield0002.png</file> +<file>sprites/shield/shield0003.png</file> +<file>sprites/shield/shield0004.png</file> +<file>sprites/shield/shield0005.png</file> +<file>sprites/shield/shield0006.png</file> +</qresource> +</RCC> diff --git a/examples/graphicsview/portedasteroids/sounds/Explosion.wav b/examples/graphicsview/portedasteroids/sounds/Explosion.wav Binary files differnew file mode 100644 index 0000000..7b140b1 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sounds/Explosion.wav diff --git a/examples/graphicsview/portedasteroids/sprites.h b/examples/graphicsview/portedasteroids/sprites.h new file mode 100644 index 0000000..e5f1dbb --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites.h @@ -0,0 +1,169 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/* + * KAsteroids - Copyright (c) Martin R. Jones 1997 + * + * Part of the KDE project + */ + +#ifndef __SPRITES_H__ +#define __SPRITES_H__ + +#include "animateditem.h" + +#define ID_ROCK_LARGE 1024 +#define ID_ROCK_MEDIUM 1025 +#define ID_ROCK_SMALL 1026 + +#define ID_MISSILE 1030 + +#define ID_BIT 1040 +#define ID_EXHAUST 1041 + +#define ID_ENERGY_POWERUP 1310 +#define ID_TELEPORT_POWERUP 1311 +#define ID_BRAKE_POWERUP 1312 +#define ID_SHIELD_POWERUP 1313 +#define ID_SHOOT_POWERUP 1314 + +#define ID_SHIP 1350 +#define ID_SHIELD 1351 + +#define MAX_SHIELD_AGE 350 +#define MAX_POWERUP_AGE 500 +#define MAX_MISSILE_AGE 40 + +class KMissile : public AnimatedPixmapItem +{ +public: + KMissile( const QList<QPixmap> &s, QGraphicsScene *c ) : AnimatedPixmapItem( s, c ) + { myAge = 0; } + + virtual int type() const { return ID_MISSILE; } + + void growOlder() { myAge++; } + bool expired() { return myAge > MAX_MISSILE_AGE; } + +private: + int myAge; +}; + +class KBit : public AnimatedPixmapItem +{ +public: + KBit( const QList<QPixmap> &s, QGraphicsScene *c ) : AnimatedPixmapItem( s, c ) + { death = 7; } + + virtual int type() const { return ID_BIT; } + + void setDeath( int d ) { death = d; } + void growOlder() { death--; } + bool expired() { return death <= 0; } + +private: + int death; +}; + +class KExhaust : public AnimatedPixmapItem +{ +public: + KExhaust( const QList<QPixmap> &s, QGraphicsScene *c ) : AnimatedPixmapItem( s, c ) + { death = 1; } + + virtual int type() const { return ID_EXHAUST; } + + void setDeath( int d ) { death = d; } + void growOlder() { death--; } + bool expired() { return death <= 0; } + +private: + int death; +}; + +class KPowerup : public AnimatedPixmapItem +{ +public: + KPowerup( const QList<QPixmap> &s, QGraphicsScene *c, int t ) : AnimatedPixmapItem( s, c ), + myAge( 0 ), _type(t) { } + + virtual int type() const { return _type; } + + void growOlder() { myAge++; } + bool expired() const { return myAge > MAX_POWERUP_AGE; } + +protected: + int myAge; + int _type; +}; + +class KRock : public AnimatedPixmapItem +{ +public: + KRock (const QList<QPixmap> &s, QGraphicsScene *c, int t, int sk, int st) : AnimatedPixmapItem( s, c ) + { _type = t; skip = cskip = sk; step = st; } + + void nextFrame() + { + if (cskip-- <= 0) { + setFrame( (frame()+step+frameCount())%frameCount() ); + cskip = QABS(skip); + } + } + + virtual int type() const { return _type; } + +private: + int _type; + int skip; + int cskip; + int step; +}; + +class KShield : public AnimatedPixmapItem +{ +public: + KShield( QList<QPixmap> &s, QGraphicsScene *c ) + : AnimatedPixmapItem( s, c ) {} + + virtual int type() const { return ID_SHIELD; } +}; + +#endif diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits.ini b/examples/graphicsview/portedasteroids/sprites/bits/bits.ini new file mode 100644 index 0000000..cb2976f --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits.ini @@ -0,0 +1,9 @@ +Cyclic_Animation=On +Width=12 +Height=12 +Final_frame=16 ;; NR_ROTS +Antialias=On +Output_Alpha=On +Output_to_File=On +Output_File_Type=n +Input_File_Name=bits.pov diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits.pov b/examples/graphicsview/portedasteroids/sprites/bits/bits.pov new file mode 100644 index 0000000..9be7ccb --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits.pov @@ -0,0 +1,31 @@ + +#version 3.0 +global_settings { assumed_gamma 2.0 } + +#include "colors.inc" +#include "textures.inc" +#include "metals.inc" + +camera { + location <15, -15, -100> + look_at <0, 0, 0> +} + +light_source { <50, 50, -50> colour White } +light_source { <0, 0, -50> colour White } + +prism { + linear_sweep + linear_spline + 0, + 0.2, + 5, + <2, 0>, <0, 2>, <-1, 1>, <0, -3>, <2, 0> + texture { T_Silver_2A } + + rotate <360*clock, 50, 30> + scale <20, 20, 20> +} + + + diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0000.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0000.png Binary files differnew file mode 100644 index 0000000..5ec9d02 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0000.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0001.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0001.png Binary files differnew file mode 100644 index 0000000..07b4012 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0001.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0002.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0002.png Binary files differnew file mode 100644 index 0000000..8333792 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0002.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0003.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0003.png Binary files differnew file mode 100644 index 0000000..9f1fc02 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0003.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0004.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0004.png Binary files differnew file mode 100644 index 0000000..eb1cc09 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0004.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0005.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0005.png Binary files differnew file mode 100644 index 0000000..149be63 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0005.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0006.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0006.png Binary files differnew file mode 100644 index 0000000..4ac75c8 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0006.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0007.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0007.png Binary files differnew file mode 100644 index 0000000..907241d --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0007.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0008.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0008.png Binary files differnew file mode 100644 index 0000000..1533268 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0008.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0009.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0009.png Binary files differnew file mode 100644 index 0000000..05402ba --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0009.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0010.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0010.png Binary files differnew file mode 100644 index 0000000..ca4f229 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0010.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0011.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0011.png Binary files differnew file mode 100644 index 0000000..91913c0 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0011.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0012.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0012.png Binary files differnew file mode 100644 index 0000000..e55d439 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0012.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0013.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0013.png Binary files differnew file mode 100644 index 0000000..9c73436 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0013.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0014.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0014.png Binary files differnew file mode 100644 index 0000000..f0463a2 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0014.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0015.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0015.png Binary files differnew file mode 100644 index 0000000..bce35aa --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0015.png diff --git a/examples/graphicsview/portedasteroids/sprites/exhaust/exhaust.png b/examples/graphicsview/portedasteroids/sprites/exhaust/exhaust.png Binary files differnew file mode 100644 index 0000000..1d9bc33 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/exhaust/exhaust.png diff --git a/examples/graphicsview/portedasteroids/sprites/missile/missile.png b/examples/graphicsview/portedasteroids/sprites/missile/missile.png Binary files differnew file mode 100644 index 0000000..f1a83b2 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/missile/missile.png diff --git a/examples/graphicsview/portedasteroids/sprites/powerups/brake.png b/examples/graphicsview/portedasteroids/sprites/powerups/brake.png Binary files differnew file mode 100644 index 0000000..5f65a11 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/powerups/brake.png diff --git a/examples/graphicsview/portedasteroids/sprites/powerups/energy.png b/examples/graphicsview/portedasteroids/sprites/powerups/energy.png Binary files differnew file mode 100644 index 0000000..4b40074 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/powerups/energy.png diff --git a/examples/graphicsview/portedasteroids/sprites/powerups/shield.png b/examples/graphicsview/portedasteroids/sprites/powerups/shield.png Binary files differnew file mode 100644 index 0000000..6ac6868 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/powerups/shield.png diff --git a/examples/graphicsview/portedasteroids/sprites/powerups/shoot.png b/examples/graphicsview/portedasteroids/sprites/powerups/shoot.png Binary files differnew file mode 100644 index 0000000..5e5bf08 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/powerups/shoot.png diff --git a/examples/graphicsview/portedasteroids/sprites/powerups/teleport.png b/examples/graphicsview/portedasteroids/sprites/powerups/teleport.png Binary files differnew file mode 100644 index 0000000..009c229 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/powerups/teleport.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock1.ini b/examples/graphicsview/portedasteroids/sprites/rock1/rock1.ini new file mode 100644 index 0000000..e42fc76 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock1.ini @@ -0,0 +1,9 @@ +Cyclic_Animation=On +Width=48 +Height=48 +Final_frame=32 ;; NR_ROTS +Antialias=On +Output_Alpha=On +Output_to_File=On +Output_File_Type=n +Input_File_Name=rock1.pov diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock1.pov b/examples/graphicsview/portedasteroids/sprites/rock1/rock1.pov new file mode 100644 index 0000000..58298c0 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock1.pov @@ -0,0 +1,26 @@ +#include "colors.inc" +#include "shapes.inc" +#include "textures.inc" +// #include "stones.inc" + +camera { + location <2,2,-6> + up <0, 1, 0> +// right <4/3, 0, 0> + look_at <0,0,0> +} + +object { light_source { <10, 5, -5> color red 1.1 green 1.1 blue 1.0 } } + +#declare Rock = +mesh { + #include "rock.inc" /* collection of triangle or smooth_triangle data */ +} + +object { + Rock + texture { pigment {White} } + scale 1.9 + rotate <60, 45, 360*clock> +} + diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10000.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10000.png Binary files differnew file mode 100644 index 0000000..5fe70ef --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10000.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10001.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10001.png Binary files differnew file mode 100644 index 0000000..ea66dac --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10001.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10002.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10002.png Binary files differnew file mode 100644 index 0000000..cb55ed0 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10002.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10003.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10003.png Binary files differnew file mode 100644 index 0000000..f82934c --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10003.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10004.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10004.png Binary files differnew file mode 100644 index 0000000..04efc2b --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10004.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10005.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10005.png Binary files differnew file mode 100644 index 0000000..b9c0d03 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10005.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10006.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10006.png Binary files differnew file mode 100644 index 0000000..7f91267 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10006.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10007.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10007.png Binary files differnew file mode 100644 index 0000000..b28f219 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10007.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10008.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10008.png Binary files differnew file mode 100644 index 0000000..0153d4a --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10008.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10009.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10009.png Binary files differnew file mode 100644 index 0000000..c04d827 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10009.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10010.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10010.png Binary files differnew file mode 100644 index 0000000..c7d3c40 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10010.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10011.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10011.png Binary files differnew file mode 100644 index 0000000..233dfce --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10011.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10012.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10012.png Binary files differnew file mode 100644 index 0000000..ec7b5ba --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10012.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10013.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10013.png Binary files differnew file mode 100644 index 0000000..22eac3a --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10013.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10014.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10014.png Binary files differnew file mode 100644 index 0000000..ad1503d --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10014.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10015.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10015.png Binary files differnew file mode 100644 index 0000000..cec22e2 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10015.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10016.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10016.png Binary files differnew file mode 100644 index 0000000..c7a96cb --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10016.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10017.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10017.png Binary files differnew file mode 100644 index 0000000..c8310bd --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10017.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10018.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10018.png Binary files differnew file mode 100644 index 0000000..b8d436b --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10018.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10019.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10019.png Binary files differnew file mode 100644 index 0000000..e5d0799 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10019.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10020.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10020.png Binary files differnew file mode 100644 index 0000000..440f8d0 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10020.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10021.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10021.png Binary files differnew file mode 100644 index 0000000..de3d54d --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10021.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10022.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10022.png Binary files differnew file mode 100644 index 0000000..698056d --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10022.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10023.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10023.png Binary files differnew file mode 100644 index 0000000..4e6ba04 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10023.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10024.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10024.png Binary files differnew file mode 100644 index 0000000..3b42850 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10024.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10025.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10025.png Binary files differnew file mode 100644 index 0000000..6813936 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10025.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10026.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10026.png Binary files differnew file mode 100644 index 0000000..4a2b171 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10026.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10027.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10027.png Binary files differnew file mode 100644 index 0000000..30448fb --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10027.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10028.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10028.png Binary files differnew file mode 100644 index 0000000..43ca1a9 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10028.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10029.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10029.png Binary files differnew file mode 100644 index 0000000..9d7e888 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10029.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10030.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10030.png Binary files differnew file mode 100644 index 0000000..39b2ad2 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10030.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10031.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10031.png Binary files differnew file mode 100644 index 0000000..257ec7b --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10031.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock2.ini b/examples/graphicsview/portedasteroids/sprites/rock2/rock2.ini new file mode 100644 index 0000000..d50e6fa --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock2.ini @@ -0,0 +1,9 @@ +Cyclic_Animation=On +Width=32 +Height=32 +Final_frame=32 ;; NR_ROTS +Antialias=On +Output_Alpha=On +Output_to_File=On +Output_File_Type=n +Input_File_Name=rock2.pov diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock2.pov b/examples/graphicsview/portedasteroids/sprites/rock2/rock2.pov new file mode 100644 index 0000000..2f37a20 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock2.pov @@ -0,0 +1,26 @@ +#include "colors.inc" +#include "shapes.inc" +#include "textures.inc" +// #include "stones.inc" + +camera { + location <2,2,-6> + up <0, 1, 0> +// right <4/3, 0, 0> + look_at <0,0,0> +} + +object { light_source { <10, 5, -5> color red 1.1 green 1.1 blue 1.0 } } + +#declare Rock = +mesh { + #include "rock.inc" /* collection of triangle or smooth_triangle data */ +} + +object { + Rock + texture { pigment {White} } + scale 1.9 + rotate <60, 30, 360*clock> +} + diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20000.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20000.png Binary files differnew file mode 100644 index 0000000..5cb52bb --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20000.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20001.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20001.png Binary files differnew file mode 100644 index 0000000..d765be1 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20001.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20002.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20002.png Binary files differnew file mode 100644 index 0000000..84e2380 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20002.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20003.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20003.png Binary files differnew file mode 100644 index 0000000..39772b8 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20003.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20004.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20004.png Binary files differnew file mode 100644 index 0000000..b983079 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20004.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20005.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20005.png Binary files differnew file mode 100644 index 0000000..70bb4d8 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20005.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20006.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20006.png Binary files differnew file mode 100644 index 0000000..cf5c2f4 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20006.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20007.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20007.png Binary files differnew file mode 100644 index 0000000..479c21d --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20007.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20008.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20008.png Binary files differnew file mode 100644 index 0000000..871abca --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20008.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20009.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20009.png Binary files differnew file mode 100644 index 0000000..bc31fbb --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20009.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20010.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20010.png Binary files differnew file mode 100644 index 0000000..1da9953 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20010.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20011.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20011.png Binary files differnew file mode 100644 index 0000000..d542c6e --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20011.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20012.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20012.png Binary files differnew file mode 100644 index 0000000..d104ff9 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20012.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20013.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20013.png Binary files differnew file mode 100644 index 0000000..e12943d --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20013.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20014.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20014.png Binary files differnew file mode 100644 index 0000000..dc7529c --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20014.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20015.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20015.png Binary files differnew file mode 100644 index 0000000..0b49c2c --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20015.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20016.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20016.png Binary files differnew file mode 100644 index 0000000..adbad98 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20016.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20017.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20017.png Binary files differnew file mode 100644 index 0000000..5a8aeef --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20017.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20018.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20018.png Binary files differnew file mode 100644 index 0000000..11c6af4 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20018.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20019.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20019.png Binary files differnew file mode 100644 index 0000000..026b72b --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20019.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20020.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20020.png Binary files differnew file mode 100644 index 0000000..8bc7e20 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20020.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20021.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20021.png Binary files differnew file mode 100644 index 0000000..e0a7626 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20021.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20022.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20022.png Binary files differnew file mode 100644 index 0000000..5796e12 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20022.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20023.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20023.png Binary files differnew file mode 100644 index 0000000..d2cf0c6 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20023.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20024.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20024.png Binary files differnew file mode 100644 index 0000000..071ce21 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20024.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20025.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20025.png Binary files differnew file mode 100644 index 0000000..ae8101d --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20025.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20026.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20026.png Binary files differnew file mode 100644 index 0000000..f2681d4 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20026.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20027.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20027.png Binary files differnew file mode 100644 index 0000000..e83fd41 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20027.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20028.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20028.png Binary files differnew file mode 100644 index 0000000..5621b4d --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20028.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20029.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20029.png Binary files differnew file mode 100644 index 0000000..aec4a34 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20029.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20030.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20030.png Binary files differnew file mode 100644 index 0000000..89a8f5f --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20030.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20031.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20031.png Binary files differnew file mode 100644 index 0000000..69f5375 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20031.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock3.ini b/examples/graphicsview/portedasteroids/sprites/rock3/rock3.ini new file mode 100644 index 0000000..26a3cf9 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock3.ini @@ -0,0 +1,9 @@ +Cyclic_Animation=On +Width=20 +Height=20 +Final_frame=32 ;; NR_ROTS +Antialias=On +Output_Alpha=On +Output_to_File=On +Output_File_Type=n +Input_File_Name=rock3.pov diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock3.pov b/examples/graphicsview/portedasteroids/sprites/rock3/rock3.pov new file mode 100644 index 0000000..2f37a20 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock3.pov @@ -0,0 +1,26 @@ +#include "colors.inc" +#include "shapes.inc" +#include "textures.inc" +// #include "stones.inc" + +camera { + location <2,2,-6> + up <0, 1, 0> +// right <4/3, 0, 0> + look_at <0,0,0> +} + +object { light_source { <10, 5, -5> color red 1.1 green 1.1 blue 1.0 } } + +#declare Rock = +mesh { + #include "rock.inc" /* collection of triangle or smooth_triangle data */ +} + +object { + Rock + texture { pigment {White} } + scale 1.9 + rotate <60, 30, 360*clock> +} + diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30000.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30000.png Binary files differnew file mode 100644 index 0000000..de1205a --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30000.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30001.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30001.png Binary files differnew file mode 100644 index 0000000..12ebc00 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30001.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30002.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30002.png Binary files differnew file mode 100644 index 0000000..ebb899e --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30002.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30003.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30003.png Binary files differnew file mode 100644 index 0000000..1ff7a06 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30003.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30004.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30004.png Binary files differnew file mode 100644 index 0000000..5b505bf --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30004.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30005.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30005.png Binary files differnew file mode 100644 index 0000000..f9680dc --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30005.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30006.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30006.png Binary files differnew file mode 100644 index 0000000..e29746a --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30006.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30007.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30007.png Binary files differnew file mode 100644 index 0000000..f01baa6 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30007.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30008.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30008.png Binary files differnew file mode 100644 index 0000000..cd10711 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30008.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30009.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30009.png Binary files differnew file mode 100644 index 0000000..4f32955 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30009.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30010.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30010.png Binary files differnew file mode 100644 index 0000000..bb61d54 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30010.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30011.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30011.png Binary files differnew file mode 100644 index 0000000..8486e5a --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30011.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30012.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30012.png Binary files differnew file mode 100644 index 0000000..d9ae419 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30012.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30013.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30013.png Binary files differnew file mode 100644 index 0000000..ce69400 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30013.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30014.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30014.png Binary files differnew file mode 100644 index 0000000..981e92c --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30014.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30015.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30015.png Binary files differnew file mode 100644 index 0000000..b8fb00c --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30015.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30016.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30016.png Binary files differnew file mode 100644 index 0000000..72bc42f --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30016.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30017.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30017.png Binary files differnew file mode 100644 index 0000000..c89f358 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30017.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30018.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30018.png Binary files differnew file mode 100644 index 0000000..e1ba724 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30018.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30019.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30019.png Binary files differnew file mode 100644 index 0000000..5f004a7 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30019.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30020.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30020.png Binary files differnew file mode 100644 index 0000000..58009bf --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30020.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30021.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30021.png Binary files differnew file mode 100644 index 0000000..8d9549c --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30021.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30022.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30022.png Binary files differnew file mode 100644 index 0000000..1e8a1c2 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30022.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30023.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30023.png Binary files differnew file mode 100644 index 0000000..9b960d6 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30023.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30024.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30024.png Binary files differnew file mode 100644 index 0000000..6c15f2b --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30024.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30025.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30025.png Binary files differnew file mode 100644 index 0000000..12b05da --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30025.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30026.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30026.png Binary files differnew file mode 100644 index 0000000..16190e9 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30026.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30027.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30027.png Binary files differnew file mode 100644 index 0000000..a862501 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30027.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30028.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30028.png Binary files differnew file mode 100644 index 0000000..e3e0c18 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30028.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30029.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30029.png Binary files differnew file mode 100644 index 0000000..ec70b84 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30029.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30030.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30030.png Binary files differnew file mode 100644 index 0000000..da48df1 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30030.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30031.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30031.png Binary files differnew file mode 100644 index 0000000..c1dc1b9 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30031.png diff --git a/examples/graphicsview/portedasteroids/sprites/shield/shield0000.png b/examples/graphicsview/portedasteroids/sprites/shield/shield0000.png Binary files differnew file mode 100644 index 0000000..7233254 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/shield/shield0000.png diff --git a/examples/graphicsview/portedasteroids/sprites/shield/shield0001.png b/examples/graphicsview/portedasteroids/sprites/shield/shield0001.png Binary files differnew file mode 100644 index 0000000..2b0bc9d --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/shield/shield0001.png diff --git a/examples/graphicsview/portedasteroids/sprites/shield/shield0002.png b/examples/graphicsview/portedasteroids/sprites/shield/shield0002.png Binary files differnew file mode 100644 index 0000000..cdc0fe3 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/shield/shield0002.png diff --git a/examples/graphicsview/portedasteroids/sprites/shield/shield0003.png b/examples/graphicsview/portedasteroids/sprites/shield/shield0003.png Binary files differnew file mode 100644 index 0000000..979ed5a --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/shield/shield0003.png diff --git a/examples/graphicsview/portedasteroids/sprites/shield/shield0004.png b/examples/graphicsview/portedasteroids/sprites/shield/shield0004.png Binary files differnew file mode 100644 index 0000000..0bb93a2 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/shield/shield0004.png diff --git a/examples/graphicsview/portedasteroids/sprites/shield/shield0005.png b/examples/graphicsview/portedasteroids/sprites/shield/shield0005.png Binary files differnew file mode 100644 index 0000000..32210bd --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/shield/shield0005.png diff --git a/examples/graphicsview/portedasteroids/sprites/shield/shield0006.png b/examples/graphicsview/portedasteroids/sprites/shield/shield0006.png Binary files differnew file mode 100644 index 0000000..76c9920 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/shield/shield0006.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship.ini b/examples/graphicsview/portedasteroids/sprites/ship/ship.ini new file mode 100644 index 0000000..479cc20 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship.ini @@ -0,0 +1,9 @@ +Cyclic_Animation=On +Width=42 +Height=42 +Final_frame=32 ;; NR_ROTS +Antialias=On +Output_Alpha=On +Output_to_File=On +Output_File_Type=n +Input_File_Name=ship.pov diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship.pov b/examples/graphicsview/portedasteroids/sprites/ship/ship.pov new file mode 100644 index 0000000..8f185cd --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship.pov @@ -0,0 +1,128 @@ + +#version 3.0 +global_settings { assumed_gamma 2.0 } + +#include "colors.inc" +#include "textures.inc" +#include "metals.inc" + +camera { + orthographic + up <0, 130, 0> + right <130, 0, 0> + location <0, 0, -130> + look_at <0, 0, 0> +} + +light_source { <50, 25, -25> colour White } +light_source { <0, 0, -100> colour Gray80 } + +#declare ShipColor = color red 1.0 green 1.0 blue 0.9 + +#declare BaseTexture = +texture { + pigment { ShipColor } +} + +#declare Grubby = +texture { + pigment { + bozo + color_map { + [0.0 color rgbt <1, 1, 1, 1>] + [0.8 color rgbt <0.9, 0.9, 0.9, 0.5>] + [1.0 color rgbt <0.8, 0.8, 0.8, 0.5>] + } + turbulence 2.0 + scale 3 + } +} + +#declare ShipTexture = +texture { BaseTexture } +texture { Grubby } + +union { + cone { + <12, 0, 0>, 0.5 + <11, 0, 0>, 1.0 + texture { ShipTexture } + } + cone { + <11, 0, 0>, 1.0 + <8, 0, 0>, 2.0 + texture { ShipTexture } + } + cone { + <8, 0, 0>, 2.0 + <3.5, 0, 0>, 3.8 + texture { ShipTexture } + } + difference { + cone { + <8, 0, -0.01>, 2.0 + <3.5, 0, -0.01>, 3.8 + pigment { color Gray20 } + } + box { + <9, -4.0, -3.7>, + <2, 4.0, 10> + rotate <0, -18, 0> + } + box { + <6.5, -4.0, -8>, + <10, 4.0, 8> + } + box { + <2, -4.0, -8>, + <4.5, 4.0, 8> + } + } + cone { + <3.5, 0, 0>, 3.8 + <2, 0, 0>, 4.0 + texture { ShipTexture } + } + cylinder { + <2, 0, 0>, + <-9, 0, 0>, + 4.0 + texture { ShipTexture } + } + cone { + <-9, 0, 0>, 4.0 + <-10, 0, 0>, 3.5 + texture { ShipTexture } + } + prism { + linear_sweep + linear_spline + 0, + 0.5, + 4, + <7.5, 0>, <-7.5, 10>, <-7.5, -10>, <7.5, 0> + rotate <90, 0, 0> + texture { T_Silver_2A } + texture { ShipTexture } + } + prism { + linear_sweep + linear_spline + -0.5, + 0.5, + 4, + <4, 0>, <-7.5, 5>, <-7.5, -5>, <4, 0> + pigment { color White } + } + cone { + <-12, 0, 0>, 3.0 + <-10, 0, 0>, 2.0 + texture { T_Silver_2A } + pigment { color Gray60 } + } + + rotate <0, 0,-360*clock> + scale <5, 5, 5> +} + + diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0000.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0000.png Binary files differnew file mode 100644 index 0000000..a8f1bb3 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0000.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0001.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0001.png Binary files differnew file mode 100644 index 0000000..861f130 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0001.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0002.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0002.png Binary files differnew file mode 100644 index 0000000..418ced1 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0002.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0003.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0003.png Binary files differnew file mode 100644 index 0000000..50a386b --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0003.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0004.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0004.png Binary files differnew file mode 100644 index 0000000..f2bc0bc --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0004.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0005.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0005.png Binary files differnew file mode 100644 index 0000000..7280485 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0005.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0006.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0006.png Binary files differnew file mode 100644 index 0000000..51d26e9 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0006.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0007.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0007.png Binary files differnew file mode 100644 index 0000000..682c042 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0007.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0008.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0008.png Binary files differnew file mode 100644 index 0000000..003d7fa --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0008.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0009.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0009.png Binary files differnew file mode 100644 index 0000000..538b879 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0009.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0010.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0010.png Binary files differnew file mode 100644 index 0000000..17999cd --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0010.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0011.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0011.png Binary files differnew file mode 100644 index 0000000..1a4bbe9 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0011.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0012.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0012.png Binary files differnew file mode 100644 index 0000000..2523d85 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0012.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0013.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0013.png Binary files differnew file mode 100644 index 0000000..8bd5971 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0013.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0014.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0014.png Binary files differnew file mode 100644 index 0000000..a164ab7 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0014.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0015.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0015.png Binary files differnew file mode 100644 index 0000000..ca8e0b9 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0015.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0016.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0016.png Binary files differnew file mode 100644 index 0000000..cfaf8c4 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0016.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0017.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0017.png Binary files differnew file mode 100644 index 0000000..8049617 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0017.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0018.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0018.png Binary files differnew file mode 100644 index 0000000..4a3421b --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0018.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0019.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0019.png Binary files differnew file mode 100644 index 0000000..786d375 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0019.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0020.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0020.png Binary files differnew file mode 100644 index 0000000..bd4365c --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0020.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0021.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0021.png Binary files differnew file mode 100644 index 0000000..eb358c1 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0021.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0022.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0022.png Binary files differnew file mode 100644 index 0000000..eb865e1 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0022.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0023.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0023.png Binary files differnew file mode 100644 index 0000000..3738ce2 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0023.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0024.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0024.png Binary files differnew file mode 100644 index 0000000..a7c1adc --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0024.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0025.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0025.png Binary files differnew file mode 100644 index 0000000..2ca3aae --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0025.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0026.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0026.png Binary files differnew file mode 100644 index 0000000..4661ca5 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0026.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0027.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0027.png Binary files differnew file mode 100644 index 0000000..f5c9203 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0027.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0028.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0028.png Binary files differnew file mode 100644 index 0000000..08353d4 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0028.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0029.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0029.png Binary files differnew file mode 100644 index 0000000..8685d31 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0029.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0030.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0030.png Binary files differnew file mode 100644 index 0000000..78dd469 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0030.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0031.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0031.png Binary files differnew file mode 100644 index 0000000..6cd0643 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0031.png diff --git a/examples/graphicsview/portedasteroids/toplevel.cpp b/examples/graphicsview/portedasteroids/toplevel.cpp new file mode 100644 index 0000000..367f8c6 --- /dev/null +++ b/examples/graphicsview/portedasteroids/toplevel.cpp @@ -0,0 +1,542 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/* + * KAsteroids - Copyright (c) Martin R. Jones 1997 + * + * Part of the KDE project + */ +// --- toplevel.cpp --- +#include <q3accel.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qlcdnumber.h> +#include <qpushbutton.h> + +#include <qapplication.h> +//Added by qt3to4: +#include <Q3HBoxLayout> +#include <QShowEvent> +#include <Q3Frame> +#include <QPixmap> +#include <QHideEvent> +#include <QKeyEvent> +#include <Q3VBoxLayout> + +#include "toplevel.h" +#include "ledmeter.h" + + +#define SB_SCORE 1 +#define SB_LEVEL 2 +#define SB_SHIPS 3 + +struct SLevel +{ + int nrocks; + double rockSpeed; +}; + +#define MAX_LEVELS 16 + +SLevel levels[MAX_LEVELS] = +{ + { 1, 0.4 }, + { 1, 0.6 }, + { 2, 0.5 }, + { 2, 0.7 }, + { 2, 0.8 }, + { 3, 0.6 }, + { 3, 0.7 }, + { 3, 0.8 }, + { 4, 0.6 }, + { 4, 0.7 }, + { 4, 0.8 }, + { 5, 0.7 }, + { 5, 0.8 }, + { 5, 0.9 }, + { 5, 1.0 } +}; + +const char *soundEvents[] = +{ + "ShipDestroyed", + "RockDestroyed", + 0 +}; + +const char *soundDefaults[] = +{ + "Explosion.wav", + "ploop.wav", + 0 +}; + + +KAstTopLevel::KAstTopLevel( QWidget *parent, const char *name ) + : Q3MainWindow( parent, name, 0 ) +{ + QWidget *border = new QWidget( this ); + border->setBackgroundColor( Qt::black ); + setCentralWidget( border ); + + Q3VBoxLayout *borderLayout = new Q3VBoxLayout( border ); + borderLayout->addStretch( 1 ); + + QWidget *mainWin = new QWidget( border ); + mainWin->setFixedSize(640, 480); + borderLayout->addWidget( mainWin, 0, Qt::AlignHCenter ); + + borderLayout->addStretch( 1 ); + + view = new KAsteroidsView( mainWin ); + view->setFocusPolicy( Qt::StrongFocus ); + connect( view, SIGNAL(shipKilled()), SLOT(slotShipKilled()) ); + connect( view, SIGNAL(rockHit(int)), SLOT(slotRockHit(int)) ); + connect( view, SIGNAL(rocksRemoved()), SLOT(slotRocksRemoved()) ); + connect( view, SIGNAL(updateVitals()), SLOT(slotUpdateVitals()) ); + + Q3VBoxLayout *vb = new Q3VBoxLayout( mainWin ); + Q3HBoxLayout *hb = new Q3HBoxLayout; + Q3HBoxLayout *hbd = new Q3HBoxLayout; + vb->addLayout( hb ); + + QFont labelFont( "helvetica", 24 ); + QColorGroup grp( Qt::darkGreen, Qt::black, QColor( 128, 128, 128 ), + QColor( 64, 64, 64 ), Qt::black, Qt::darkGreen, Qt::black ); + QPalette pal( grp, grp, grp ); + + mainWin->setPalette( pal ); + + hb->addSpacing( 10 ); + + QLabel *label; + label = new QLabel( tr("Score"), mainWin ); + label->setFont( labelFont ); + label->setPalette( pal ); + label->setFixedWidth( label->sizeHint().width() ); + hb->addWidget( label ); + + scoreLCD = new QLCDNumber( 6, mainWin ); + scoreLCD->setFrameStyle( Q3Frame::NoFrame ); + scoreLCD->setSegmentStyle( QLCDNumber::Flat ); + scoreLCD->setFixedWidth( 150 ); + scoreLCD->setPalette( pal ); + hb->addWidget( scoreLCD ); + hb->addStretch( 10 ); + + label = new QLabel( tr("Level"), mainWin ); + label->setFont( labelFont ); + label->setPalette( pal ); + label->setFixedWidth( label->sizeHint().width() ); + hb->addWidget( label ); + + levelLCD = new QLCDNumber( 2, mainWin ); + levelLCD->setFrameStyle( Q3Frame::NoFrame ); + levelLCD->setSegmentStyle( QLCDNumber::Flat ); + levelLCD->setFixedWidth( 70 ); + levelLCD->setPalette( pal ); + hb->addWidget( levelLCD ); + hb->addStretch( 10 ); + + label = new QLabel( tr("Ships"), mainWin ); + label->setFont( labelFont ); + label->setFixedWidth( label->sizeHint().width() ); + label->setPalette( pal ); + hb->addWidget( label ); + + shipsLCD = new QLCDNumber( 1, mainWin ); + shipsLCD->setFrameStyle( Q3Frame::NoFrame ); + shipsLCD->setSegmentStyle( QLCDNumber::Flat ); + shipsLCD->setFixedWidth( 40 ); + shipsLCD->setPalette( pal ); + hb->addWidget( shipsLCD ); + + hb->addStrut( 30 ); + + vb->addWidget( view, 10 ); + +// -- bottom layout: + vb->addLayout( hbd ); + + QFont smallFont( "helvetica", 14 ); + hbd->addSpacing( 10 ); + + QString sprites_prefix = ":/trolltech/examples/graphicsview/portedasteroids/sprites/"; +/* + label = new QLabel( tr( "T" ), mainWin ); + label->setFont( smallFont ); + label->setFixedWidth( label->sizeHint().width() ); + label->setPalette( pal ); + hbd->addWidget( label ); + + teleportsLCD = new QLCDNumber( 1, mainWin ); + teleportsLCD->setFrameStyle( QFrame::NoFrame ); + teleportsLCD->setSegmentStyle( QLCDNumber::Flat ); + teleportsLCD->setPalette( pal ); + teleportsLCD->setFixedHeight( 20 ); + hbd->addWidget( teleportsLCD ); + + hbd->addSpacing( 10 ); +*/ + QPixmap pm( sprites_prefix + "powerups/brake.png" ); + label = new QLabel( mainWin ); + label->setPixmap( pm ); + label->setFixedWidth( label->sizeHint().width() ); + label->setPalette( pal ); + hbd->addWidget( label ); + + brakesLCD = new QLCDNumber( 1, mainWin ); + brakesLCD->setFrameStyle( Q3Frame::NoFrame ); + brakesLCD->setSegmentStyle( QLCDNumber::Flat ); + brakesLCD->setPalette( pal ); + brakesLCD->setFixedHeight( 20 ); + hbd->addWidget( brakesLCD ); + + hbd->addSpacing( 10 ); + + pm.load( sprites_prefix + "powerups/shield.png" ); + label = new QLabel( mainWin ); + label->setPixmap( pm ); + label->setFixedWidth( label->sizeHint().width() ); + label->setPalette( pal ); + hbd->addWidget( label ); + + shieldLCD = new QLCDNumber( 1, mainWin ); + shieldLCD->setFrameStyle( Q3Frame::NoFrame ); + shieldLCD->setSegmentStyle( QLCDNumber::Flat ); + shieldLCD->setPalette( pal ); + shieldLCD->setFixedHeight( 20 ); + hbd->addWidget( shieldLCD ); + + hbd->addSpacing( 10 ); + + pm.load( sprites_prefix + "powerups/shoot.png" ); + label = new QLabel( mainWin ); + label->setPixmap( pm ); + label->setFixedWidth( label->sizeHint().width() ); + label->setPalette( pal ); + hbd->addWidget( label ); + + shootLCD = new QLCDNumber( 1, mainWin ); + shootLCD->setFrameStyle( Q3Frame::NoFrame ); + shootLCD->setSegmentStyle( QLCDNumber::Flat ); + shootLCD->setPalette( pal ); + shootLCD->setFixedHeight( 20 ); + hbd->addWidget( shootLCD ); + + hbd->addStretch( 1 ); + + label = new QLabel( tr( "Fuel" ), mainWin ); + label->setFont( smallFont ); + label->setFixedWidth( label->sizeHint().width() + 10 ); + label->setPalette( pal ); + hbd->addWidget( label ); + + powerMeter = new KALedMeter( mainWin ); + powerMeter->setFrameStyle( Q3Frame::Box | Q3Frame::Plain ); + powerMeter->setRange( MAX_POWER_LEVEL ); + powerMeter->addColorRange( 10, Qt::darkRed ); + powerMeter->addColorRange( 20, QColor(160, 96, 0) ); + powerMeter->addColorRange( 70, Qt::darkGreen ); + powerMeter->setCount( 40 ); + powerMeter->setPalette( pal ); + powerMeter->setFixedSize( 200, 12 ); + hbd->addWidget( powerMeter ); + + shipsRemain = 3; + showHiscores = FALSE; + + actions.insert( Qt::Key_Up, Thrust ); + actions.insert( Qt::Key_Left, RotateLeft ); + actions.insert( Qt::Key_Right, RotateRight ); + actions.insert( Qt::Key_Space, Shoot ); + actions.insert( Qt::Key_Z, Teleport ); + actions.insert( Qt::Key_X, Brake ); + actions.insert( Qt::Key_S, Shield ); + actions.insert( Qt::Key_P, Pause ); + actions.insert( Qt::Key_L, Launch ); + actions.insert( Qt::Key_N, NewGame ); + + view->showText( tr( "Press N to start playing" ), Qt::yellow ); +} + +KAstTopLevel::~KAstTopLevel() +{ +} + +void KAstTopLevel::playSound( const char * ) +{ +} + +void KAstTopLevel::keyPressEvent( QKeyEvent *event ) +{ + if ( event->isAutoRepeat() || !actions.contains( event->key() ) ) + { + event->ignore(); + return; + } + + Action a = actions[ event->key() ]; + + switch ( a ) + { + case RotateLeft: + view->rotateLeft( TRUE ); + break; + + case RotateRight: + view->rotateRight( TRUE ); + break; + + case Thrust: + view->thrust( TRUE ); + break; + + case Shoot: + view->shoot( TRUE ); + break; + + case Shield: + view->setShield( TRUE ); + break; + + case Teleport: + view->teleport( TRUE ); + break; + + case Brake: + view->brake( TRUE ); + break; + + default: + event->ignore(); + return; + } + event->accept(); +} + +void KAstTopLevel::keyReleaseEvent( QKeyEvent *event ) +{ + if ( event->isAutoRepeat() || !actions.contains( event->key() ) ) + { + event->ignore(); + return; + } + + Action a = actions[ event->key() ]; + + switch ( a ) + { + case RotateLeft: + view->rotateLeft( FALSE ); + break; + + case RotateRight: + view->rotateRight( FALSE ); + break; + + case Thrust: + view->thrust( FALSE ); + break; + + case Shoot: + view->shoot( FALSE ); + break; + + case Brake: + view->brake( FALSE ); + break; + + case Shield: + view->setShield( FALSE ); + break; + + case Teleport: + view->teleport( FALSE ); + break; + + case Launch: + if ( waitShip ) + { + view->newShip(); + waitShip = FALSE; + view->hideText(); + } + else + { + event->ignore(); + return; + } + break; + + case NewGame: + slotNewGame(); + break; +/* + case Pause: + { + view->pause( TRUE ); + QMessageBox::information( this, + tr("KAsteroids is paused"), + tr("Paused") ); + view->pause( FALSE ); + } + break; +*/ + default: + event->ignore(); + return; + } + + event->accept(); +} + +void KAstTopLevel::showEvent( QShowEvent *e ) +{ + Q3MainWindow::showEvent( e ); + view->pause( FALSE ); + view->setFocus(); +} + +void KAstTopLevel::hideEvent( QHideEvent *e ) +{ + Q3MainWindow::hideEvent( e ); + view->pause( TRUE ); +} + +void KAstTopLevel::slotNewGame() +{ + score = 0; + shipsRemain = SB_SHIPS; + scoreLCD->display( 0 ); + level = 0; + levelLCD->display( level+1 ); + shipsLCD->display( shipsRemain-1 ); + view->newGame(); + view->setRockSpeed( levels[0].rockSpeed ); + view->addRocks( levels[0].nrocks ); +// view->showText( tr( "Press L to launch." ), yellow ); + view->newShip(); + waitShip = FALSE; + view->hideText(); + isPaused = FALSE; +} + +void KAstTopLevel::slotShipKilled() +{ + shipsRemain--; + shipsLCD->display( shipsRemain-1 ); + + playSound( "ShipDestroyed" ); + + if ( shipsRemain ) + { + waitShip = TRUE; + view->showText( tr( "Ship Destroyed. Press L to launch."), Qt::yellow ); + } + else + { + view->showText( tr("Game Over!"), Qt::red ); + view->endGame(); + doStats(); +// highscore->addEntry( score, level, showHiscores ); + } +} + +void KAstTopLevel::slotRockHit( int size ) +{ + switch ( size ) + { + case 0: + score += 10; + break; + + case 1: + score += 20; + break; + + default: + score += 40; + } + + playSound( "RockDestroyed" ); + + scoreLCD->display( score ); +} + +void KAstTopLevel::slotRocksRemoved() +{ + level++; + + if ( level >= MAX_LEVELS ) + level = MAX_LEVELS - 1; + + view->setRockSpeed( levels[level-1].rockSpeed ); + view->addRocks( levels[level-1].nrocks ); + + levelLCD->display( level+1 ); +} + +void KAstTopLevel::doStats() +{ + QString r( "0.00" ); + if ( view->shots() ) + r = QString::number( (double)view->hits() / view->shots() * 100.0, + 'g', 2 ); + +/* multi-line text broken in Qt 3 + QString s = tr( "Game Over\n\nShots fired:\t%1\n Hit:\t%2\n Missed:\t%3\nHit ratio:\t%4 %\n\nPress N for a new game" ) + .arg(view->shots()).arg(view->hits()) + .arg(view->shots() - view->hits()) + .arg(r); +*/ + + view->showText( "Game Over. Press N for a new game.", Qt::yellow, FALSE ); +} + +void KAstTopLevel::slotUpdateVitals() +{ + brakesLCD->display( view->brakeCount() ); + shieldLCD->display( view->shieldCount() ); + shootLCD->display( view->shootCount() ); +// teleportsLCD->display( view->teleportCount() ); + powerMeter->setValue( view->power() ); +} diff --git a/examples/graphicsview/portedasteroids/toplevel.h b/examples/graphicsview/portedasteroids/toplevel.h new file mode 100644 index 0000000..767580e --- /dev/null +++ b/examples/graphicsview/portedasteroids/toplevel.h @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/* + * KAsteroids - Copyright (c) Martin R. Jones 1997 + * + * Part of the KDE project + */ + +#ifndef __KAST_TOPLEVEL_H__ +#define __KAST_TOPLEVEL_H__ + +#include <q3mainwindow.h> +#include <q3dict.h> +#include <qmap.h> +//Added by qt3to4: +#include <QShowEvent> +#include <QHideEvent> +#include <QKeyEvent> + +#include "view.h" + + +class KALedMeter; +QT_BEGIN_NAMESPACE +class QLCDNumber; +QT_END_NAMESPACE + +class KAstTopLevel : public Q3MainWindow +{ + Q_OBJECT +public: + KAstTopLevel( QWidget *parent=0, const char *name=0 ); + virtual ~KAstTopLevel(); + +private: + void playSound( const char *snd ); + void readSoundMapping(); + void doStats(); + +protected: + virtual void showEvent( QShowEvent * ); + virtual void hideEvent( QHideEvent * ); + virtual void keyPressEvent( QKeyEvent *event ); + virtual void keyReleaseEvent( QKeyEvent *event ); + +private slots: + void slotNewGame(); + + void slotShipKilled(); + void slotRockHit( int size ); + void slotRocksRemoved(); + + void slotUpdateVitals(); + +private: + KAsteroidsView *view; + QLCDNumber *scoreLCD; + QLCDNumber *levelLCD; + QLCDNumber *shipsLCD; + + QLCDNumber *teleportsLCD; +// QLCDNumber *bombsLCD; + QLCDNumber *brakesLCD; + QLCDNumber *shieldLCD; + QLCDNumber *shootLCD; + KALedMeter *powerMeter; + + bool sound; + Q3Dict<QString> soundDict; + + // waiting for user to press Enter to launch a ship + bool waitShip; + bool isPaused; + + int shipsRemain; + int score; + int level; + bool showHiscores; + + enum Action { Launch, Thrust, RotateLeft, RotateRight, Shoot, Teleport, + Brake, Shield, Pause, NewGame }; + + QMap<int,Action> actions; +}; + +#endif + diff --git a/examples/graphicsview/portedasteroids/view.cpp b/examples/graphicsview/portedasteroids/view.cpp new file mode 100644 index 0000000..9429111 --- /dev/null +++ b/examples/graphicsview/portedasteroids/view.cpp @@ -0,0 +1,966 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/* + * KAsteroids - Copyright (c) Martin R. Jones 1997 + * + * Part of the KDE project + */ + +#include <stdlib.h> +#include <math.h> +#include <qapplication.h> +#include <qnamespace.h> +#include <q3accel.h> +#include <qmessagebox.h> +#include <q3scrollview.h> +#include <qdir.h> +#include <QGraphicsItem> +//Added by qt3to4: +#include <QTimerEvent> +#include <QPixmap> +#include <QResizeEvent> +#include <QShowEvent> + +#include "view.h" + +#define IMG_BACKGROUND ":/trolltech/examples/graphicsview/portedasteroids/bg.png" + +#define REFRESH_DELAY 33 +#define SHIP_SPEED 0.3 +#define MISSILE_SPEED 10.0 +#define SHIP_STEPS 64 +#define ROTATE_RATE 2 +#define SHIELD_ON_COST 1 +#define SHIELD_HIT_COST 30 +#define BRAKE_ON_COST 4 + +#define MAX_ROCK_SPEED 2.5 +#define MAX_POWERUP_SPEED 1.5 +#define MAX_SHIP_SPEED 12 +#define MAX_BRAKES 5 +#define MAX_SHIELDS 5 +#define MAX_FIREPOWER 5 + +#define TEXT_SPEED 4 + +#define PI_X_2 6.283185307 +#ifndef M_PI +#define M_PI 3.141592654 +#endif + +static struct +{ + int id; + const char *path; + int frames; +} +kas_animations [] = +{ + { ID_ROCK_LARGE, "rock1/rock1%1.png", 32 }, + { ID_ROCK_MEDIUM, "rock2/rock2%1.png", 32 }, + { ID_ROCK_SMALL, "rock3/rock3%1.png", 32 }, + { ID_SHIP, "ship/ship%1.png", 32 }, + { ID_MISSILE, "missile/missile.png", 1 }, + { ID_BIT, "bits/bits%1.png", 16 }, + { ID_EXHAUST, "exhaust/exhaust.png", 1 }, + { ID_ENERGY_POWERUP, "powerups/energy.png", 1 }, +// { ID_TELEPORT_POWERUP, "powerups/teleport%1.png", 12 }, + { ID_BRAKE_POWERUP, "powerups/brake.png", 1 }, + { ID_SHIELD_POWERUP, "powerups/shield.png", 1 }, + { ID_SHOOT_POWERUP, "powerups/shoot.png", 1 }, + { ID_SHIELD, "shield/shield%1.png", 6 }, + { 0, 0, 0 } +}; + +KAsteroidsView::KAsteroidsView( QWidget *parent, const char *name ) + : QWidget( parent, name ), + field(0, 0, 640, 440), + view(&field,this) +{ + view.setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); + view.setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); + view.setCacheMode(QGraphicsView::CacheBackground); + view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); + view.setOptimizationFlags(QGraphicsView::DontClipPainter + | QGraphicsView::DontSavePainterState + | QGraphicsView::DontAdjustForAntialiasing); + view.viewport()->setFocusProxy( this ); + rocks.setAutoDelete( TRUE ); + missiles.setAutoDelete( TRUE ); + bits.setAutoDelete( TRUE ); + powerups.setAutoDelete( TRUE ); + exhaust.setAutoDelete( TRUE ); + + QPixmap pm( IMG_BACKGROUND ); + field.setBackgroundBrush( pm ); + + textSprite = new QGraphicsTextItem( 0, &field ); + QFont font( "helvetica", 18 ); + textSprite->setFont( font ); + textSprite->setCacheMode(QGraphicsItem::DeviceCoordinateCache); + + shield = 0; + shieldOn = FALSE; + refreshRate = REFRESH_DELAY; + + initialized = readSprites(); + + shieldTimer = new QTimer( this ); + connect( shieldTimer, SIGNAL(timeout()), this, SLOT(hideShield()) ); + mTimerId = -1; + + shipPower = MAX_POWER_LEVEL; + vitalsChanged = TRUE; + can_destroy_powerups = FALSE; + + mPaused = TRUE; + + if ( !initialized ) { + textSprite->setHtml( tr("<font color=red>Error: Cannot read sprite images</font>") ); + textSprite->setPos( (field.width()-textSprite->boundingRect().width()) / 2, + (field.height()-textSprite->boundingRect().height()) / 2 ); + } +} + +// - - - + +KAsteroidsView::~KAsteroidsView() +{ +} + +// - - - + +void KAsteroidsView::reset() +{ + if ( !initialized ) + return; + rocks.clear(); + missiles.clear(); + bits.clear(); + powerups.clear(); + exhaust.clear(); + + shotsFired = 0; + shotsHit = 0; + + rockSpeed = 1.0; + powerupSpeed = 1.0; + mFrameNum = 0; + mPaused = FALSE; + + ship->hide(); + shield->hide(); +/* + if ( mTimerId >= 0 ) { + killTimer( mTimerId ); + mTimerId = -1; + } +*/ +} + +// - -- + +void KAsteroidsView::newGame() +{ + if ( !initialized ) + return; + if ( shieldOn ) + { + shield->hide(); + shieldOn = FALSE; + } + reset(); + if ( mTimerId < 0 ) + mTimerId = startTimer( REFRESH_DELAY ); + emit updateVitals(); +} + +// - - - + +void KAsteroidsView::endGame() +{ +} + +void KAsteroidsView::pause( bool p ) +{ + if ( !initialized ) + return; + if ( !mPaused && p ) { + if ( mTimerId >= 0 ) { + killTimer( mTimerId ); + mTimerId = -1; + } + } else if ( mPaused && !p ) + mTimerId = startTimer( REFRESH_DELAY ); + mPaused = p; +} + +// - - - + +void KAsteroidsView::newShip() +{ + if ( !initialized ) + return; + ship->setPos( width()/2, height()/2 ); + ship->setFrame( 0 ); + shield->setPos( width()/2, height()/2 ); + shield->setFrame( 0 ); + ship->setVelocity( 0.0, 0.0 ); + shipDx = 0; + shipDy = 0; + shipAngle = 0; + rotateL = FALSE; + rotateR = FALSE; + thrustShip = FALSE; + shootShip = FALSE; + brakeShip = FALSE; + teleportShip = FALSE; + shieldOn = TRUE; + shootDelay = 0; + shipPower = MAX_POWER_LEVEL; + rotateRate = ROTATE_RATE; + rotateSlow = 0; + + mBrakeCount = 0; + mTeleportCount = 0; + mShootCount = 0; + + ship->show(); + shield->show(); + mShieldCount = 1; // just in case the ship appears on a rock. + shieldTimer->start( 1000, TRUE ); +} + +void KAsteroidsView::setShield( bool s ) +{ + if ( !initialized ) + return; + if ( shieldTimer->isActive() && !s ) { + shieldTimer->stop(); + hideShield(); + } else { + shieldOn = s && mShieldCount; + } +} + +void KAsteroidsView::brake( bool b ) +{ + if ( !initialized ) + return; + if ( mBrakeCount ) + { + if ( brakeShip && !b ) + { + rotateL = FALSE; + rotateR = FALSE; + thrustShip = FALSE; + rotateRate = ROTATE_RATE; + } + + brakeShip = b; + } +} + +// - - - + +bool KAsteroidsView::readSprites() +{ + QString sprites_prefix = ":/trolltech/examples/graphicsview/portedasteroids/sprites/"; + + int i = 0; + while ( kas_animations[i].id ) + { + QList<QPixmap> anim; + QString wildcard = sprites_prefix + kas_animations[i].path; + wildcard.replace("%1", "*"); + QFileInfo fi(wildcard); + foreach (QString entry, QDir(fi.path(), fi.fileName()).entryList()) + anim << QPixmap(fi.path() + "/" + entry); + animation.insert( kas_animations[i].id, anim ); + i++; + } + + ship = new AnimatedPixmapItem( animation[ID_SHIP], &field ); + ship->hide(); + + shield = new KShield( animation[ID_SHIELD], &field ); + shield->hide(); + + return (!ship->image(0).isNull() && !shield->image(0).isNull()); +} + +// - - - + +void KAsteroidsView::addRocks( int num ) +{ + if ( !initialized ) + return; + for ( int i = 0; i < num; i++ ) + { + KRock *rock = new KRock( animation[ID_ROCK_LARGE], &field, + ID_ROCK_LARGE, randInt(2), randInt(2) ? -1 : 1 ); + double dx = (2.0 - randDouble()*4.0) * rockSpeed; + double dy = (2.0 - randDouble()*4.0) * rockSpeed; + rock->setVelocity( dx, dy ); + rock->setFrame( randInt( rock->frameCount() ) ); + if ( dx > 0 ) + { + if ( dy > 0 ) + rock->setPos( 5, 5 ); + else + rock->setPos( 5, field.height() - 25 ); + rock->setFrame( 0 ); + } + else + { + if ( dy > 0 ) + rock->setPos( field.width() - 25, 5 ); + else + rock->setPos( field.width() - 25, field.height() - 25 ); + rock->setFrame( 0 ); + } + rock->show(); + rocks.append( rock ); + } +} + +// - - - + +void KAsteroidsView::showText( const QString &text, const QColor &color, bool scroll ) +{ + if ( !initialized ) + return; + textSprite->setHtml( QString("<font color=#%1%2%3>%4</font>") + .arg(color.red(), 2, 16, QLatin1Char('0')) + .arg(color.green(), 2, 16, QLatin1Char('0')) + .arg(color.blue(), 2, 16, QLatin1Char('0')) + .arg(text) ); + Q_UNUSED(color); + // ### Porting: no such thing textSprite->setColor( color ); + + if ( scroll ) { + textSprite->setPos( (field.width()-textSprite->boundingRect().width()) / 2, + -textSprite->boundingRect().height() ); + textDy = TEXT_SPEED; + } else { + textSprite->setPos( (field.width()-textSprite->boundingRect().width()) / 2, + (field.height()-textSprite->boundingRect().height()) / 2 ); + textDy = 0; + } + textSprite->show(); +} + +// - - - + +void KAsteroidsView::hideText() +{ + textDy = -TEXT_SPEED; +} + +// - - - + +void KAsteroidsView::resizeEvent(QResizeEvent* event) +{ + QWidget::resizeEvent(event); + field.setSceneRect(0, 0, width()-4, height()-4); + view.resize(width(),height()); +} + +// - - - + +void KAsteroidsView::timerEvent( QTimerEvent * ) +{ + field.advance(); + + AnimatedPixmapItem *rock; + + // move rocks forward + for ( rock = rocks.first(); rock; rock = rocks.next() ) { + ((KRock *)rock)->nextFrame(); + wrapSprite( rock ); + } + + wrapSprite( ship ); + + // check for missile collision with rocks. + processMissiles(); + + // these are generated when a ship explodes + for ( KBit *bit = bits.first(); bit; bit = bits.next() ) + { + if ( bit->expired() ) + { + bits.removeRef( bit ); + } + else + { + bit->growOlder(); + bit->setFrame( ( bit->frame()+1 ) % bit->frameCount() ); + } + } + + for ( KExhaust *e = exhaust.first(); e; e = exhaust.next() ) + exhaust.removeRef( e ); + + // move / rotate ship. + // check for collision with a rock. + processShip(); + + // move powerups and check for collision with player and missiles + processPowerups(); + + if ( textSprite->isVisible() ) + { + if ( textDy < 0 && + textSprite->boundingRect().y() <= -textSprite->boundingRect().height() ) { + textSprite->hide(); + } else { + textSprite->moveBy( 0, textDy ); + } + + if ( textSprite->sceneBoundingRect().y() > (field.height()-textSprite->boundingRect().height())/2 ) + textDy = 0; + } + + if ( vitalsChanged && !(mFrameNum % 10) ) { + emit updateVitals(); + vitalsChanged = FALSE; + } + + mFrameNum++; +} + +void KAsteroidsView::wrapSprite( QGraphicsItem *s ) +{ + int x = int(s->x() + s->boundingRect().width() / 2); + int y = int(s->y() + s->boundingRect().height() / 2); + + if ( x > field.width() ) + s->setPos( s->x() - field.width(), s->y() ); + else if ( x < 0 ) + s->setPos( field.width() + s->x(), s->y() ); + + if ( y > field.height() ) + s->setPos( s->x(), s->y() - field.height() ); + else if ( y < 0 ) + s->setPos( s->x(), field.height() + s->y() ); +} + +// - - - + +void KAsteroidsView::rockHit( AnimatedPixmapItem *hit ) +{ + KPowerup *nPup = 0; + int rnd = int(randDouble()*30.0) % 30; + switch( rnd ) + { + case 4: + case 5: + nPup = new KPowerup( animation[ID_ENERGY_POWERUP], &field, + ID_ENERGY_POWERUP ); + break; + case 10: +// nPup = new KPowerup( animation[ID_TELEPORT_POWERUP], &field, +// ID_TELEPORT_POWERUP ); + break; + case 15: + nPup = new KPowerup( animation[ID_BRAKE_POWERUP], &field, + ID_BRAKE_POWERUP ); + break; + case 20: + nPup = new KPowerup( animation[ID_SHIELD_POWERUP], &field, + ID_SHIELD_POWERUP ); + break; + case 24: + case 25: + nPup = new KPowerup( animation[ID_SHOOT_POWERUP], &field, + ID_SHOOT_POWERUP ); + break; + } + if ( nPup ) + { + double r = 0.5 - randDouble(); + nPup->setPos( hit->x(), hit->y() ); + nPup->setFrame( 0 ); + nPup->setVelocity( hit->xVelocity() + r, hit->yVelocity() + r ); + powerups.append( nPup ); + } + + if ( hit->type() == ID_ROCK_LARGE || hit->type() == ID_ROCK_MEDIUM ) + { + // break into smaller rocks + double addx[4] = { 1.0, 1.0, -1.0, -1.0 }; + double addy[4] = { -1.0, 1.0, -1.0, 1.0 }; + + double dx = hit->xVelocity(); + double dy = hit->yVelocity(); + + double maxRockSpeed = MAX_ROCK_SPEED * rockSpeed; + if ( dx > maxRockSpeed ) + dx = maxRockSpeed; + else if ( dx < -maxRockSpeed ) + dx = -maxRockSpeed; + if ( dy > maxRockSpeed ) + dy = maxRockSpeed; + else if ( dy < -maxRockSpeed ) + dy = -maxRockSpeed; + + AnimatedPixmapItem *nrock; + + for ( int i = 0; i < 4; i++ ) + { + double r = rockSpeed/2 - randDouble()*rockSpeed; + if ( hit->type() == ID_ROCK_LARGE ) + { + nrock = new KRock( animation[ID_ROCK_MEDIUM], &field, + ID_ROCK_MEDIUM, randInt(2), randInt(2) ? -1 : 1 ); + emit rockHit( 0 ); + } + else + { + nrock = new KRock( animation[ID_ROCK_SMALL], &field, + ID_ROCK_SMALL, randInt(2), randInt(2) ? -1 : 1 ); + emit rockHit( 1 ); + } + + nrock->setPos( hit->x(), hit->y() ); + nrock->setFrame( 0 ); + nrock->setVelocity( dx+addx[i]*rockSpeed+r, dy+addy[i]*rockSpeed+r ); + nrock->setFrame( randInt( nrock->frameCount() ) ); + rocks.append( nrock ); + } + } + else if ( hit->type() == ID_ROCK_SMALL ) + emit rockHit( 2 ); + rocks.removeRef( hit ); + if ( rocks.count() == 0 ) + emit rocksRemoved(); +} + +void KAsteroidsView::reducePower( int val ) +{ + shipPower -= val; + if ( shipPower <= 0 ) + { + shipPower = 0; + thrustShip = FALSE; + if ( shieldOn ) + { + shieldOn = FALSE; + shield->hide(); + } + } + vitalsChanged = TRUE; +} + +void KAsteroidsView::addExhaust( double x, double y, double dx, + double dy, int count ) +{ + for ( int i = 0; i < count; i++ ) + { + KExhaust *e = new KExhaust( animation[ID_EXHAUST], &field ); + e->setPos( x + 2 - randDouble()*4, y + 2 - randDouble()*4 ); + e->setVelocity( dx, dy ); + exhaust.append( e ); + } +} + +void KAsteroidsView::processMissiles() +{ + KMissile *missile; + + // if a missile has hit a rock, remove missile and break rock into smaller + // rocks or remove completely. + Q3PtrListIterator<KMissile> it(missiles); + + for ( ; it.current(); ++it ) + { + missile = it.current(); + missile->growOlder(); + + if ( missile->expired() ) + { + missiles.removeRef( missile ); + continue; + } + + wrapSprite( missile ); + + QList<QGraphicsItem *> hits = missile->collidingItems(Qt::IntersectsItemBoundingRect); + QList<QGraphicsItem *>::Iterator hit; + for ( hit = hits.begin(); hit != hits.end(); ++hit ) + { + if ( (*hit)->type() >= ID_ROCK_LARGE && + (*hit)->type() <= ID_ROCK_SMALL && (*hit)->collidesWithItem(missile) ) + { + shotsHit++; + rockHit( static_cast<AnimatedPixmapItem *>(*hit) ); + missiles.removeRef( missile ); + break; + } + } + } +} + +// - - - + +void KAsteroidsView::processShip() +{ + if ( ship->isVisible() ) + { + if ( shieldOn ) + { + shield->show(); + reducePower( SHIELD_ON_COST ); + static int sf = 0; + sf++; + + if ( sf % 2 ) + shield->setFrame( (shield->frame()+1) % shield->frameCount() ); + shield->setPos( ship->x() - 9, ship->y() - 9 ); + + QList<QGraphicsItem *> hits = shield->collidingItems(Qt::IntersectsItemBoundingRect); + QList<QGraphicsItem *>::Iterator it; + for ( it = hits.begin(); it != hits.end(); ++it ) + { + if ( (*it)->type() >= ID_ROCK_LARGE && + (*it)->type() <= ID_ROCK_SMALL && (*it)->collidesWithItem(shield) ) + { + int factor; + switch ( (*it)->type() ) + { + case ID_ROCK_LARGE: + factor = 3; + break; + + case ID_ROCK_MEDIUM: + factor = 2; + break; + + default: + factor = 1; + } + + if ( factor > mShieldCount ) + { + // shield not strong enough + shieldOn = FALSE; + break; + } + rockHit( static_cast<AnimatedPixmapItem *>(*it) ); + // the more shields we have the less costly + reducePower( factor * (SHIELD_HIT_COST - mShieldCount*2) ); + } + } + } + + if ( !shieldOn ) + { + shield->hide(); + QList<QGraphicsItem *> hits = ship->collidingItems(Qt::IntersectsItemBoundingRect); + QList<QGraphicsItem *>::Iterator it; + for ( it = hits.begin(); it != hits.end(); ++it ) + { + if ( (*it)->type() >= ID_ROCK_LARGE && + (*it)->type() <= ID_ROCK_SMALL && (*it)->collidesWithItem(ship)) + { + KBit *bit; + for ( int i = 0; i < 12; i++ ) + { + bit = new KBit( animation[ID_BIT], &field ); + bit->setPos( ship->x() + 5 - randDouble() * 10, + ship->y() + 5 - randDouble() * 10 ); + bit->setFrame( randInt(bit->frameCount()) ); + bit->setVelocity( 1-randDouble()*2, + 1-randDouble()*2 ); + bit->setDeath( 60 + randInt(60) ); + bits.append( bit ); + } + ship->hide(); + shield->hide(); + emit shipKilled(); + break; + } + } + } + + + if ( rotateSlow ) + rotateSlow--; + + if ( rotateL ) + { + shipAngle -= rotateSlow ? 1 : rotateRate; + if ( shipAngle < 0 ) + shipAngle += SHIP_STEPS; + } + + if ( rotateR ) + { + shipAngle += rotateSlow ? 1 : rotateRate; + if ( shipAngle >= SHIP_STEPS ) + shipAngle -= SHIP_STEPS; + } + + double angle = shipAngle * PI_X_2 / SHIP_STEPS; + double cosangle = cos( angle ); + double sinangle = sin( angle ); + + if ( brakeShip ) + { + thrustShip = FALSE; + rotateL = FALSE; + rotateR = FALSE; + rotateRate = ROTATE_RATE; + if ( fabs(shipDx) < 2.5 && fabs(shipDy) < 2.5 ) + { + shipDx = 0.0; + shipDy = 0.0; + ship->setVelocity( shipDx, shipDy ); + brakeShip = FALSE; + } + else + { + double motionAngle = atan2( -shipDy, -shipDx ); + if ( angle > M_PI ) + angle -= PI_X_2; + double angleDiff = angle - motionAngle; + if ( angleDiff > M_PI ) + angleDiff = PI_X_2 - angleDiff; + else if ( angleDiff < -M_PI ) + angleDiff = PI_X_2 + angleDiff; + double fdiff = fabs( angleDiff ); + if ( fdiff > 0.08 ) + { + if ( angleDiff > 0 ) + rotateL = TRUE; + else if ( angleDiff < 0 ) + rotateR = TRUE; + if ( fdiff > 0.6 ) + rotateRate = mBrakeCount + 1; + else if ( fdiff > 0.4 ) + rotateRate = 2; + else + rotateRate = 1; + + if ( rotateRate > 5 ) + rotateRate = 5; + } + else if ( fabs(shipDx) > 1 || fabs(shipDy) > 1 ) + { + thrustShip = TRUE; + // we'll make braking a bit faster + shipDx += cosangle/6 * (mBrakeCount - 1); + shipDy += sinangle/6 * (mBrakeCount - 1); + reducePower( BRAKE_ON_COST ); + addExhaust( ship->x() + 20 - cosangle*22, + ship->y() + 20 - sinangle*22, + shipDx-cosangle, shipDy-sinangle, + mBrakeCount+1 ); + } + } + } + + if ( thrustShip ) + { + // The ship has a terminal velocity, but trying to go faster + // still uses fuel (can go faster diagonally - don't care). + double thrustx = cosangle/4; + double thrusty = sinangle/4; + if ( fabs(shipDx + thrustx) < MAX_SHIP_SPEED ) + shipDx += thrustx; + if ( fabs(shipDy + thrusty) < MAX_SHIP_SPEED ) + shipDy += thrusty; + ship->setVelocity( shipDx, shipDy ); + reducePower( 1 ); + addExhaust( ship->x() + 20 - cosangle*20, + ship->y() + 20 - sinangle*20, + shipDx-cosangle, shipDy-sinangle, 3 ); + } + + ship->setFrame( shipAngle >> 1 ); + + if ( shootShip ) + { + if ( !shootDelay && (int)missiles.count() < mShootCount + 2 ) + { + KMissile *missile = new KMissile( animation[ID_MISSILE], &field ); + missile->setPos( 21+ship->x()+cosangle*21, + 21+ship->y()+sinangle*21 ); + missile->setFrame( 0 ); + missile->setVelocity( shipDx + cosangle*MISSILE_SPEED, + shipDy + sinangle*MISSILE_SPEED ); + missiles.append( missile ); + shotsFired++; + reducePower( 1 ); + + shootDelay = 5; + } + + if ( shootDelay ) + shootDelay--; + } + + if ( teleportShip ) + { + int ra = qrand() % 10; + if( ra == 0 ) + ra += qrand() % 20; + int xra = ra * 60 + ( (qrand() % 20) * (qrand() % 20) ); + int yra = ra * 50 - ( (qrand() % 20) * (qrand() % 20) ); + ship->setPos( xra, yra ); + } + + vitalsChanged = TRUE; + } +} + +// - - - + +void KAsteroidsView::processPowerups() +{ + if ( !powerups.isEmpty() ) + { + // if player gets the powerup remove it from the screen, if option + // "Can destroy powerups" is enabled and a missile hits the powerup + // destroy it + + KPowerup *pup; + Q3PtrListIterator<KPowerup> it( powerups ); + + for( ; it.current(); ++it ) + { + pup = it.current(); + pup->growOlder(); + + if( pup->expired() ) + { + powerups.removeRef( pup ); + continue; + } + + wrapSprite( pup ); + + QList<QGraphicsItem *> hits = pup->collidingItems(); + QList<QGraphicsItem *>::Iterator it; + for ( it = hits.begin(); it != hits.end(); ++it ) + { + if ( (*it) == ship ) + { + switch( pup->type() ) + { + case ID_ENERGY_POWERUP: + shipPower += 150; + if ( shipPower > MAX_POWER_LEVEL ) + shipPower = MAX_POWER_LEVEL; + break; + case ID_TELEPORT_POWERUP: + mTeleportCount++; + break; + case ID_BRAKE_POWERUP: + if ( mBrakeCount < MAX_BRAKES ) + mBrakeCount++; + break; + case ID_SHIELD_POWERUP: + if ( mShieldCount < MAX_SHIELDS ) + mShieldCount++; + break; + case ID_SHOOT_POWERUP: + if ( mShootCount < MAX_FIREPOWER ) + mShootCount++; + break; + } + + powerups.removeRef( pup ); + vitalsChanged = TRUE; + } + else if ( (*it) == shield ) + { + powerups.removeRef( pup ); + } + else if ( (*it)->type() == ID_MISSILE ) + { + if ( can_destroy_powerups ) + { + powerups.removeRef( pup ); + } + } + } + } + } // -- if( powerups.isEmpty() ) +} + +// - - - + +void KAsteroidsView::hideShield() +{ + shield->hide(); + mShieldCount = 0; + shieldOn = FALSE; +} + +double KAsteroidsView::randDouble() +{ + int v = qrand(); + return (double)v / (double)RAND_MAX; +} + +int KAsteroidsView::randInt( int range ) +{ + return qrand() % range; +} + +void KAsteroidsView::showEvent( QShowEvent *e ) +{ +#if defined( QT_LICENSE_PROFESSIONAL ) + static bool wasThere = FALSE; + + if ( !wasThere ) { + wasThere = TRUE; + QMessageBox::information( this, tr("QGraphicsView demo"), + tr("This game has been implemented using the QGraphicsView class.\n" + "The QGraphicsView class is not part of the Light Platform Edition. Please \n" + "contact Nokia if you want to upgrade to the Full Platform Edition.") ); + } +#endif + + QWidget::showEvent( e ); +} diff --git a/examples/graphicsview/portedasteroids/view.h b/examples/graphicsview/portedasteroids/view.h new file mode 100644 index 0000000..eeb7e2b --- /dev/null +++ b/examples/graphicsview/portedasteroids/view.h @@ -0,0 +1,183 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/* + * KAsteroids - Copyright (c) Martin R. Jones 1997 + * + * Part of the KDE project + */ + +#ifndef __AST_VIEW_H__ +#define __AST_VIEW_H__ + +#include <qwidget.h> +#include <q3ptrlist.h> +#include <q3intdict.h> +#include <qtimer.h> +#include <QGraphicsScene> +#include <QGraphicsView> +//Added by qt3to4: +#include <QTimerEvent> +#include <QShowEvent> +#include <QResizeEvent> +#include "sprites.h" + +#define MAX_POWER_LEVEL 1000 + +class KAsteroidsView : public QWidget +{ + Q_OBJECT +public: + KAsteroidsView( QWidget *parent = 0, const char *name = 0 ); + virtual ~KAsteroidsView(); + + int refreshRate; + + void reset(); + void setRockSpeed( double rs ) { rockSpeed = rs; } + void addRocks( int num ); + void newGame(); + void endGame(); + void newShip(); + + void rotateLeft( bool r ) { rotateL = r; rotateSlow = 5; } + void rotateRight( bool r ) { rotateR = r; rotateSlow = 5; } + void thrust( bool t ) { thrustShip = t && shipPower > 0; } + void shoot( bool s ) { shootShip = s; shootDelay = 0; } + void setShield( bool s ); + void teleport( bool te) { teleportShip = te && mTeleportCount; } + void brake( bool b ); + void pause( bool p); + + void showText( const QString &text, const QColor &color, bool scroll=TRUE ); + void hideText(); + + int shots() const { return shotsFired; } + int hits() const { return shotsHit; } + int power() const { return shipPower; } + + int teleportCount() const { return mTeleportCount; } + int brakeCount() const { return mBrakeCount; } + int shieldCount() const { return mShieldCount; } + int shootCount() const { return mShootCount; } + +signals: + void shipKilled(); + void rockHit( int size ); + void rocksRemoved(); + void updateVitals(); + +private slots: + void hideShield(); + +protected: + bool readSprites(); + void wrapSprite( QGraphicsItem * ); + void rockHit( AnimatedPixmapItem * ); + void reducePower( int val ); + void addExhaust( double x, double y, double dx, double dy, int count ); + void processMissiles(); + void processShip(); + void processPowerups(); + void processShield(); + double randDouble(); + int randInt( int range ); + + virtual void resizeEvent( QResizeEvent *event ); + virtual void timerEvent( QTimerEvent * ); + + void showEvent( QShowEvent * ); + +private: + QGraphicsScene field; + QGraphicsView view; + QMap<int, QList<QPixmap> > animation; + Q3PtrList<AnimatedPixmapItem> rocks; + Q3PtrList<KMissile> missiles; + Q3PtrList<KBit> bits; + Q3PtrList<KExhaust> exhaust; + Q3PtrList<KPowerup> powerups; + KShield *shield; + AnimatedPixmapItem *ship; + QGraphicsTextItem *textSprite; + + bool rotateL; + bool rotateR; + bool thrustShip; + bool shootShip; + bool teleportShip; + bool brakeShip; + bool pauseShip; + bool shieldOn; + + bool vitalsChanged; + + int shipAngle; + int rotateSlow; + int rotateRate; + int shipPower; + + int shotsFired; + int shotsHit; + int shootDelay; + + int mBrakeCount; + int mShieldCount; + int mTeleportCount; + int mShootCount; + + double shipDx; + double shipDy; + + int textDy; + int mFrameNum; + bool mPaused; + int mTimerId; + + double rockSpeed; + double powerupSpeed; + + bool can_destroy_powerups; + + QTimer *shieldTimer; + bool initialized; +}; + +#endif diff --git a/examples/graphicsview/portedcanvas/blendshadow.cpp b/examples/graphicsview/portedcanvas/blendshadow.cpp new file mode 100644 index 0000000..d40806d --- /dev/null +++ b/examples/graphicsview/portedcanvas/blendshadow.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qimage.h> +#include <qcolor.h> + +static inline int blendComponent( int v, int av, int s, int as ) +{ + return as*s + av*v -(av*as*s)/255; +} + +static inline QRgb blendShade( QRgb v, QRgb s ) +{ + //shadow image is already reduced and blurred + int as = qAlpha(s); + int av = qAlpha(v); + if ( as == 0 || av == 255 ) + return v; + + int a = as + av -(as*av)/255; + + int r = blendComponent( qRed(v),av, qRed(s), as)/a; + int g = blendComponent( qGreen(v),av, qGreen(s), as)/a; + int b = blendComponent( qBlue(v),av, qBlue(s), as)/a; + + return qRgba(r,g,b,a); +} + + + +int main( int*, char**) +{ + QImage image( "out.png" ); + image.convertDepth( 32 ); + QImage shade( "outshade.png" ); + shade.convertDepth( 32 ); + int dx = 10; + int dy = 5; + + int w = image.width(); + int h = image.height(); + + QImage img( w+dx, h+dy, 32 ); + img.setAlphaBuffer( TRUE ); + + for ( int y = 0; y < h+dy; y++ ) { + for ( int x = 0; x < w+dx; x++ ) { + QRgb sh = (x<dx||y<dy) ? 0 : shade.pixel( x-dx, y-dy ); + QRgb pixel = (x<w&y<h) ? image.pixel( x, y ) : 0; + img.setPixel( x, y, blendShade( pixel, sh ) ); + } + } + img.save("blend.png", "PNG" ); +} + + diff --git a/examples/graphicsview/portedcanvas/butterfly.png b/examples/graphicsview/portedcanvas/butterfly.png Binary files differnew file mode 100644 index 0000000..f3e050e --- /dev/null +++ b/examples/graphicsview/portedcanvas/butterfly.png diff --git a/examples/graphicsview/portedcanvas/canvas.cpp b/examples/graphicsview/portedcanvas/canvas.cpp new file mode 100644 index 0000000..7937762 --- /dev/null +++ b/examples/graphicsview/portedcanvas/canvas.cpp @@ -0,0 +1,732 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qdatetime.h> +#include <qmainwindow.h> +#include <qstatusbar.h> +#include <qmessagebox.h> +#include <qmenubar.h> +#include <qapplication.h> +#include <qpainter.h> +#include <qprinter.h> +#include <qlabel.h> +#include <qimage.h> +#include <q3progressdialog.h> +#include <Q3PointArray> +#include <Q3PtrList> +#include <QPixmap> +#include <Q3PopupMenu> +#include <QMouseEvent> +#include <Q3MemArray> +#include "canvas.h" +#include <QStyleOptionGraphicsItem> +#include <qdebug.h> +#include <stdlib.h> + +// We use a global variable to save memory - all the brushes and pens in +// the mesh are shared. +static QBrush *tb = 0; +static QPen *tp = 0; + +class EdgeItem; +class NodeItem; + +class EdgeItem: public QGraphicsLineItem +{ +public: + EdgeItem( NodeItem*, NodeItem* ); + void setFromPoint( int x, int y ) ; + void setToPoint( int x, int y ); + static int count() { return c; } +private: + static int c; +}; + +static const int imageRTTI = 984376; + + +class ImageItem: public QGraphicsRectItem +{ +public: + ImageItem( QImage img ); + int rtti () const { return imageRTTI; } +protected: + void paint( QPainter *, const QStyleOptionGraphicsItem *option, QWidget *widget ); +private: + QImage image; + QPixmap pixmap; +}; + + +ImageItem::ImageItem( QImage img ) + : image(img) +{ + setRect(0, 0, image.width(), image.height()); + setFlag(ItemIsMovable); +#if !defined(Q_WS_QWS) + pixmap.convertFromImage(image, Qt::OrderedAlphaDither); +#endif +} + +void ImageItem::paint( QPainter *p, const QStyleOptionGraphicsItem *option, QWidget * ) +{ +// On Qt/Embedded, we can paint a QImage as fast as a QPixmap, +// but on other platforms, we need to use a QPixmap. +#if defined(Q_WS_QWS) + p->drawImage( option->exposedRect, image, option->exposedRect, Qt::OrderedAlphaDither ); +#else + p->drawPixmap( option->exposedRect, pixmap, option->exposedRect ); +#endif +} + +class NodeItem: public QGraphicsEllipseItem +{ +public: + NodeItem(); + ~NodeItem() {} + + void addInEdge( EdgeItem *edge ) { inList.append( edge ); } + void addOutEdge( EdgeItem *edge ) { outList.append( edge ); } + +protected: + QVariant itemChange(GraphicsItemChange change, const QVariant &value); + + + // QPoint center() { return boundingRect().center(); } +private: + Q3PtrList<EdgeItem> inList; + Q3PtrList<EdgeItem> outList; +}; + + +int EdgeItem::c = 0; + +EdgeItem::EdgeItem( NodeItem *from, NodeItem *to ) + : QGraphicsLineItem( ) +{ + c++; + setPen( *tp ); + from->addOutEdge( this ); + to->addInEdge( this ); + setLine( QLineF(int(from->x()), int(from->y()), int(to->x()), int(to->y()) )); + setZValue( 127 ); + setBoundingRegionGranularity(0.05); +} + +void EdgeItem::setFromPoint( int x, int y ) +{ + setLine(QLineF( x,y, line().p2().x(), line().p2().y() )); +} + +void EdgeItem::setToPoint( int x, int y ) +{ + setLine(QLineF( line().p1().x(), line().p1().y(), x, y )); +} + +QVariant NodeItem::itemChange(GraphicsItemChange change, const QVariant &value) +{ + if (change == ItemPositionHasChanged) { + Q3PtrListIterator<EdgeItem> it1( inList ); + EdgeItem *edge; + while (( edge = it1.current() )) { + ++it1; + edge->setToPoint( int(x()), int(y()) ); + } + Q3PtrListIterator<EdgeItem> it2( outList ); + while (( edge = it2.current() )) { + ++it2; + edge->setFromPoint( int(x()), int(y()) ); + } + } + + return QGraphicsEllipseItem::itemChange(change, value); +} + +NodeItem::NodeItem( ) + : QGraphicsEllipseItem( QRectF(-3, -3, 6, 6) ) +{ + setPen( *tp ); + setBrush( *tb ); + setZValue( 128 ); + setFlag(ItemIsMovable); +} + +FigureEditor::FigureEditor( + QGraphicsScene& c, QWidget* parent, + const char* name, Qt::WindowFlags f) : + QGraphicsView(&c,parent) +{ + setObjectName(name); + setWindowFlags(f); + setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); +} + +void FigureEditor::clear() +{ + scene()->clear(); +} + +BouncyLogo::BouncyLogo() : + xvel(0), yvel(0) +{ + setPixmap(QPixmap(":/trolltech/examples/graphicsview/portedcanvas/qt-trans.xpm")); +} + +const int logo_rtti = 1234; + +int BouncyLogo::type() const +{ + return logo_rtti; +} + +QPainterPath BouncyLogo::shape() const +{ + QPainterPath path; + path.addRect(boundingRect()); + return path; +} + +void BouncyLogo::initPos() +{ + initSpeed(); + int trial=1000; + do { + setPos(qrand()%int(scene()->width()),qrand()%int(scene()->height())); + advance(0); + } while (trial-- && xvel==0.0 && yvel==0.0); +} + +void BouncyLogo::initSpeed() +{ + const double speed = 4.0; + double d = (double)(qrand()%1024) / 1024.0; + xvel = d*speed*2-speed; + yvel = (1-d)*speed*2-speed; +} + +void BouncyLogo::advance(int stage) +{ + switch ( stage ) { + case 0: { + double vx = xvel; + double vy = yvel; + + if ( vx == 0.0 && vy == 0.0 ) { + // stopped last turn + initSpeed(); + vx = xvel; + vy = yvel; + } + + double nx = x() + vx; + double ny = y() + vy; + + if ( nx < 0 || nx >= scene()->width() ) + vx = -vx; + if ( ny < 0 || ny >= scene()->height() ) + vy = -vy; + + for (int bounce=0; bounce<4; bounce++) { + QList<QGraphicsItem *> l=scene()->collidingItems(this); + for (QList<QGraphicsItem *>::Iterator it=l.begin(); it!=l.end(); ++it) { + QGraphicsItem *hit = *it; + QPainterPath advancedShape = QMatrix().translate(xvel, yvel).map(shape()); + if ( hit->type()==logo_rtti && hit->collidesWithPath(mapToItem(hit, advancedShape)) ) { + switch ( bounce ) { + case 0: + vx = -vx; + break; + case 1: + vy = -vy; + vx = -vx; + break; + case 2: + vx = -vx; + break; + case 3: + // Stop for this turn + vx = 0; + vy = 0; + break; + } + xvel = vx; + yvel = vy; + break; + } + } + } + + if ( x()+vx < 0 || x()+vx >= scene()->width() ) + vx = 0; + if ( y()+vy < 0 || y()+vy >= scene()->height() ) + vy = 0; + + xvel = vx; + yvel = vy; + } break; + case 1: + moveBy(xvel, yvel); + break; + } +} + +static uint mainCount = 0; +static QImage *butterflyimg; +static QImage *logoimg; + +Main::Main(QGraphicsScene& c, QWidget* parent, const char* name, Qt::WindowFlags f) : + Q3MainWindow(parent,name,f), + canvas(c) +{ + editor = new FigureEditor(canvas,this); + QMenuBar* menu = menuBar(); + + Q3PopupMenu* file = new Q3PopupMenu( menu ); + file->insertItem("&Fill canvas", this, SLOT(init()), Qt::CTRL+Qt::Key_F); + file->insertItem("&Erase canvas", this, SLOT(clear()), Qt::CTRL+Qt::Key_E); + file->insertItem("&New view", this, SLOT(newView()), Qt::CTRL+Qt::Key_N); + file->insertSeparator(); + file->insertItem("&Print...", this, SLOT(print()), Qt::CTRL+Qt::Key_P); + file->insertSeparator(); + file->insertItem("E&xit", qApp, SLOT(quit()), Qt::CTRL+Qt::Key_Q); + menu->insertItem("&File", file); + + Q3PopupMenu* edit = new Q3PopupMenu( menu ); + edit->insertItem("Add &Circle", this, SLOT(addCircle()), Qt::ALT+Qt::Key_C); + edit->insertItem("Add &Hexagon", this, SLOT(addHexagon()), Qt::ALT+Qt::Key_H); + edit->insertItem("Add &Polygon", this, SLOT(addPolygon()), Qt::ALT+Qt::Key_P); + edit->insertItem("Add Spl&ine", this, SLOT(addSpline()), Qt::ALT+Qt::Key_I); + edit->insertItem("Add &Text", this, SLOT(addText()), Qt::ALT+Qt::Key_T); + edit->insertItem("Add &Line", this, SLOT(addLine()), Qt::ALT+Qt::Key_L); + edit->insertItem("Add &Rectangle", this, SLOT(addRectangle()), Qt::ALT+Qt::Key_R); + edit->insertItem("Add &Sprite", this, SLOT(addSprite()), Qt::ALT+Qt::Key_S); + edit->insertItem("Create &Mesh", this, SLOT(addMesh()), Qt::ALT+Qt::Key_M ); + edit->insertItem("Add &Alpha-blended image", this, SLOT(addButterfly()), Qt::ALT+Qt::Key_A); + menu->insertItem("&Edit", edit); + + Q3PopupMenu* view = new Q3PopupMenu( menu ); + view->insertItem("&Enlarge", this, SLOT(enlarge()), Qt::SHIFT+Qt::CTRL+Qt::Key_Plus); + view->insertItem("Shr&ink", this, SLOT(shrink()), Qt::SHIFT+Qt::CTRL+Qt::Key_Minus); + view->insertSeparator(); + view->insertItem("&Rotate clockwise", this, SLOT(rotateClockwise()), Qt::CTRL+Qt::Key_PageDown); + view->insertItem("Rotate &counterclockwise", this, SLOT(rotateCounterClockwise()), Qt::CTRL+Qt::Key_PageUp); + view->insertItem("&Zoom in", this, SLOT(zoomIn()), Qt::CTRL+Qt::Key_Plus); + view->insertItem("Zoom &out", this, SLOT(zoomOut()), Qt::CTRL+Qt::Key_Minus); + view->insertItem("Translate left", this, SLOT(moveL()), Qt::CTRL+Qt::Key_Left); + view->insertItem("Translate right", this, SLOT(moveR()), Qt::CTRL+Qt::Key_Right); + view->insertItem("Translate up", this, SLOT(moveU()), Qt::CTRL+Qt::Key_Up); + view->insertItem("Translate down", this, SLOT(moveD()), Qt::CTRL+Qt::Key_Down); + view->insertItem("&Mirror", this, SLOT(mirror()), Qt::CTRL+Qt::Key_Home); + menu->insertItem("&View", view); + + menu->insertSeparator(); + + Q3PopupMenu* help = new Q3PopupMenu( menu ); + help->insertItem("&About", this, SLOT(help()), Qt::Key_F1); + help->setItemChecked(dbf_id, TRUE); + menu->insertItem("&Help",help); + + statusBar(); + + setCentralWidget(editor); + + printer = 0; + + init(); +} + +void Main::init() +{ + clear(); + + static int r=24; + qsrand(++r); + + mainCount++; + butterflyimg = 0; + logoimg = 0; + + int i; + for ( i=0; i < int(canvas.width()) / 56; i++) { + addButterfly(); + } + for ( i=0; i < int(canvas.width()) / 85; i++) { + addHexagon(); + } + for ( i=0; i < int(canvas.width()) / 128; i++) { + addLogo(); + } +} + +Main::~Main() +{ + delete printer; + if ( !--mainCount ) { + delete[] butterflyimg; + butterflyimg = 0; + delete[] logoimg; + logoimg = 0; + } +} + +void Main::newView() +{ + // Open a new view... have it delete when closed. + Main *m = new Main(canvas, 0, 0, Qt::WDestructiveClose); + m->show(); +} + +void Main::clear() +{ + editor->clear(); +} + +void Main::help() +{ + static QMessageBox* about = new QMessageBox( "Qt Canvas Example", + "<h3>The QCanvas classes example</h3>" + "<ul>" + "<li> Press ALT-S for some sprites." + "<li> Press ALT-C for some circles." + "<li> Press ALT-L for some lines." + "<li> Drag the objects around." + "<li> Read the code!" + "</ul>", QMessageBox::Information, 1, 0, 0, this, 0, FALSE ); + about->setButtonText( 1, "Dismiss" ); + about->show(); +} + +void Main::aboutQt() +{ + QMessageBox::aboutQt( this, "Qt Canvas Example" ); +} + +void Main::enlarge() +{ + canvas.setSceneRect(0, 0, canvas.width()*4/3, canvas.height()*4/3); +} + +void Main::shrink() +{ + canvas.setSceneRect(0, 0, qMax(canvas.width()*3/4, qreal(1.0)), qMax(canvas.height()*3/4, qreal(1.0))); +} + +void Main::rotateClockwise() +{ + editor->rotate( 22.5 ); +} + +void Main::rotateCounterClockwise() +{ + editor->rotate( -22.5 ); +} + +void Main::zoomIn() +{ + editor->scale( 2.0, 2.0 ); +} + +void Main::zoomOut() +{ + editor->scale( 0.5, 0.5 ); +} + +void Main::mirror() +{ + editor->scale( -1, 1 ); +} + +void Main::moveL() +{ + editor->translate( -16, 0 ); +} + +void Main::moveR() +{ + editor->translate( +16, 0 ); +} + +void Main::moveU() +{ + editor->translate( 0, -16 ); +} + +void Main::moveD() +{ + editor->translate( 0, +16 ); +} + +void Main::print() +{ + if ( !printer ) printer = new QPrinter; + if ( printer->setup(this) ) { + QPainter pp(printer); + canvas.render(&pp); + } +} + + +void Main::addSprite() +{ + BouncyLogo* i = new BouncyLogo; + canvas.addItem(i); + i->initPos(); + i->setZValue(qrand()%256); +} + +QString butterfly_fn; +QString logo_fn; + + +void Main::addButterfly() +{ + if ( butterfly_fn.isEmpty() ) + return; + if ( !butterflyimg ) { + butterflyimg = new QImage[4]; + butterflyimg[0].load( butterfly_fn ); + butterflyimg[1] = butterflyimg[0].smoothScale( int(butterflyimg[0].width()*0.75), + int(butterflyimg[0].height()*0.75) ); + butterflyimg[2] = butterflyimg[0].smoothScale( int(butterflyimg[0].width()*0.5), + int(butterflyimg[0].height()*0.5) ); + butterflyimg[3] = butterflyimg[0].smoothScale( int(butterflyimg[0].width()*0.25), + int(butterflyimg[0].height()*0.25) ); + } + QAbstractGraphicsShapeItem* i = new ImageItem(butterflyimg[qrand()%4]); + canvas.addItem(i); + i->setPos(qrand()%int(canvas.width()-butterflyimg->width()), + qrand()%int(canvas.height()-butterflyimg->height())); + i->setZValue(qrand()%256+250); +} + +void Main::addLogo() +{ + if ( logo_fn.isEmpty() ) + return; + if ( !logoimg ) { + logoimg = new QImage[4]; + logoimg[0].load( logo_fn ); + logoimg[1] = logoimg[0].smoothScale( int(logoimg[0].width()*0.75), + int(logoimg[0].height()*0.75) ); + logoimg[2] = logoimg[0].smoothScale( int(logoimg[0].width()*0.5), + int(logoimg[0].height()*0.5) ); + logoimg[3] = logoimg[0].smoothScale( int(logoimg[0].width()*0.25), + int(logoimg[0].height()*0.25) ); + } + QAbstractGraphicsShapeItem* i = new ImageItem(logoimg[qrand()%4]); + canvas.addItem(i); + i->setPos(qrand()%int(canvas.width()-logoimg->width()), + qrand()%int(canvas.height()-logoimg->width())); + i->setZValue(qrand()%256+256); +} + + + +void Main::addCircle() +{ + QAbstractGraphicsShapeItem* i = canvas.addEllipse(QRectF(0,0,50,50)); + i->setFlag(QGraphicsItem::ItemIsMovable); + i->setPen(Qt::NoPen); + i->setBrush( QColor(qrand()%32*8,qrand()%32*8,qrand()%32*8) ); + i->setPos(qrand()%int(canvas.width()),qrand()%int(canvas.height())); + i->setZValue(qrand()%256); +} + +void Main::addHexagon() +{ + const int size = int(canvas.width() / 25); + Q3PointArray pa(6); + pa[0] = QPoint(2*size,0); + pa[1] = QPoint(size,-size*173/100); + pa[2] = QPoint(-size,-size*173/100); + pa[3] = QPoint(-2*size,0); + pa[4] = QPoint(-size,size*173/100); + pa[5] = QPoint(size,size*173/100); + QGraphicsPolygonItem* i = canvas.addPolygon(pa); + i->setFlag(QGraphicsItem::ItemIsMovable); + i->setPen(Qt::NoPen); + i->setBrush( QColor(qrand()%32*8,qrand()%32*8,qrand()%32*8) ); + i->setPos(qrand()%int(canvas.width()),qrand()%int(canvas.height())); + i->setZValue(qrand()%256); +} + +void Main::addPolygon() +{ + const int size = int(canvas.width()/2); + Q3PointArray pa(6); + pa[0] = QPoint(0,0); + pa[1] = QPoint(size,size/5); + pa[2] = QPoint(size*4/5,size); + pa[3] = QPoint(size/6,size*5/4); + pa[4] = QPoint(size*3/4,size*3/4); + pa[5] = QPoint(size*3/4,size/4); + QGraphicsPolygonItem* i = canvas.addPolygon(pa); + i->setFlag(QGraphicsItem::ItemIsMovable); + i->setPen(Qt::NoPen); + i->setBrush( QColor(qrand()%32*8,qrand()%32*8,qrand()%32*8) ); + i->setPos(qrand()%int(canvas.width()),qrand()%int(canvas.height())); + i->setZValue(qrand()%256); +} + +void Main::addSpline() +{ + const int size = int(canvas.width()/6); + + Q3PointArray pa(12); + pa[0] = QPoint(0,0); + pa[1] = QPoint(size/2,0); + pa[2] = QPoint(size,size/2); + pa[3] = QPoint(size,size); + pa[4] = QPoint(size,size*3/2); + pa[5] = QPoint(size/2,size*2); + pa[6] = QPoint(0,size*2); + pa[7] = QPoint(-size/2,size*2); + pa[8] = QPoint(size/4,size*3/2); + pa[9] = QPoint(0,size); + pa[10]= QPoint(-size/4,size/2); + pa[11]= QPoint(-size/2,0); + + QPainterPath path; + path.moveTo(pa[0]); + for (int i = 1; i < pa.size(); i += 3) + path.cubicTo(pa[i], pa[(i + 1) % pa.size()], pa[(i + 2) % pa.size()]); + + QGraphicsPathItem* item = canvas.addPath(path); + item->setFlag(QGraphicsItem::ItemIsMovable); + item->setPen(Qt::NoPen); + item->setBrush( QColor(qrand()%32*8,qrand()%32*8,qrand()%32*8) ); + item->setPos(qrand()%int(canvas.width()),qrand()%int(canvas.height())); + item->setZValue(qrand()%256); +} + +void Main::addText() +{ + QGraphicsTextItem* i = canvas.addText("QCanvasText"); + i->setFlag(QGraphicsItem::ItemIsMovable); + i->setPos(qrand()%int(canvas.width()),qrand()%int(canvas.height())); + i->setZValue(qrand()%256); +} + +void Main::addLine() +{ + QGraphicsLineItem* i = canvas.addLine(QLineF( qrand()%int(canvas.width()), qrand()%int(canvas.height()), + qrand()%int(canvas.width()), qrand()%int(canvas.height()) )); + i->setFlag(QGraphicsItem::ItemIsMovable); + i->setPen( QPen(QColor(qrand()%32*8,qrand()%32*8,qrand()%32*8), 6) ); + i->setZValue(qrand()%256); +} + +void Main::addMesh() +{ + int x0 = 0; + int y0 = 0; + + if ( !tb ) tb = new QBrush( Qt::red ); + if ( !tp ) tp = new QPen( Qt::black ); + + int nodecount = 0; + + int w = int(canvas.width()); + int h = int(canvas.height()); + + const int dist = 30; + int rows = h / dist; + int cols = w / dist; + +#ifndef QT_NO_PROGRESSDIALOG + Q3ProgressDialog progress( "Creating mesh...", "Abort", rows, + this, "progress", TRUE ); +#endif + + canvas.update(); + + Q3MemArray<NodeItem*> lastRow(cols); + for ( int j = 0; j < rows; j++ ) { + int n = j%2 ? cols-1 : cols; + NodeItem *prev = 0; + for ( int i = 0; i < n; i++ ) { + NodeItem *el = new NodeItem; + canvas.addItem(el); + nodecount++; + int r = qrand(); + int xrand = r %20; + int yrand = (r/20) %20; + el->setPos( xrand + x0 + i*dist + (j%2 ? dist/2 : 0 ), + yrand + y0 + j*dist ); + + if ( j > 0 ) { + if ( i < cols-1 ) + canvas.addItem(new EdgeItem( lastRow[i], el)); + if ( j%2 ) + canvas.addItem(new EdgeItem( lastRow[i+1], el)); + else if ( i > 0 ) + canvas.addItem(new EdgeItem( lastRow[i-1], el)); + } + if ( prev ) { + canvas.addItem(new EdgeItem( prev, el)); + } + if ( i > 0 ) lastRow[i-1] = prev; + prev = el; + } + lastRow[n-1]=prev; +#ifndef QT_NO_PROGRESSDIALOG + progress.setProgress( j ); + if ( progress.wasCancelled() ) + break; +#endif + } +#ifndef QT_NO_PROGRESSDIALOG + progress.setProgress( rows ); +#endif + // qDebug( "%d nodes, %d edges", nodecount, EdgeItem::count() ); +} + +void Main::addRectangle() +{ + QAbstractGraphicsShapeItem *i = canvas.addRect( QRectF(qrand()%int(canvas.width()), + qrand()%int(canvas.height()), + canvas.width()/5, + canvas.width()/5) ); + i->setFlag(QGraphicsItem::ItemIsMovable); + int z = qrand()%256; + i->setBrush( QColor(z,z,z) ); + i->setPen( QPen(QColor(qrand()%32*8,qrand()%32*8,qrand()%32*8), 6) ); + i->setZValue(z); +} diff --git a/examples/graphicsview/portedcanvas/canvas.doc b/examples/graphicsview/portedcanvas/canvas.doc new file mode 100644 index 0000000..f6d77ad --- /dev/null +++ b/examples/graphicsview/portedcanvas/canvas.doc @@ -0,0 +1,29 @@ +/*! \page canvas-example.html + + \ingroup examples + \title Canvas Example + + This example shows a QCanvas and some \l{QCanvasItem}s in action. + You can do a lot more with QCanvas than we show here, but the + example provides a taste of what can be done. + + <hr> + + Header file: + + \include canvas/canvas.h + + <hr> + + Implementation: + + \include canvas/canvas.cpp + + <hr> + + Main: + + \include canvas/main.cpp +*/ + + diff --git a/examples/graphicsview/portedcanvas/canvas.h b/examples/graphicsview/portedcanvas/canvas.h new file mode 100644 index 0000000..1ebdf90 --- /dev/null +++ b/examples/graphicsview/portedcanvas/canvas.h @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef EXAMPLE_H +#define EXAMPLE_H + +#include <q3popupmenu.h> +#include <q3mainwindow.h> +#include <q3intdict.h> +#include <QMouseEvent> +#include <QGraphicsView> +#include <QGraphicsScene> +#include <QGraphicsItem> + +class BouncyLogo : public QGraphicsPixmapItem { + void initSpeed(); +public: + BouncyLogo(); + void advance(int); + int type() const; + + QPainterPath shape() const; + + void initPos(); +private: + qreal xvel; + qreal yvel; +}; + + +class FigureEditor : public QGraphicsView { + Q_OBJECT + +public: + FigureEditor(QGraphicsScene&, QWidget* parent=0, const char* name=0, Qt::WindowFlags f=0); + void clear(); + +signals: + void status(const QString&); +}; + +class Main : public Q3MainWindow { + Q_OBJECT + +public: + Main(QGraphicsScene&, QWidget* parent=0, const char* name=0, Qt::WindowFlags f=0); + ~Main(); + +public slots: + void help(); + +private slots: + void aboutQt(); + void newView(); + void clear(); + void init(); + + void addSprite(); + void addCircle(); + void addHexagon(); + void addPolygon(); + void addSpline(); + void addText(); + void addLine(); + void addRectangle(); + void addMesh(); + void addLogo(); + void addButterfly(); + + void enlarge(); + void shrink(); + void rotateClockwise(); + void rotateCounterClockwise(); + void zoomIn(); + void zoomOut(); + void mirror(); + void moveL(); + void moveR(); + void moveU(); + void moveD(); + + void print(); + +private: + QGraphicsScene& canvas; + FigureEditor *editor; + + Q3PopupMenu* options; + QPrinter* printer; + int dbf_id; +}; + +#endif diff --git a/examples/graphicsview/portedcanvas/main.cpp b/examples/graphicsview/portedcanvas/main.cpp new file mode 100644 index 0000000..8478d94 --- /dev/null +++ b/examples/graphicsview/portedcanvas/main.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qstatusbar.h> +#include <qmessagebox.h> +#include <qmenubar.h> +#include <qapplication.h> +#include <qdesktopwidget.h> +#include <qimage.h> +#include <qtimer.h> + +#include "canvas.h" + +#include <stdlib.h> + +extern QString butterfly_fn; +extern QString logo_fn; + +int main(int argc, char** argv) +{ + Q_INIT_RESOURCE(portedcanvas); + + QApplication app(argc,argv); + + if ( argc > 1 ) + butterfly_fn = argv[1]; + else + butterfly_fn = ":/trolltech/examples/graphicsview/portedcanvas/butterfly.png"; + + if ( argc > 2 ) + logo_fn = argv[2]; + else + logo_fn = ":/trolltech/examples/graphicsview/portedcanvas/qtlogo.png"; + + QGraphicsScene canvas; + canvas.setSceneRect(0, 0, 800, 600); + Main m(canvas); + m.resize(m.sizeHint()); + m.setCaption("Ported Canvas Example"); + if ( QApplication::desktop()->width() > m.width() + 10 + && QApplication::desktop()->height() > m.height() +30 ) + m.show(); + else + m.showMaximized(); + + QTimer timer; + QObject::connect(&timer, SIGNAL(timeout()), &canvas, SLOT(advance())); + timer.start(30); + + QObject::connect( qApp, SIGNAL(lastWindowClosed()), qApp, SLOT(quit()) ); + + return app.exec(); +} + diff --git a/examples/graphicsview/portedcanvas/makeimg.cpp b/examples/graphicsview/portedcanvas/makeimg.cpp new file mode 100644 index 0000000..c3bb073 --- /dev/null +++ b/examples/graphicsview/portedcanvas/makeimg.cpp @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** 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 examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qimage.h> +#include <qcolor.h> + +static inline int blendComponent( int v, int av, int s, int as ) +{ + //shadow gets a color inversely proportional to the + //alpha value + s = (s*(255-as))/255; + //then do standard blending + return as*s + av*v -(av*as*s)/255; +} + +static inline QRgb blendShade( QRgb v, QRgb s ) +{ + //pick a number: shadow is 1/3 of object + int as = qAlpha(s)/3; + int av = qAlpha(v); + if ( as == 0 || av == 255 ) + return v; + + int a = as + av -(as*av)/255; + + + int r = blendComponent( qRed(v),av, qRed(s), as)/a; + int g = blendComponent( qGreen(v),av, qGreen(s), as)/a; + int b = blendComponent( qBlue(v),av, qBlue(s), as)/a; + + return qRgba(r,g,b,a); +} + +int main( int*, char**) +{ + QImage *img; + + img = new QImage( "in.png" ); + int w,h; + int y; + img->setAlphaBuffer( TRUE ); + *img = img->convertDepth( 32 ); + w = img->width(); + h = img->height(); +#if 0 + for ( y = 0; y < h; y ++ ) { + uint *line = (uint*)img->scanLine( y ); + for ( int x = 0; x < w; x++ ) { + uint pixel = line[x]; + int r = qRed(pixel); + int g = qGreen(pixel); + int b = qBlue(pixel); + int min = QMIN( r, QMIN( g, b ) ); + int max = QMAX( r, QMAX( g, b ) ); + r -= min; + g -= min; + b -= min; + if ( max !=min ) { + r = (r*255)/(max-min); + g = (g*255)/(max-min); + b = (b*255)/(max-min); + } + int a = 255-min; + a -= (max-min)/3; //hack more transparency for colors. + line[x] = qRgba( r, g, b, a ); + } + } +#endif + *img = img->smoothScale( w/2, h/2 ); + + qDebug( "saving out.png"); + img->save( "out.png", "PNG" ); + + w = img->width(); + h = img->height(); + + QImage *img2 = new QImage( w, h, 32 ); + img2->setAlphaBuffer( TRUE ); + for ( y = 0; y < h; y++ ) { + for ( int x = 0; x < w; x++ ) { + QRgb shader = img->pixel( x, y ); + + int as = qAlpha(shader)/3; + + int r = (qRed(shader)*(255-as))/255; + int g = (qGreen(shader)*(255-as))/255; + int b = (qBlue(shader)*(255-as))/255; + + img2->setPixel( x, y, qRgba(r,g,b,as) ); + } + } + + img2->save( "outshade.png", "PNG" ); + +} diff --git a/examples/graphicsview/portedcanvas/portedcanvas.pro b/examples/graphicsview/portedcanvas/portedcanvas.pro new file mode 100644 index 0000000..eb601f9 --- /dev/null +++ b/examples/graphicsview/portedcanvas/portedcanvas.pro @@ -0,0 +1,18 @@ +TEMPLATE = app +TARGET = portedcanvas + +CONFIG += qt warn_on + +HEADERS = canvas.h +SOURCES = canvas.cpp main.cpp +QT += qt3support + +RESOURCES += portedcanvas.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/qt3support/graphicsview/portedcanvas +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS portedcanvas.pro *.png *.xpm *.doc +sources.path = $$[QT_INSTALL_EXAMPLES]/qt3support/graphicsview/portedcanvas +INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/graphicsview/portedcanvas/portedcanvas.qrc b/examples/graphicsview/portedcanvas/portedcanvas.qrc new file mode 100644 index 0000000..cf2e024 --- /dev/null +++ b/examples/graphicsview/portedcanvas/portedcanvas.qrc @@ -0,0 +1,7 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="/trolltech/examples/graphicsview/portedcanvas"> +<file>qt-trans.xpm</file> +<file>butterfly.png</file> +<file>qtlogo.png</file> +</qresource> +</RCC> diff --git a/examples/graphicsview/portedcanvas/qt-trans.xpm b/examples/graphicsview/portedcanvas/qt-trans.xpm new file mode 100644 index 0000000..225f684 --- /dev/null +++ b/examples/graphicsview/portedcanvas/qt-trans.xpm @@ -0,0 +1,54 @@ +/* XPM */ +static char *qtlogo_xpm[] = { +/* width height ncolors chars_per_pixel */ +"54 34 13 1", +/* colors */ +" c #000000", +". c #999999", +"X c #333366", +"o c #6666CC", +"O c #333333", +"@ c #666699", +"# c #000066", +"$ c #666666", +"% c #3333CC", +"& c #000033", +"* c #9999CC", +"= c #333399", +"+ c None", +/* pixels */ +"+++++++++++++++++++.$OOO$.++++++++++++++++++++++++++++", +"+++++++++++++++++$ O.+++++++++++++++++++++++++", +"+++++++++++++++.O $++++++++++++++++++++++++", +"++++++++++++++. $.++.$ O+++++++++++++++++++++++", +"+++++++++++++. O.+++++++$ O++++++++++++++++++++++", +"+++++++++++++O ++++++++++$ $+++++++++++++++++++++", +"++++++++++++$ .+++++++++++O .++++++++++++++++++++", +"+++++++++++. O+++++++++++++ O++++++.+++++++++++++", +"+++++++++++$ .+++++++++++++$ .+++.O +++++++++++++", +"+++++++++++ +++++++++++++++ O+++. +++++++++++++", +"++++++++++. &Xoooo*++++++++++$ +++. +++++++++++++", +"++++++++++@=%%%%%%%%%%*+++++++. .++. +++++++++++++", +"+++++++**oooooo**++*o%%%%o+++++ $++O +++++++++++++", +"+++++*****$OOX@oooo*++*%%%%%*++O $+. OOO$++++++++*", +"++..+.++....$O$+*ooooo*+*o%%%%%O O+$ $$O.++++++**+", +"***+*+++++$$....+++*oooo**+*o%%# O++O ++++++***o*++", +"*+++++++++O $.....++**oooo**+*X &o*O ++++*ooo*++++", +"++++++++++$ O++.....++**oooo*X &%%& ..*o%%*++++++", +"++++++++++$ ++++.....+++**ooO $*o& @oo*+++++++++", +"++++++++++. .++++++.....+++*O Xo*O .++++++++++++", +"+++++++++++ O+++++++++...... .++O +++++++++++++", +"+++++++++++O +++.$$$.++++++. O+++O +++++++++++++", +"+++++++++++. $$OO O.++++O .+++O +++++++++++++", +"++++++++++++O .+++.O $++. O++++O +++++++++++++", +"++++++++++++. O+++++O $+O +++++O +++++++++++++", +"+++++++++++++. O+++++O O .+++++O .++++++++++++", +"++++++++++++++$ .++++O .++++.+$ O+.$.++++++++", +"+++++++++++++++. O$$O .+++++... +++++++++", +"+++++++++++++++++$ O+++++$$+.O O$.+++++++++", +"+++++++++++++++++++$OO O$.O O.++. .++++++++++++++++", +"+++++++++++++++++++++++++++. OO .++++++++++++++++", +"++++++++++++++++++++++++++++. O+++++++++++++++++", +"+++++++++++++++++++++++++++++. .+++++++++++++++++", +"++++++++++++++++++++++++++++++.O O.++++++++++++++++++" +}; diff --git a/examples/graphicsview/portedcanvas/qtlogo.png b/examples/graphicsview/portedcanvas/qtlogo.png Binary files differnew file mode 100644 index 0000000..5aac08a --- /dev/null +++ b/examples/graphicsview/portedcanvas/qtlogo.png |