| 1 | #cxx . . $ `<file>/melder/melder_colour.h`/ifndef _melder_colour_h_ |
| 2 | #define _melder_colour_h_cxx . . $ `melder/melder_colour.h:2:9`! |
| 3 | /* melder_colour.h |
| 4 | * |
| 5 | * Copyright (C) 2019 Paul Boersma |
| 6 | * |
| 7 | * This code 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 (at |
| 10 | * your option) any later version. |
| 11 | * |
| 12 | * This code is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 15 | * See the 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 work. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | struct MelderColourcxx . . $ MelderColour# { |
| 22 | double redcxx . . $ MelderColour#red., greencxx . . $ MelderColour#green., bluecxx . . $ MelderColour#blue., transparencycxx . . $ MelderColour#transparency.; |
| 23 | explicit MelderColourcxx . . $ MelderColour#MelderColour(49f6e7a06ebc5aa8). () : |
| 24 | redcxx . . $ MelderColour#red. (0.0), greencxx . . $ MelderColour#green. (0.0), bluecxx . . $ MelderColour#blue. (0.0), transparencycxx . . $ MelderColour#transparency. (0.0) {} |
| 25 | explicit MelderColourcxx . . $ MelderColour#MelderColour(ba8836b59fb42830). (double greyValue) : |
| 26 | redcxx . . $ MelderColour#red. (Melder_clippedcxx . . $ Melder_clipped(5eb09607cedc971b). (0.0, greyValue, 1.0)), greencxx . . $ MelderColour#green. (redcxx . . $ MelderColour#red.), bluecxx . . $ MelderColour#blue. (redcxx . . $ MelderColour#red.), transparencycxx . . $ MelderColour#transparency. (0.0) {} |
| 27 | explicit MelderColourcxx . . $ MelderColour#MelderColour(98dd472ac7e5c3d4). (double initialRed, double initialGreen, double initialBlue) : |
| 28 | redcxx . . $ MelderColour#red. (initialRed), greencxx . . $ MelderColour#green. (initialGreen), bluecxx . . $ MelderColour#blue. (initialBlue), transparencycxx . . $ MelderColour#transparency. (0.0) {} |
| 29 | explicit MelderColourcxx . . $ MelderColour#MelderColour(52a61fa14d44b641). (double initialRed, double initialGreen, double initialBlue, double initialTransparency) : |
| 30 | redcxx . . $ MelderColour#red. (initialRed), greencxx . . $ MelderColour#green. (initialGreen), bluecxx . . $ MelderColour#blue. (initialBlue), transparencycxx . . $ MelderColour#transparency. (initialTransparency) {} |
| 31 | explicit MelderColourcxx . . $ MelderColour#MelderColour(b62d0ae5a96d0925). (constVECcxx . . $ constVEC# const& vec); |
| 32 | bool validcxx . . $ MelderColour#valid(50ce9a9e25b4a850). () const { |
| 33 | return isdefinedcxx . . $ isdefined(f8197d536af80c96). (ourcxx . . $ `melder/melder.h:42:9`! redcxx . . $ MelderColour#red.); |
| 34 | } |
| 35 | bool isGreycxx . . $ MelderColour#isGrey(50ce9a9e25b4a850). () const { |
| 36 | return ourcxx . . $ `melder/melder.h:42:9`! redcxx . . $ MelderColour#red. == ourcxx . . $ `melder/melder.h:42:9`! greencxx . . $ MelderColour#green. && ourcxx . . $ `melder/melder.h:42:9`! greencxx . . $ MelderColour#green. == ourcxx . . $ `melder/melder.h:42:9`! bluecxx . . $ MelderColour#blue.; |
| 37 | } |
| 38 | }; |
| 39 | |
| 40 | extern MelderColourcxx . . $ MelderColour# Melder_BLACKcxx . . $ Melder_BLACK., Melder_WHITEcxx . . $ Melder_WHITE., Melder_REDcxx . . $ Melder_RED., Melder_GREENcxx . . $ Melder_GREEN., Melder_BLUEcxx . . $ Melder_BLUE., |
| 41 | Melder_CYANcxx . . $ Melder_CYAN., Melder_MAGENTAcxx . . $ Melder_MAGENTA., Melder_YELLOWcxx . . $ Melder_YELLOW., Melder_MAROONcxx . . $ Melder_MAROON., Melder_LIMEcxx . . $ Melder_LIME., Melder_NAVYcxx . . $ Melder_NAVY., Melder_TEALcxx . . $ Melder_TEAL., |
| 42 | Melder_PURPLEcxx . . $ Melder_PURPLE., Melder_OLIVEcxx . . $ Melder_OLIVE., Melder_PINKcxx . . $ Melder_PINK., Melder_SILVERcxx . . $ Melder_SILVER., Melder_GREYcxx . . $ Melder_GREY.; |
| 43 | |
| 44 | MelderColourcxx . . $ MelderColour# MelderColour_fromColourNamecxx . . $ MelderColour_fromColourName(ddf3ca81f5326095). (conststring32cxx . . $ conststring32# colourName); |
| 45 | /* |
| 46 | If `colourName` is one of the 16 standard names (case-insensitively), |
| 47 | then return that colour. If not, then result.valid() will return false. |
| 48 | */ |
| 49 | |
| 50 | MelderColourcxx . . $ MelderColour# MelderColour_fromNumberStringcxx . . $ MelderColour_fromNumberString(ddf3ca81f5326095). (conststring32cxx . . $ conststring32# numberString); |
| 51 | |
| 52 | MelderColourcxx . . $ MelderColour# MelderColour_fromRGBStringcxx . . $ MelderColour_fromRGBString(ddf3ca81f5326095). (conststring32cxx . . $ conststring32# rgbString); |
| 53 | |
| 54 | MelderColourcxx . . $ MelderColour# MelderColour_fromColourNameOrNumberStringOrRGBStringcxx . . $ MelderColour_fromColourNameOrNumberStringOrRGBString(ddf3ca81f5326095). (conststring32cxx . . $ conststring32# string); |
| 55 | |
| 56 | MelderColourcxx . . $ MelderColour# MelderColour_fromColourNameOrRGBStringcxx . . $ MelderColour_fromColourNameOrRGBString(ddf3ca81f5326095). (conststring32cxx . . $ conststring32# string); |
| 57 | |
| 58 | conststring32cxx . . $ conststring32# MelderColour_nameRGBcxx . . $ MelderColour_nameRGB(7dfff7c3df3cd0ae). (MelderColourcxx . . $ MelderColour# colour); |
| 59 | conststring32cxx . . $ conststring32# MelderColour_namePrettyOrNullcxx . . $ MelderColour_namePrettyOrNull(7dfff7c3df3cd0ae). (MelderColourcxx . . $ MelderColour# colour); |
| 60 | conststring32cxx . . $ conststring32# MelderColour_namecxx . . $ MelderColour_name(7dfff7c3df3cd0ae). (MelderColourcxx . . $ MelderColour# colour); |
| 61 | |
| 62 | static inline bool MelderColour_equalcxx . . $ MelderColour_equal(d84867a02c6595e6). (MelderColourcxx . . $ MelderColour# colour1, MelderColourcxx . . $ MelderColour# colour2) { |
| 63 | return |
| 64 | colour1. redcxx . . $ MelderColour#red. == colour2. redcxx . . $ MelderColour#red. && |
| 65 | colour1. greencxx . . $ MelderColour#green. == colour2. greencxx . . $ MelderColour#green. && |
| 66 | colour1. bluecxx . . $ MelderColour#blue. == colour2. bluecxx . . $ MelderColour#blue. && |
| 67 | colour1. transparencycxx . . $ MelderColour#transparency. == colour2. transparencycxx . . $ MelderColour#transparency.; |
| 68 | } |
| 69 | MelderColourcxx . . $ MelderColour# Melder_cyclingBackgroundColourcxx . . $ Melder_cyclingBackgroundColour(919a6c82b92b763e). (integercxx . . $ integer# category); |
| 70 | MelderColourcxx . . $ MelderColour# Melder_cyclingTextColourcxx . . $ Melder_cyclingTextColour(919a6c82b92b763e). (integercxx . . $ integer# category); |
| 71 | |
| 72 | static inline MelderColourcxx . . $ MelderColour# operatorcxx . . $ `operator*`(b464376f9cf8932a).* (double multiplier, MelderColourcxx . . $ MelderColour# me) { |
| 73 | return |
| 74 | multiplier <= 1.0 ? |
| 75 | MelderColourcxx . . $ MelderColour#MelderColour(52a61fa14d44b641). (me.redcxx . . $ MelderColour#red. * multiplier, me.greencxx . . $ MelderColour#green. * multiplier, me.bluecxx . . $ MelderColour#blue. * multiplier, me.transparencycxx . . $ MelderColour#transparency.) |
| 76 | : |
| 77 | MelderColourcxx . . $ MelderColour#MelderColour(52a61fa14d44b641). ( |
| 78 | 1.0 - (1.0 - me.redcxx . . $ MelderColour#red.) / multiplier, |
| 79 | 1.0 - (1.0 - me.greencxx . . $ MelderColour#green.) / multiplier, |
| 80 | 1.0 - (1.0 - me.bluecxx . . $ MelderColour#blue.) / multiplier, |
| 81 | me.transparencycxx . . $ MelderColour#transparency. |
| 82 | ) |
| 83 | ; |
| 84 | } |
| 85 | |
| 86 | /* End of file melder_colour.h */ |
| 87 | #endif |