OpenStructure
Loading...
Searching...
No Matches
gradient.hh
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// This file is part of the OpenStructure project <www.openstructure.org>
3//
4// Copyright (C) 2008-2020 by the OpenStructure authors
5//
6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License as published by the Free
8// Software Foundation; either version 3.0 of the License, or (at your option)
9// any later version.
10// This library is distributed in the hope that it will be useful, but WITHOUT
11// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13// details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with this library; if not, write to the Free Software Foundation, Inc.,
17// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18//------------------------------------------------------------------------------
19#ifndef OST_GFX_GRADIENT_HH
20#define OST_GFX_GRADIENT_HH
21
22/*
23 Authors: Marco Biasini, Ansgar Philippsen
24*/
25
26#include <vector>
27
28#include "color.hh"
29
30#include <ost/info/info.hh>
31#include <ost/info/info_fw.hh>
32
33namespace ost { namespace gfx {
34
60public:
61 struct Stop {
62 Stop(): t(0.0) {}
63
64 Stop(float tt, const Color& c): t(tt), color(c) {}
65 float t;
67
68 Color GetColor() const {
69 return color;
70 }
71
72 float GetRel() const {
73 return t;
74 }
75
76 bool operator==(const Stop& ref) const
77 {
78 return t==ref.t && color==ref.color;
79 }
80
81 };
82
83 typedef std::vector<Stop> StopList;
84
85public:
91
93 Gradient(const String& name);
94
96 Color GetColorAt(float t) const;
101 void SetColorAt(float t, const Color& color);
102
104 // TODO: rename to ToInfo
105 // TODO:: add stand-alone function named GradientToInfo(Gradient, InfoGroup)
106 void GradientToInfo(info::InfoGroup& group) const;
107
110
112 // TODO: move outside
113 // TODO: add FromInfo member function that overwrites this
115
117 void SetHSVMode(bool m) {hsv_mode_=m;}
119 bool GetHSVMode() const {return hsv_mode_;}
120
121private:
122 std::vector<Stop> stops_;
123 bool hsv_mode_;
124};
125
126
130}}
131
132#endif
color gradient
Definition gradient.hh:59
StopList GetStops() const
get list of color stops
void GradientToInfo(info::InfoGroup &group) const
convert gradient to info
static gfx::Gradient GradientFromInfo(const info::InfoGroup &group)
create gradient from info
std::vector< Stop > StopList
Definition gradient.hh:83
Gradient(const String &name)
initialize with a pre-define gradient name
bool GetHSVMode() const
return the HSV interpolation mode flag
Definition gradient.hh:119
void SetColorAt(float t, const Color &color)
set color
Color GetColorAt(float t) const
get color
void SetHSVMode(bool m)
turn HSV interpolation mode on or off
Definition gradient.hh:117
#define DLLEXPORT_OST_GFX
std::string String
Definition base.hh:54
Definition base.dox:1
Color GetColor() const
Definition gradient.hh:68
Stop(float tt, const Color &c)
Definition gradient.hh:64
float GetRel() const
Definition gradient.hh:72
bool operator==(const Stop &ref) const
Definition gradient.hh:76