annotate libgui/src/gui-utils.cc @ 29359:7854d5752dd2

maint: merge stable to default.
author John W. Eaton <jwe@octave.org>
date Wed, 10 Feb 2021 10:10:40 -0500
parents ab8aa1bb3c2f
children 796f54d4ddbf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29220
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
1 ////////////////////////////////////////////////////////////////////////
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
2 //
29359
7854d5752dd2 maint: merge stable to default.
John W. Eaton <jwe@octave.org>
parents: 29220
diff changeset
3 // Copyright (C) 2000-2021 The Octave Project Developers
29220
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
4 //
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
6 // distribution or <https://octave.org/copyright/>.
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
7 //
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
8 // This file is part of Octave.
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
9 //
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
11 // under the terms of the GNU General Public License as published by
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
13 // (at your option) any later version.
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
14 //
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
18 // GNU General Public License for more details.
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
19 //
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
20 // You should have received a copy of the GNU General Public License
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
21 // along with Octave; see the file COPYING. If not, see
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
22 // <https://www.gnu.org/licenses/>.
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
23 //
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
24 ////////////////////////////////////////////////////////////////////////
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
25
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
26 #if defined (HAVE_CONFIG_H)
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
27 # include "config.h"
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
28 #endif
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
29
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
30 #include "gui-utils.h"
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
31
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
32 namespace octave
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
33 {
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
34 OCTGUI_API QColor
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
35 interpolate_color (const QColor& col1, const QColor& col2,
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
36 double fs, double fv)
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
37 {
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
38 qreal h1, s1, v1, h2, s2, v2;
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
39
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
40 col1.getHsvF (&h1, &s1, &v1);
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
41 col2.getHsvF (&h2, &s2, &v2);
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
42
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
43 return QColor::fromHsvF (h1, s1*fs, v1 + fv*(v2 - v1));
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
44 }
ab8aa1bb3c2f add gui utilities with first function for color interpolation
Torsten Lilge <ttl-octave@mailbox.org>
parents:
diff changeset
45 }