Commit CairoUtil class forgotten in commit 60ccdd.
This commit is contained in:
parent
fffb1b89da
commit
86c7003d6d
2 changed files with 154 additions and 0 deletions
81
src/gui/util/cairo-util.cpp
Normal file
81
src/gui/util/cairo-util.cpp
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
cairo-util.cpp - Defines utility functions for Cairo
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2010, Stefan Kangas <skangas@skangas.se>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
* *****************************************************/
|
||||
|
||||
#include "cairo-util.hpp"
|
||||
|
||||
namespace gui {
|
||||
namespace util {
|
||||
|
||||
RefPtr<SolidPattern>
|
||||
CairoUtil::pattern_set_red (const RefPtr<SolidPattern> color, double red)
|
||||
{
|
||||
double old_red;
|
||||
double blue;
|
||||
double green;
|
||||
double alpha;
|
||||
|
||||
color->get_rgba (old_red, blue, green, alpha);
|
||||
|
||||
return Cairo::SolidPattern::create_rgba (red, blue, green, alpha);
|
||||
}
|
||||
|
||||
RefPtr<SolidPattern>
|
||||
CairoUtil::pattern_set_green (const RefPtr<SolidPattern> color, double blue)
|
||||
{
|
||||
double red;
|
||||
double old_blue;
|
||||
double green;
|
||||
double alpha;
|
||||
|
||||
color->get_rgba (red, old_blue, green, alpha);
|
||||
|
||||
return Cairo::SolidPattern::create_rgba (red, blue, green, alpha);
|
||||
}
|
||||
|
||||
RefPtr<SolidPattern>
|
||||
CairoUtil::pattern_set_blue (const RefPtr<SolidPattern> color, double green)
|
||||
{
|
||||
double red;
|
||||
double blue;
|
||||
double old_green;
|
||||
double alpha;
|
||||
|
||||
color->get_rgba (red, blue, old_green, alpha);
|
||||
|
||||
return Cairo::SolidPattern::create_rgba (red, blue, green, alpha);
|
||||
}
|
||||
|
||||
RefPtr<SolidPattern>
|
||||
CairoUtil::pattern_set_alpha (const RefPtr<SolidPattern> color, double alpha)
|
||||
{
|
||||
double red;
|
||||
double blue;
|
||||
double green;
|
||||
double old_alpha;
|
||||
|
||||
color->get_rgba (red, blue, green, old_alpha);
|
||||
|
||||
return Cairo::SolidPattern::create_rgba (red, blue, green, alpha);
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace gui
|
||||
73
src/gui/util/cairo-util.hpp
Normal file
73
src/gui/util/cairo-util.hpp
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
cairo-util.hpp - Declares utility functions for Cairo
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2010, Stefan Kangas <skangas@skangas.se>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
* *****************************************************/
|
||||
|
||||
#include <cairomm/cairomm.h>
|
||||
|
||||
#ifndef UTIL_CAIRO_HPP
|
||||
#define UTIL_CAIRO_HPP
|
||||
|
||||
using Cairo::RefPtr;
|
||||
using Cairo::SolidPattern;
|
||||
|
||||
namespace gui {
|
||||
namespace util {
|
||||
|
||||
class CairoUtil
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Make a new SolidPattern from an old one, changing the red component of the color.
|
||||
* @param The new value for the red component of the color.
|
||||
* @return The new pattern.
|
||||
*/
|
||||
static RefPtr<SolidPattern>
|
||||
pattern_set_red (const RefPtr<SolidPattern> color, double red);
|
||||
|
||||
/**
|
||||
* Make a new SolidPattern from an old one, changing the green component of the color.
|
||||
* @param The new value for the green component of the color.
|
||||
* @return The new pattern.
|
||||
*/
|
||||
static RefPtr<SolidPattern>
|
||||
pattern_set_green (const RefPtr<SolidPattern>, double green);
|
||||
|
||||
/**
|
||||
* Make a new SolidPattern from an old one, changing the blue component of the color.
|
||||
* @param The new value for the blue component of the color.
|
||||
* @return The new pattern.
|
||||
*/
|
||||
static RefPtr<SolidPattern>
|
||||
pattern_set_blue (const RefPtr<SolidPattern>, double blue);
|
||||
|
||||
/**
|
||||
* Make a new SolidPattern from an old one, changing the alpha component of the color.
|
||||
* @param The new value for the alpha component of the color.
|
||||
* @return The new pattern.
|
||||
*/
|
||||
static RefPtr<SolidPattern>
|
||||
pattern_set_alpha (const RefPtr<SolidPattern>, double alpha);
|
||||
};
|
||||
|
||||
} // namespace util
|
||||
} // namespace gui
|
||||
|
||||
#endif
|
||||
Loading…
Reference in a new issue