cgv
Loading...
Searching...
No Matches
named_color_schemes.h
1/* Sources:
2
3[1] d3js https://d3js.org/
4A subset of color schemes was ported from d3js-scale-chromatic (https://github.com/d3/d3-scale-chromatic/).
5These include:
6// sequential schemes: blues_data, greens_data, grays_data, oranges_data, purples_data, reds_data
7// diverging schemes: BrBG_data, PiYG_data, PRGn_data, PuOr_data, RdBu_data, RdGy_data, RdYlBu_data, RdYlGn_data, spectral_data
8// cyclic schemes: turbo_fn, viridis_data, magma_data, inferno_data, plasma_data, cividis_fn
9// categorical schemes: category10_data, accent8_data, dark8_data, observable10_data, paired12_data, pastel8_1_data, pastel8_2_data, set8_data, set9_data, set12_data, tableau10_data
10
11License:
12d3js copyright notice
13Copyright 2010-2024 Mike Bostock
14
15Permission to use, copy, modify, and/or distribute this software for any purpose
16with or without fee is hereby granted, provided that the above copyright notice
17and this permission notice appear in all copies.
18
19THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
20REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
21FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
22INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
23OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
24TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
25THIS SOFTWARE.
26
27Apache-Style Software License for ColorBrewer software and ColorBrewer Color Schemes
28
29Copyright 2002 Cynthia Brewer, Mark Harrower, and The Pennsylvania State University
30
31Licensed under the Apache License, Version 2.0 (the "License"); you may not use
32this file except in compliance with the License. You may obtain a copy of the
33License at
34
35http://www.apache.org/licenses/LICENSE-2.0
36
37Unless required by applicable law or agreed to in writing, software distributed
38under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
39CONDITIONS OF ANY KIND, either express or implied. See the License for the
40specific language governing permissions and limitations under the License.
41
42==============================================================================
43
44[2] Matplotlib https://matplotlib.org/
45A subset of color schemes was ported from Matpotlib (https://github.com/matplotlib/matplotlib/tree/main/lib/matplotlib/_cm.py).
46These include: bone_data, jet_data, hot_data, twilight_data
47
48License:
49License agreement for matplotlib versions 1.3.0 and later
50=========================================================
51
521. This LICENSE AGREEMENT is between the Matplotlib Development Team
53("MDT"), and the Individual or Organization ("Licensee") accessing and
54otherwise using matplotlib software in source or binary form and its
55associated documentation.
56
572. Subject to the terms and conditions of this License Agreement, MDT
58hereby grants Licensee a nonexclusive, royalty-free, world-wide license
59to reproduce, analyze, test, perform and/or display publicly, prepare
60derivative works, distribute, and otherwise use matplotlib
61alone or in any derivative version, provided, however, that MDT's
62License Agreement and MDT's notice of copyright, i.e., "Copyright (c)
632012- Matplotlib Development Team; All Rights Reserved" are retained in
64matplotlib alone or in any derivative version prepared by
65Licensee.
66
673. In the event Licensee prepares a derivative work that is based on or
68incorporates matplotlib or any part thereof, and wants to
69make the derivative work available to others as provided herein, then
70Licensee hereby agrees to include in any such work a brief summary of
71the changes made to matplotlib .
72
734. MDT is making matplotlib available to Licensee on an "AS
74IS" basis. MDT MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
75IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, MDT MAKES NO AND
76DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
77FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF MATPLOTLIB
78WILL NOT INFRINGE ANY THIRD PARTY RIGHTS.
79
805. MDT SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF MATPLOTLIB
81 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR
82LOSS AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING
83MATPLOTLIB , OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF
84THE POSSIBILITY THEREOF.
85
866. This License Agreement will automatically terminate upon a material
87breach of its terms and conditions.
88
897. Nothing in this License Agreement shall be deemed to create any
90relationship of agency, partnership, or joint venture between MDT and
91Licensee. This License Agreement does not grant permission to use MDT
92trademarks or trade name in a trademark sense to endorse or promote
93products or services of Licensee, or any third party.
94
958. By copying, installing or otherwise using matplotlib ,
96Licensee agrees to be bound by the terms and conditions of this License
97Agreement.
98
99License agreement for matplotlib versions prior to 1.3.0
100========================================================
101
1021. This LICENSE AGREEMENT is between John D. Hunter ("JDH"), and the
103Individual or Organization ("Licensee") accessing and otherwise using
104matplotlib software in source or binary form and its associated
105documentation.
106
1072. Subject to the terms and conditions of this License Agreement, JDH
108hereby grants Licensee a nonexclusive, royalty-free, world-wide license
109to reproduce, analyze, test, perform and/or display publicly, prepare
110derivative works, distribute, and otherwise use matplotlib
111alone or in any derivative version, provided, however, that JDH's
112License Agreement and JDH's notice of copyright, i.e., "Copyright (c)
1132002-2011 John D. Hunter; All Rights Reserved" are retained in
114matplotlib alone or in any derivative version prepared by
115Licensee.
116
1173. In the event Licensee prepares a derivative work that is based on or
118incorporates matplotlib or any part thereof, and wants to
119make the derivative work available to others as provided herein, then
120Licensee hereby agrees to include in any such work a brief summary of
121the changes made to matplotlib.
122
1234. JDH is making matplotlib available to Licensee on an "AS
124IS" basis. JDH MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
125IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, JDH MAKES NO AND
126DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
127FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF MATPLOTLIB
128WILL NOT INFRINGE ANY THIRD PARTY RIGHTS.
129
1305. JDH SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF MATPLOTLIB
131 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR
132LOSS AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING
133MATPLOTLIB , OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF
134THE POSSIBILITY THEREOF.
135
1366. This License Agreement will automatically terminate upon a material
137breach of its terms and conditions.
138
1397. Nothing in this License Agreement shall be deemed to create any
140relationship of agency, partnership, or joint venture between JDH and
141Licensee. This License Agreement does not grant permission to use JDH
142trademarks or trade name in a trademark sense to endorse or promote
143products or services of Licensee, or any third party.
144
1458. By copying, installing or otherwise using matplotlib,
146Licensee agrees to be bound by the terms and conditions of this License
147Agreement.
148
149==============================================================================
150
151[3] Cynthia A. BrewerÂ’s ColorBrewer https://colorbrewer2.org/
152Many of the color schemes listed under [1] and [2] originate from Cynthia A. Brewer's ColorBrewer
153
154License:
155Apache-Style Software License for ColorBrewer software and ColorBrewer Color Schemes
156
157Copyright (c) 2002 Cynthia Brewer, Mark Harrower, and The Pennsylvania State University.
158
159Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
160You may obtain a copy of the License at
161
162http://www.apache.org/licenses/LICENSE-2.0
163
164Unless required by applicable law or agreed to in writing, software distributed
165under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
166CONDITIONS OF ANY KIND, either express or implied. See the License for the
167specific language governing permissions and limitations under the License.
168*/
169
170#pragma once
171
172#include <array>
173#include <set>
174
175#include <cgv/math/interpolate.h>
176
177#include "color.h"
178#include "color_scheme.h"
179
180#include "lib_begin.h"
181
182namespace cgv {
183namespace media {
184namespace schemes {
185
187template<typename ParamT = float>
189public:
190 using point_type = std::pair<ParamT, float>;
191
193
194 rgb_per_channel_piecewise_interpolator(const std::vector<point_type>& red_points, const std::vector<point_type>& green_points, const std::vector<point_type>& blue_points) {
195 points[0] = red_points;
196 points[1] = green_points;
197 points[2] = blue_points;
198 }
199
200 std::unique_ptr<cgv::math::interpolator<cgv::rgb, ParamT>> clone() const override {
201 return std::unique_ptr<cgv::math::interpolator<cgv::rgb, ParamT>>(new rgb_per_channel_piecewise_interpolator(*this));
202 };
203
204 cgv::rgb at(ParamT t) const override {
205 return {
206 cgv::math::interpolate_linear(points[0], t),
207 cgv::math::interpolate_linear(points[1], t),
208 cgv::math::interpolate_linear(points[2], t)
209 };
210 }
211
212 std::vector<point_type> points[3];
213};
214
215// sequential (single-hue)
216constexpr std::array<const char*, 7> blues_data = {
217 "deebf79ecae13182bd",
218 "eff3ffbdd7e76baed62171b5",
219 "eff3ffbdd7e76baed63182bd08519c",
220 "eff3ffc6dbef9ecae16baed63182bd08519c",
221 "eff3ffc6dbef9ecae16baed64292c62171b5084594",
222 "f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594",
223 "f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b"
224};
225constexpr std::array<const char*, 7> greens_data = {
226 "e5f5e0a1d99b31a354",
227 "edf8e9bae4b374c476238b45",
228 "edf8e9bae4b374c47631a354006d2c",
229 "edf8e9c7e9c0a1d99b74c47631a354006d2c",
230 "edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32",
231 "f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32",
232 "f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b"
233};
234constexpr std::array<const char*, 7> grays_data = {
235 "f0f0f0bdbdbd636363",
236 "f7f7f7cccccc969696525252",
237 "f7f7f7cccccc969696636363252525",
238 "f7f7f7d9d9d9bdbdbd969696636363252525",
239 "f7f7f7d9d9d9bdbdbd969696737373525252252525",
240 "fffffff0f0f0d9d9d9bdbdbd969696737373525252252525",
241 "fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000"
242};
243constexpr std::array<const char*, 7> oranges_data = {
244 "fee6cefdae6be6550d",
245 "feeddefdbe85fd8d3cd94701",
246 "feeddefdbe85fd8d3ce6550da63603",
247 "feeddefdd0a2fdae6bfd8d3ce6550da63603",
248 "feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04",
249 "fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04",
250 "fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704"
251};
252constexpr std::array<const char*, 7> purples_data = {
253 "efedf5bcbddc756bb1",
254 "f2f0f7cbc9e29e9ac86a51a3",
255 "f2f0f7cbc9e29e9ac8756bb154278f",
256 "f2f0f7dadaebbcbddc9e9ac8756bb154278f",
257 "f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486",
258 "fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486",
259 "fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d"
260};
261static constexpr std::array<const char*, 7> reds_data = {
262 "fee0d2fc9272de2d26",
263 "fee5d9fcae91fb6a4acb181d",
264 "fee5d9fcae91fb6a4ade2d26a50f15",
265 "fee5d9fcbba1fc9272fb6a4ade2d26a50f15",
266 "fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d",
267 "fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d",
268 "fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d"
269};
270
271static auto interpolateBlues() { return continuous_color_scheme::smooth(to_colors(blues_data.back()), ColorSchemeType::kSequential); }
272static auto interpolateGreens() { return continuous_color_scheme::smooth(to_colors(greens_data.back()), ColorSchemeType::kSequential); }
273static auto interpolateGrays() { return continuous_color_scheme::smooth(to_colors(grays_data.back()), ColorSchemeType::kSequential); }
274static auto interpolateOranges() { return continuous_color_scheme::smooth(to_colors(oranges_data.back()), ColorSchemeType::kSequential); }
275static auto interpolatePurples() { return continuous_color_scheme::smooth(to_colors(purples_data.back()), ColorSchemeType::kSequential); }
276static auto interpolateReds() { return continuous_color_scheme::smooth(to_colors(reds_data.back()), ColorSchemeType::kSequential); }
277
278static auto schemeBlues() { return discrete_color_scheme(to_colors(blues_data), ColorSchemeType::kSequential); }
279static auto schemeGreens() { return discrete_color_scheme(to_colors(greens_data), ColorSchemeType::kSequential); }
280static auto schemeGrays() { return discrete_color_scheme(to_colors(grays_data), ColorSchemeType::kSequential); }
281static auto schemeOranges() { return discrete_color_scheme(to_colors(oranges_data), ColorSchemeType::kSequential); }
282static auto schemePurples() { return discrete_color_scheme(to_colors(purples_data), ColorSchemeType::kSequential); }
283static auto schemeReds() { return discrete_color_scheme(to_colors(reds_data), ColorSchemeType::kSequential); }
284
285// sequential (multi-hue)
286// Viridis turbo
287static cgv::rgb turbo_fn(float t) {
288 cgv::rgb color = {
289 0.1357f + t * (4.5974f - t * (42.3277f - t * (130.5887f - t * (150.5666f - t * 58.1375f)))),
290 0.0914f + t * (2.1856f + t * (4.8052f - t * (14.0195f - t * (4.2109f + t * 2.7747f)))),
291 0.1067f + t * (12.5925f - t * (60.1097f - t * (109.0745f - t * (88.5066f - t * 26.8183f))))
292 };
293 color.clamp();
294 return color;
295}
296// Cividis from Nunez, Anderton, and Renslow (https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0199239)
297static cgv::rgb cividis_fn(float t) {
298 cgv::rgb color = {
299 -0.0178f - t * (0.1386f - t * (9.3401f - t * (25.1086f - t * (27.5479f - t * 10.6297f)))),
300 0.1274f + t * (0.6695f + t * (0.2071f - t * (0.5155f - t * (0.6925f - t * 0.2642f)))),
301 0.3186f + t * (1.7347f - t * (9.735f - t * (24.1853f - t * (25.9409f - t * 9.7085f))))
302 };
303 color.clamp();
304 return color;
305}
306constexpr const char* viridis_data = "44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725";
307constexpr const char* magma_data = "00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf";
308constexpr const char* inferno_data = "00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4";
309constexpr const char* plasma_data = "0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921";
310
311// Matplotlib bone. A grayscale color map with a blue tint, useful for adding an "electronic" look to grayscale images.
312const std::array<std::vector<std::pair<float, float>>, 3> bone_data = { {
313 {
314 { 0.0f, 0.0f },
315 { 0.746032f, 0.652778f },
316 { 1.0f, 1.0f },
317 },
318 {
319 { 0.0f, 0.0f },
320 { 0.365079f, 0.319444f },
321 { 0.746032f, 0.777778f },
322 { 1.0f, 1.0f }
323 },
324 {
325 { 0.0f, 0.0f },
326 { 0.365079f, 0.444444f },
327 { 1.0f, 1.0f }
328 }
329} };
330// Matplotlib jet. A sequential rainbow-like color map from dark blue over green and yellow to dark red. Use with caution; prefer turbo instead.
331const std::array<std::vector<std::pair<float, float>>, 3> jet_data = { {
332 {
333 { 0.00f, 0.0f },
334 { 0.35f, 0.0f },
335 { 0.66f, 1.0f },
336 { 0.89f, 1.0f },
337 { 1.00f, 0.5f }
338 },
339 {
340 { 0.000f, 0.0f },
341 { 0.125f, 0.0f },
342 { 0.375f, 1.0f },
343 { 0.640f, 1.0f },
344 { 0.910f, 0.0f },
345 { 1.000f, 0.0f }
346 },
347 {
348 { 0.00f, 0.5f },
349 { 0.11f, 1.0f },
350 { 0.34f, 1.0f },
351 { 0.65f, 0.0f },
352 { 1.00f, 0.0f }
353 }
354} };
355// Matplotlib hot.
356const std::array<std::vector<std::pair<float, float>>, 3> hot_data = { {
357 {
358 { 0.0f, 0.0416f },
359 { 0.365079f, 1.0f },
360 { 1.0f, 1.0f },
361 },
362 {
363 { 0.0f, 0.0f },
364 { 0.365079f, 0.0f },
365 { 0.746032f, 1.0f },
366 { 1.0f, 1.0f }
367 },
368 {
369 { 0.0f, 0.0f },
370 { 0.746032f, 0.0f },
371 { 1.0f, 1.0f }
372 }
373} };
374
375static continuous_color_scheme interpolateBone() { return { rgb_per_channel_piecewise_interpolator<float>(bone_data[0], bone_data[1], bone_data[2]) }; }
376static continuous_color_scheme interpolateJet() { return { rgb_per_channel_piecewise_interpolator<float>(jet_data[0], jet_data[1], jet_data[2]) }; }
377static continuous_color_scheme interpolateHot() { return { rgb_per_channel_piecewise_interpolator<float>(hot_data[0], hot_data[1], hot_data[2]) }; }
378static auto interpolateTurbo() { return continuous_color_scheme::function(turbo_fn); }
379static auto interpolateViridis() { return continuous_color_scheme::linear(to_colors(viridis_data)); }
380static auto interpolateMagma() { return continuous_color_scheme::linear(to_colors(magma_data)); }
381static auto interpolateInferno() { return continuous_color_scheme::linear(to_colors(inferno_data)); }
382static auto interpolatePlasma() { return continuous_color_scheme::linear(to_colors(plasma_data)); }
383static auto interpolateCividis() { return continuous_color_scheme::function(cividis_fn); }
384
385// diverging
386constexpr std::array<const char*, 9> BrBG_data = {
387 "d8b365f5f5f55ab4ac",
388 "a6611adfc27d80cdc1018571",
389 "a6611adfc27df5f5f580cdc1018571",
390 "8c510ad8b365f6e8c3c7eae55ab4ac01665e",
391 "8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e",
392 "8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e",
393 "8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e",
394 "5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30",
395 "5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30"
396};
397constexpr std::array<const char*, 9> PiYG_data = {
398 "e9a3c9f7f7f7a1d76a",
399 "d01c8bf1b6dab8e1864dac26",
400 "d01c8bf1b6daf7f7f7b8e1864dac26",
401 "c51b7de9a3c9fde0efe6f5d0a1d76a4d9221",
402 "c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221",
403 "c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221",
404 "c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221",
405 "8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419",
406 "8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419"
407};
408constexpr std::array<const char*, 9> PRGn_data = {
409 "af8dc3f7f7f77fbf7b",
410 "7b3294c2a5cfa6dba0008837",
411 "7b3294c2a5cff7f7f7a6dba0008837",
412 "762a83af8dc3e7d4e8d9f0d37fbf7b1b7837",
413 "762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837",
414 "762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837",
415 "762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837",
416 "40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b",
417 "40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b"
418};
419constexpr std::array<const char*, 9> PuOr_data = {
420 "998ec3f7f7f7f1a340",
421 "5e3c99b2abd2fdb863e66101",
422 "5e3c99b2abd2f7f7f7fdb863e66101",
423 "542788998ec3d8daebfee0b6f1a340b35806",
424 "542788998ec3d8daebf7f7f7fee0b6f1a340b35806",
425 "5427888073acb2abd2d8daebfee0b6fdb863e08214b35806",
426 "5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806",
427 "2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08",
428 "2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08"
429};
430constexpr std::array<const char*, 9> RdBu_data = {
431 "ef8a62f7f7f767a9cf",
432 "ca0020f4a58292c5de0571b0",
433 "ca0020f4a582f7f7f792c5de0571b0",
434 "b2182bef8a62fddbc7d1e5f067a9cf2166ac",
435 "b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac",
436 "b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac",
437 "b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac",
438 "67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061",
439 "67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061"
440};
441constexpr std::array<const char*, 9> RdGy_data = {
442 "ef8a62ffffff999999",
443 "ca0020f4a582bababa404040",
444 "ca0020f4a582ffffffbababa404040",
445 "b2182bef8a62fddbc7e0e0e09999994d4d4d",
446 "b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d",
447 "b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d",
448 "b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d",
449 "67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a",
450 "67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a"
451};
452constexpr std::array<const char*, 9> RdYlBu_data = {
453 "fc8d59ffffbf91bfdb",
454 "d7191cfdae61abd9e92c7bb6",
455 "d7191cfdae61ffffbfabd9e92c7bb6",
456 "d73027fc8d59fee090e0f3f891bfdb4575b4",
457 "d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4",
458 "d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4",
459 "d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4",
460 "a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695",
461 "a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695"
462};
463constexpr std::array<const char*, 9> RdYlGn_data = {
464 "fc8d59ffffbf91cf60",
465 "d7191cfdae61a6d96a1a9641",
466 "d7191cfdae61ffffbfa6d96a1a9641",
467 "d73027fc8d59fee08bd9ef8b91cf601a9850",
468 "d73027fc8d59fee08bffffbfd9ef8b91cf601a9850",
469 "d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850",
470 "d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850",
471 "a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837",
472 "a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837"
473};
474
475static auto interpolateBrBG() { return continuous_color_scheme::smooth(to_colors(BrBG_data.back()), ColorSchemeType::kDiverging); }
476static auto interpolatePiYG() { return continuous_color_scheme::smooth(to_colors(PiYG_data.back()), ColorSchemeType::kDiverging); }
477static auto interpolatePRGn() { return continuous_color_scheme::smooth(to_colors(PRGn_data.back()), ColorSchemeType::kDiverging); }
478static auto interpolatePuOr() { return continuous_color_scheme::smooth(to_colors(PuOr_data.back()), ColorSchemeType::kDiverging); }
479static auto interpolateRdBu() { return continuous_color_scheme::smooth(to_colors(RdBu_data.back()), ColorSchemeType::kDiverging); }
480static auto interpolateRdGy() { return continuous_color_scheme::smooth(to_colors(RdGy_data.back()), ColorSchemeType::kDiverging); }
481static auto interpolateRdYlBu() { return continuous_color_scheme::smooth(to_colors(RdYlBu_data.back()), ColorSchemeType::kDiverging); }
482static auto interpolateRdYlGn() { return continuous_color_scheme::smooth(to_colors(RdYlGn_data.back()), ColorSchemeType::kDiverging); }
483
484static auto schemeBrBG() { return discrete_color_scheme(to_colors(BrBG_data), ColorSchemeType::kDiverging); }
485static auto schemePRGn() { return discrete_color_scheme(to_colors(PRGn_data), ColorSchemeType::kDiverging); }
486static auto schemePiYG() { return discrete_color_scheme(to_colors(PiYG_data), ColorSchemeType::kDiverging); }
487static auto schemePuOr() { return discrete_color_scheme(to_colors(PuOr_data), ColorSchemeType::kDiverging); }
488static auto schemeRdBu() { return discrete_color_scheme(to_colors(RdBu_data), ColorSchemeType::kDiverging); }
489static auto schemeRdGy() { return discrete_color_scheme(to_colors(RdGy_data), ColorSchemeType::kDiverging); }
490static auto schemeRdYlBu() { return discrete_color_scheme(to_colors(RdYlBu_data), ColorSchemeType::kDiverging); }
491static auto schemeRdYlGn() { return discrete_color_scheme(to_colors(RdYlGn_data), ColorSchemeType::kDiverging); }
492
493constexpr const char* spectral_data = "9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2";
494static auto interpolateSpectral() { return continuous_color_scheme::smooth(to_colors(spectral_data)); }
495
496// cyclical
497constexpr const char* hue_data = "ff0000ffff0000ff0000ffff0000ffff00ffff0000";
498constexpr const char* twilight_data = "e1d8e2e0d9e2dfd9e1ded9e0ddd9e0dbd8dfd9d8ded8d7ddd6d6dcd4d6dbd2d5dacfd4d9cdd2d8cad1d7c7d0d6c5cfd4c2cdd3bfccd2bccbd1b9c9d0b6c8cfb3c6ceb0c4cdadc3ccaac1cba7c0caa4becaa1bcc99ebbc89bb9c898b7c796b5c793b4c690b2c58eb0c58baec589adc487abc484a9c382a7c380a5c37ea3c27ca1c27a9fc2789ec1769cc1749ac17398c07196c07094c06e92bf6d90bf6b8ebf6a8cbe698abe6888be6786bd6683bd6581bd647fbc647dbc637bbb6279bb6277ba6174ba6172b96070b8606eb8606bb75f69b65f67b65f65b55f62b45f60b35e5eb25e5bb15e59b05e57af5e54ae5e52ad5e4fac5e4daa5e4ba95d48a85d46a65d43a55d41a35d3ea15c3c9f5c3a9e5c379c5b359a5b32975a30955a2e93592b9059298e58278b572588562386552183541f7f531d7c521c79511a764f19724e186f4c176b4b166849156547146146135e44135b4212574012543f11513d114e3c114c3a104939104637104436104235104034113e33113c32113a3112393013372f13363012363212373311373411373611383711393911393a113a3c113b3e113c40113d42113e44123f4712404912414c13424e13435014445314455615465815475b16485d174960174a63184b65194b68194c6b1a4d6d1b4d701c4e721d4e751e4f781f4f7a204f7d214f7f22508124508425508626508828508b29508d2b508f2d50912e4f93304f95324f97344f99364f9b374f9d394f9e3b4fa03d4fa23f4fa4414fa5444fa7464fa84850aa4a50ab4c50ad4e50ae5051b05351b15551b25752b45952b55c53b65e54b76054b86355b96556ba6757bc6a58bc6c59bd6f5abe715cbf735dc0765ec17860c27b61c27d63c38065c48267c48569c5876bc68a6dc68c6fc78e71c79174c89376c99679c9987cca9b7eca9d81cba084cba287cca48acda78dcda991ceab94ceae97cfb09ad0b29ed1b5a1d1b7a4d2b9a8d3bbabd4bdafd5bfb2d6c1b6d7c3b9d8c5bcd8c7c0d9c9c3dacbc6dbcdc9dcceccddd0cfddd1d2ded3d4dfd4d6dfd5d8e0d6dae0d7dce1d7dde1d8dfe1d8e0e1d8e1";
499
500static auto interpolateHue() { return continuous_color_scheme::linear(to_colors(hue_data), ColorSchemeType::kCyclical); }
501static auto interpolateTwilight() { return continuous_color_scheme::linear(to_colors(twilight_data), ColorSchemeType::kCyclical); }
502
503// categorical
504constexpr const char* category10_data = "1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf";
505constexpr const char* accent8_data = "7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666";
506constexpr const char* dark8_data = "1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666";
507constexpr const char* observable10_data = "4269d0efb118ff725c6cc5b03ca951ff8ab7a463f297bbf59c6b4e9498a0";
508constexpr const char* paired12_data = "a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928";
509constexpr const char* pastel8_1_data = "fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2";
510constexpr const char* pastel8_2_data = "b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc";
511constexpr const char* set8_data = "66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3";
512constexpr const char* set9_data = "e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999";
513constexpr const char* set12_data = "8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f";
514constexpr const char* tableau10_data = "4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab";
515
516static auto schemeCategory10() { return discrete_color_scheme(to_colors(category10_data), ColorSchemeType::kCategorical);}
517static auto schemeAccent8() { return discrete_color_scheme(to_colors(accent8_data), ColorSchemeType::kCategorical); }
518static auto schemeDark8() { return discrete_color_scheme(to_colors(dark8_data), ColorSchemeType::kCategorical); }
519static auto schemeObservable10() { return discrete_color_scheme(to_colors(observable10_data), ColorSchemeType::kCategorical); }
520static auto schemePaired12() { return discrete_color_scheme(to_colors(paired12_data), ColorSchemeType::kCategorical); }
521static auto schemePastel8_1() { return discrete_color_scheme(to_colors(pastel8_1_data), ColorSchemeType::kCategorical); }
522static auto schemePastel8_2() { return discrete_color_scheme(to_colors(pastel8_2_data), ColorSchemeType::kCategorical); }
523static auto schemeSet8() { return discrete_color_scheme(to_colors(set8_data), ColorSchemeType::kCategorical); }
524static auto schemeSet9() { return discrete_color_scheme(to_colors(set9_data), ColorSchemeType::kCategorical); }
525static auto schemeSet12() { return discrete_color_scheme(to_colors(set12_data), ColorSchemeType::kCategorical); }
526static auto schemeTableau10() { return discrete_color_scheme(to_colors(tableau10_data), ColorSchemeType::kCategorical); }
527
528} // namespace schemes
529
530extern CGV_API size_t load_continuous_color_scheme_presets(continuous_color_scheme_registry& registry, const std::set<ColorSchemeType>& types = {});
531extern CGV_API size_t load_discrete_color_scheme_presets(discrete_color_scheme_registry& registry, const std::set<ColorSchemeType>& types = {});
532
533} // namespace media
534} // namespace cgv
535
536#include <cgv/config/lib_end.h>
Template of an abstract interface for interpolators that can be evaluated at a position t and return ...
void clamp(const T &mn=0, const T &mx=color_one< T >::value(), bool skip_alpha=false)
clamp to the given range, which defaults to [0,1] of the component type
Definition color.h:726
static continuous_color_scheme smooth(const std::vector< cgv::rgb > &colors, ColorSchemeType type=ColorSchemeType::kUndefined)
Create a continuous_color_scheme using uniform b-spline interpolation of the given colors.
static continuous_color_scheme function(std::function< cgv::rgb(float)> fn, ColorSchemeType type=ColorSchemeType::kUndefined)
Create a continuous_color_scheme using a functor as interpolator.
static continuous_color_scheme linear(const std::vector< cgv::rgb > &colors, ColorSchemeType type=ColorSchemeType::kUndefined)
Create a continuous_color_scheme using uniform linear interpolation of the given colors.
Implementation of a specialized interpolator for rgb colors that allows separate piecewise linear int...
cgv::rgb at(ParamT t) const override
Return the interpolated value at position t.
this header is dependency free
Definition print.h:11