[-]
[+]
|
Changed |
_service:tar_git:harbour-fire.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-fire.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,6 +2,6 @@
<service name="tar_git">
<param name="url">https://github.com/monich/harbour-fire.git</param>
<param name="branch">master</param>
- <param name="revision">2e4b16c</param>
+ <param name="revision">765fddf</param>
</service>
</services>
\ No newline at end of file
|
[-]
[+]
|
Deleted |
_service:tar_git:harbour-fire-1.0.2.tar.gz/src/FireDebug.h
^
|
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2022 Jolla Ltd.
- * Copyright (C) 2022 Slava Monich <slava@monich.com>
- *
- * 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:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. Neither the names of the copyright holders 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
- * HOLDERS 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.
- *
- * The views and conclusions contained in the software and documentation
- * are those of the authors and should not be interpreted as representing
- * any official policies, either expressed or implied.
- */
-
-#ifndef FIRE_DEBUG_H
-#define FIRE_DEBUG_H
-
-#include <QDebug>
-
-#ifdef DEBUG
-# define DBG(x) qDebug() << Q_FUNC_INFO << x
-# define DASSERT(x) ((x) ? ((void)0) : qt_assert(#x,__FILE__,__LINE__))
-# define DVERIFY(x) DASSERT(x)
-#else
-# define DBG(expr) ((void)0)
-# define DASSERT(expr) ((void)0)
-# define DVERIFY(x) (x)
-#endif // DEBUG
-
-#define WARN(x) qWarning() << Q_FUNC_INFO << x
-
-#endif // FIRE_DEBUG_H
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-fire-1.0.3.tar.gz/LICENSE
^
|
@@ -1,5 +1,5 @@
+Copyright (C) 2022-2023 Slava Monich <slava@monich.com>
Copyright (C) 2022 Jolla Ltd.
-Copyright (C) 2022 Slava Monich <slava@monich.com>
You may use this file under the terms of BSD license as follows:
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-fire-1.0.3.tar.gz/harbour-fire.desktop
^
|
@@ -6,4 +6,4 @@
Exec=harbour-fire
[X-Sailjail]
-Permissions=
+Permissions=Camera
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-fire-1.0.3.tar.gz/harbour-fire.pro
^
|
@@ -53,7 +53,6 @@
# App
HEADERS += \
- src/FireDebug.h \
src/FireItem.h
SOURCES += \
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-fire-1.0.3.tar.gz/qml/MainPage.qml
^
|
@@ -1,4 +1,5 @@
import QtQuick 2.0
+import QtSensors 5.0
import Sailfish.Silica 1.0
import harbour.fire 1.0
@@ -12,6 +13,7 @@
anchors.centerIn: parent
height: thisPage.height * width/thisPage.width
scale: thisPage.width/width // Scaling is far more efficient this way
+ wind: Math.max(Math.min(accelerometer.g/10, 1), -1)
active: Qt.application.active
}
@@ -28,4 +30,15 @@
onPositionChanged: fire.intensity = pressIntensity + (pressY - mouseY)/height
}
+
+ Accelerometer {
+ id: accelerometer
+
+ active: Qt.application.active
+
+ readonly property real g: (reading && active) ?
+ (thisPage.orientation == Orientation.Landscape ? -reading.y :
+ thisPage.orientation == Orientation.LandscapeInverted ? reading.y :
+ thisPage.orientation == Orientation.PortraitInverted ? -reading.x : reading.x) : 0
+ }
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-fire-1.0.3.tar.gz/src/FireItem.cpp
^
|
@@ -1,6 +1,6 @@
/*
+ * Copyright (C) 2022-2023 Slava Monich <slava@monich.com>
* Copyright (C) 2022 Jolla Ltd.
- * Copyright (C) 2022 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -35,9 +35,10 @@
* any official policies, either expressed or implied.
*/
-#include "FireDebug.h"
#include "FireItem.h"
+#include "HarbourDebug.h"
+
#include <QTimer>
#include <QPainter>
#include <QtMath>
@@ -46,7 +47,8 @@
// FireItem::Private
// ==========================================================================
-class FireItem::Private : public QObject
+class FireItem::Private :
+ public QObject
{
Q_OBJECT
@@ -55,6 +57,8 @@
static const qreal MaxIntensity;
static const qreal MinThreshold;
static const qreal MaxThreshold;
+ static const qreal kMinWind;
+ static const qreal kMaxWind;
static const uint BlackPixel;
static const QRgb ColorTable[];
@@ -78,6 +82,7 @@
QTimer* iRepaintTimer;
qreal iIntensity;
qreal iThreshold;
+ qreal iWind;
uint iRand;
};
@@ -85,6 +90,8 @@
const qreal FireItem::Private::MaxIntensity = 1.0;
const qreal FireItem::Private::MinThreshold = 0.5;
const qreal FireItem::Private::MaxThreshold = 0.8;
+const qreal FireItem::Private::kMinWind = -1.0;
+const qreal FireItem::Private::kMaxWind = 1.0;
const uint FireItem::Private::BlackPixel = 0;
const QRgb FireItem::Private::ColorTable[] = {
#define C1(i) qRgb(0, 0, i << 1)
@@ -113,6 +120,7 @@
iRepaintTimer(new QTimer(this)),
iIntensity((MinIntensity + MaxIntensity) / 2),
iThreshold(MinThreshold),
+ iWind((kMinWind + kMaxWind) / 2),
iRand(time(NULL))
{
iColorTable.resize(sizeof(ColorTable)/sizeof(ColorTable[0]));
@@ -161,7 +169,7 @@
iThreshold = qMin(qMax(iThreshold + random() * adjust - adjust/2,
minThreshold()), MaxThreshold);
- DBG(iThreshold);
+ HDEBUG(iThreshold);
}
uchar
@@ -189,6 +197,8 @@
// The rest of the image
const int left = 0;
const int right = w - 1;
+ const qreal b = qAbs(iWind);
+ const qreal d = 4 + b;
for (y--; y >= 0; y--) {
const uchar* lower = iImage.constScanLine(y + 1);
@@ -205,9 +215,16 @@
}
// The rest of the line
- for (int x = left + 1; x < right; x++) {
- row[x] = colorIndex(((uint)row[x] +
- lower[x - 1] + lower[x] + lower[x + 1])/4.0);
+ if (iWind >= 0) {
+ for (int x = left + 1; x < right; x++) {
+ row[x] = colorIndex((row[x - 1] * b + row[x] +
+ lower[x - 1] + lower[x] + lower[x + 1])/d);
+ }
+ } else {
+ for (int x = right - 1; x > left; x--) {
+ row[x] = colorIndex((row[x + 1] * b + row[x] +
+ lower[x - 1] + lower[x] + lower[x + 1])/d);
+ }
}
}
@@ -267,13 +284,32 @@
if (iPrivate->iIntensity != value) {
iPrivate->iIntensity = value;
- DBG(value);
+ HDEBUG(value);
iPrivate->iThreshold = (iPrivate->minThreshold() + Private::MaxThreshold) / 2;
iPrivate->randomizeThreshold();
Q_EMIT intensityChanged();
}
}
+qreal
+FireItem::wind() const
+{
+ return iPrivate->iWind;
+}
+
+void
+FireItem::setWind(
+ qreal aValue)
+{
+ const qreal value = qMin(qMax(aValue, Private::kMinWind), Private::kMaxWind);
+
+ if (iPrivate->iWind != value) {
+ iPrivate->iWind = value;
+ HDEBUG(value);
+ Q_EMIT windChanged();
+ }
+}
+
void
FireItem::paint(
QPainter* aPainter)
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-fire-1.0.3.tar.gz/src/FireItem.h
^
|
@@ -1,6 +1,6 @@
/*
+ * Copyright (C) 2022-2023 Slava Monich <slava@monich.com>
* Copyright (C) 2022 Jolla Ltd.
- * Copyright (C) 2022 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -40,11 +40,13 @@
#include <QQuickPaintedItem>
-class FireItem: public QQuickPaintedItem
+class FireItem:
+ public QQuickPaintedItem
{
Q_OBJECT
Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
Q_PROPERTY(qreal intensity READ intensity WRITE setIntensity NOTIFY intensityChanged)
+ Q_PROPERTY(qreal wind READ wind WRITE setWind NOTIFY windChanged)
public:
explicit FireItem(QQuickItem* aParent = Q_NULLPTR);
@@ -55,12 +57,16 @@
qreal intensity() const;
void setIntensity(qreal);
+ qreal wind() const;
+ void setWind(qreal);
+
protected:
void paint(QPainter*) Q_DECL_OVERRIDE;
Q_SIGNALS:
void activeChanged();
void intensityChanged();
+ void windChanged();
private:
class Private;
|