Current Version: 1.0.33
Project Name: csspp
color.h
Go to the documentation of this file.
1// Copyright (c) 2015-2025 Made to Order Software Corp. All Rights Reserved
2//
3// This program is free software; you can redistribute it and/or modify
4// it under the terms of the GNU General Public License as published by
5// the Free Software Foundation; either version 2 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License along
14// with this program; if not, write to the Free Software Foundation, Inc.,
15// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16#pragma once
17
18// C++
19//
20#include <cstdint>
21#include <string>
22
23
24namespace csspp
25{
26
27typedef float color_component_t;
28typedef uint8_t byte_component_t;
29typedef uint32_t rgba_color_t;
30
39
40class color
41{
42public:
43 void set_color(rgba_color_t const rgba);
45 void set_color(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha);
46 void set_color(int red, int green, int blue, int alpha);
48 void set_color(double red, double green, double blue, double alpha);
50 void get_hsl(color_component_t & hue, color_component_t & saturation, color_component_t & lightness, color_component_t & alpha) const;
51 void adjust_hue(float hue);
52 void adjust_saturation(float change);
53 void adjust_lightness(float change);
54 bool set_color(std::string const & name, bool name_only);
55 rgba_color_t get_color() const;
56 void get_color(color_component_t & red, color_component_t & green, color_component_t & blue, color_component_t & alpha) const;
57
58 bool is_solid() const;
59 bool is_transparent() const;
60
61 std::string to_string() const;
62
63private:
68};
69
70} // namespace csspp
71// vim: ts=4 sw=4 et
void adjust_saturation(float change)
void adjust_lightness(float change)
rgba_color_t get_color() const
Definition color.cpp:467
color_component_t f_blue
Definition color.h:66
bool is_solid() const
Definition color.cpp:485
void set_color(rgba_color_t const rgba)
Definition color.cpp:228
void adjust_hue(float hue)
color_component_t f_alpha
Definition color.h:67
std::string to_string() const
Definition color.cpp:495
void set_hsl(color_component_t h, color_component_t s, color_component_t l, color_component_t alpha)
Definition color.cpp:354
bool is_transparent() const
Definition color.cpp:490
void get_hsl(color_component_t &hue, color_component_t &saturation, color_component_t &lightness, color_component_t &alpha) const
Definition color.cpp:415
color_component_t f_red
Definition color.h:64
color_component_t f_green
Definition color.h:65
The namespace of all the classes in the CSS Preprocessor.
Definition csspp.h:48
uint32_t rgba_color_t
Definition color.h:29
uint8_t byte_component_t
Definition color.h:28
float color_component_t
Definition color.h:27
byte_component_t f_alpha
Definition color.h:36
byte_component_t f_blue
Definition color.h:35
byte_component_t f_green
Definition color.h:34
byte_component_t f_red
Definition color.h:33
char const * f_name
Definition color.h:37

Documentation of CSS Preprocessor.

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.