Changeset View
Changeset View
Standalone View
Standalone View
plugins/generators/simplexnoise/simplexnoisegenerator.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * KDE. Krita Project. | ||||
3 | * | ||||
4 | * Copyright (c) 2019 Eoin O'Neill <eoinoneill1991@gmail.com> | ||||
5 | * Copyright (c) 2019 Emmet O'Neill <emmetoneill.pdx@gmail.com> | ||||
6 | * | ||||
7 | * This program is free software; you can redistribute it and/or modify | ||||
8 | * it under the terms of the GNU General Public License as published by | ||||
9 | * the Free Software Foundation; either version 2 of the License, or | ||||
10 | * (at your option) any later version. | ||||
11 | * | ||||
12 | * This program is distributed in the hope that it will be useful, | ||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
15 | * GNU General Public License for more details. | ||||
16 | * | ||||
17 | * You should have received a copy of the GNU General Public License | ||||
18 | * along with this program; if not, write to the Free Software | ||||
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
20 | */ | ||||
21 | | ||||
22 | #ifndef NOISEFILTER_H | ||||
23 | #define NOISEFILTER_H | ||||
24 | | ||||
25 | #include <QObject> | ||||
26 | #include <QVariant> | ||||
27 | #include "generator/kis_generator.h" | ||||
28 | | ||||
29 | class KisConfigWidget; | ||||
30 | | ||||
31 | class KisSimplexNoiseGeneratorHandle : public QObject | ||||
32 | { | ||||
33 | Q_OBJECT | ||||
34 | public: | ||||
35 | KisSimplexNoiseGeneratorHandle(QObject *parent, const QVariantList &); | ||||
36 | ~KisSimplexNoiseGeneratorHandle() override; | ||||
37 | }; | ||||
38 | | ||||
39 | class KisSimplexNoiseGenerator : public KisGenerator | ||||
40 | { | ||||
41 | public: | ||||
42 | KisSimplexNoiseGenerator(); | ||||
43 | | ||||
44 | using KisGenerator::generate; | ||||
45 | | ||||
46 | virtual void generate(KisProcessingInformation dst, | ||||
47 | const QSize& size, | ||||
48 | const KisFilterConfigurationSP config, | ||||
49 | KoUpdater* progressUpdater | ||||
50 | ) const override; | ||||
51 | | ||||
52 | static inline KoID id() { | ||||
53 | return KoID("simplex_noise", i18n("Simplex Noise")); | ||||
54 | } | ||||
55 | | ||||
56 | KisFilterConfigurationSP factoryConfiguration() const override; | ||||
57 | KisConfigWidget * createConfigurationWidget(QWidget* parent, const KisPaintDeviceSP dev) const override; | ||||
58 | | ||||
59 | uint seedFromString(const QString &string) const; | ||||
60 | quint64 rotateLeft(const quint64 input, uint d) const; | ||||
61 | | ||||
62 | static inline double map_range(double value, double curr_min, double curr_max, double new_min, double new_max ) { | ||||
63 | return (value - curr_min) * (new_max - new_min) / (curr_max - curr_min) + new_min; | ||||
64 | } | ||||
65 | }; | ||||
66 | #endif |