Current Version: 1.0.10
Project Name: csspp
color.h
Go to the documentation of this file.
1 #ifndef CSSPP_COLOR_H
2 #define CSSPP_COLOR_H
3 // CSS Preprocessor
4 // Copyright (C) 2015-2016 Made to Order Software Corp.
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 
20 #include <cstdint>
21 #include <string>
22 
23 namespace csspp
24 {
25 
26 typedef float color_component_t;
27 typedef uint8_t byte_component_t;
28 typedef uint32_t rgba_color_t;
29 
31 {
36  char const * f_name;
37 };
38 
39 class color
40 {
41 public:
42  void set_color(rgba_color_t const rgba);
44  void set_color(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha);
45  void set_color(int red, int green, int blue, int alpha);
47  void set_color(double red, double green, double blue, double alpha);
49  void get_hsl(color_component_t & hue, color_component_t & saturation, color_component_t & lightness, color_component_t & alpha) const;
50  void adjust_hue(float hue);
51  void adjust_saturation(float change);
52  void adjust_lightness(float change);
53  bool set_color(std::string const & name, bool name_only);
54  rgba_color_t get_color() const;
55  void get_color(color_component_t & red, color_component_t & green, color_component_t & blue, color_component_t & alpha) const;
56 
57  bool is_solid() const;
58  bool is_transparent() const;
59 
60  std::string to_string() const;
61 
62 private:
67 };
68 
69 } // namespace csspp
70 #endif
71 // #ifndef CSSPP_COLOR_H
72 
73 // Local Variables:
74 // mode: cpp
75 // indent-tabs-mode: nil
76 // c-basic-offset: 4
77 // tab-width: 4
78 // End:
79 
80 // vim: ts=4 sw=4 et
byte_component_t f_blue
Definition: color.h:34
void set_hsl(color_component_t h, color_component_t s, color_component_t l, color_component_t alpha)
Definition: color.cpp:343
std::string to_string() const
Definition: color.cpp:484
void set_color(rgba_color_t const rgba)
Definition: color.cpp:217
void adjust_saturation(float change)
color_component_t f_alpha
Definition: color.h:66
color_component_t f_green
Definition: color.h:64
void get_hsl(color_component_t &hue, color_component_t &saturation, color_component_t &lightness, color_component_t &alpha) const
Definition: color.cpp:404
byte_component_t f_green
Definition: color.h:33
float color_component_t
Definition: color.h:26
void adjust_lightness(float change)
uint32_t rgba_color_t
Definition: color.h:28
rgba_color_t get_color() const
Definition: color.cpp:456
byte_component_t f_alpha
Definition: color.h:35
uint8_t byte_component_t
Definition: color.h:27
bool is_transparent() const
Definition: color.cpp:479
byte_component_t f_red
Definition: color.h:32
void adjust_hue(float hue)
color_component_t f_red
Definition: color.h:63
color_component_t f_blue
Definition: color.h:65
bool is_solid() const
Definition: color.cpp:474
char const * f_name
Definition: color.h:36

Documentation of CSS Preprocessor.

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.