1 /* === S Y N F I G ========================================================= */
3 ** \brief Template Header
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 /* ========================================================================= */
23 /* === S T A R T =========================================================== */
25 #ifndef __SYNFIG_PALETTE_H
26 #define __SYNFIG_PALETTE_H
28 /* === H E A D E R S ======================================================= */
34 /* === M A C R O S ========================================================= */
36 /* === T Y P E D E F S ===================================================== */
38 /* === C L A S S E S & S T R U C T S ======================================= */
50 PaletteItem():weight(1) { }
52 PaletteItem(const Color& color, const String& name, int weight=1):
53 color(color),name(name),weight(weight) { }
55 PaletteItem(const Color& color, int weight=1):
56 color(color),weight(weight) { }
58 void add(const Color& x, int weight=1);
60 bool operator<(const PaletteItem& rhs)const { return weight<rhs.weight; }
61 }; // END of struct PaletteItem
63 class Palette : public std::vector<PaletteItem>
69 Palette(const String& name_);
71 /*! Generates a palette for the given
74 Palette(const Surface& surface, int size=256);
76 iterator find_closest(const Color& color, float* dist=0);
77 const_iterator find_closest(const Color& color, float* dist=0)const;
79 iterator find_heavy();
81 iterator find_light();
83 static Palette grayscale(int steps=16);
85 void save_to_file(const synfig::String& filename)const;
87 static Palette load_from_file(const synfig::String& filename);
88 }; // END of class Palette
90 }; // END of namespace synfig
92 /* === E N D =============================================================== */