##

Color.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef _GAZEBO_COLOR_HH_
#define _GAZEBO_COLOR_HH_
#include <iostream>
#include <ignition/math/Color.hh>
#include <ignition/math/Vector3.hh>
#include "gazebo/common/CommonTypes.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace common
{
class GZ_COMMON_VISIBLE Color
{
public: static const Color White;
public: static const Color Black;
public: static const Color Red;
public: static const Color Green;
public: static const Color Blue;
public: static const Color Yellow;
public: static const Color Magenta;
public: typedef unsigned int RGBA;
public: typedef unsigned int BGRA;
public: typedef unsigned int ARGB;
public: typedef unsigned int ABGR;
public: Color() GAZEBO_DEPRECATED(9.0);
public: Color(float _r, float _g, float _b, float _a = 1.0)
GAZEBO_DEPRECATED(9.0);
// cppcheck-suppress noExplicitConstructor
public: Color(const ignition::math::Color &_color) GAZEBO_DEPRECATED(9.0);
public: Color &operator=(const ignition::math::Color &_color)
GAZEBO_DEPRECATED(9.0);
public: ignition::math::Color Ign() const;
public: Color(const Color &_clr) GAZEBO_DEPRECATED(9.0);
public: virtual ~Color() GAZEBO_DEPRECATED(9.0);
public: void Reset();
public: void Set(float _r = 1, float _g = 1 , float _b = 1, float _a = 1);
public: ignition::math::Vector3d HSV() const;
public: void SetFromHSV(float _h, float _s, float _v);
public: ignition::math::Vector3d YUV() const;
public: void SetFromYUV(float _y, float _u, float _v);
public: Color &operator =(const Color &_pt) GAZEBO_DEPRECATED(9.0);
public: float operator[](unsigned int _index);
public: RGBA GetAsRGBA() const;
public: BGRA GetAsBGRA() const;
public: ARGB GetAsARGB() const;
public: ABGR GetAsABGR() const;
public: void SetFromRGBA(const RGBA _v);
public: void SetFromBGRA(const BGRA _v);
public: void SetFromARGB(const ARGB _v);
public: void SetFromABGR(const ABGR _v);
public: Color operator+(const Color &_pt) const;
public: Color operator+(const float &_v) const;
public: const Color &operator+=(const Color &_pt);
public: Color operator-(const Color &_pt) const;
public: Color operator-(const float &_v) const;
public: const Color &operator-=(const Color &_pt);
public: const Color operator/(const Color &_pt) const;
public: const Color operator/(const float &_v) const;
public: const Color &operator/=(const Color &_pt);
public: const Color operator*(const Color &_pt) const;
public: const Color operator*(const float &_v) const;
public: const Color &operator*=(const Color &_pt);
public: bool operator ==(const Color &_pt) const;
public: bool operator!=(const Color &_pt) const;
private: void Clamp();
public: friend std::ostream &operator<< (std::ostream &_out,
const Color &_pt)
{
_out << _pt.r << " " << _pt.g << " " << _pt.b << " " << _pt.a;
return _out;
}
public: friend std::istream &operator>> (std::istream &_in, Color &_pt)
{
// Skip white spaces
_in.setf(std::ios_base::skipws);
_in >> _pt.r >> _pt.g >> _pt.b >> _pt.a;
return _in;
}
// The values
public: float r, g, b, a;
};
}
}
#endif
ignition
Definition: Model.hh:40
gazebo::common::Color::Reset
void Reset()
Reset the color to default values.
gazebo::common::Color::SetFromBGRA
void SetFromBGRA(const BGRA _v)
Set from uint32 BGRA packed value.
gazebo::common::Color::SetFromYUV
void SetFromYUV(float _y, float _u, float _v)
Set from yuv.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::common::Color::Yellow
static const Color Yellow
(1, 1, 0)
Definition: Color.hh:49
gazebo::common::Color::Set
void Set(float _r=1, float _g=1, float _b=1, float _a=1)
Set the contents of the vector.
common
common
Definition: FuelModelDatabase.hh:37
gazebo::common::Color::ABGR
unsigned int ABGR
Definition: Color.hh:67
gazebo::common::Color::YUV
ignition::math::Vector3d YUV() const
Get the color in YUV colorspace.
gazebo::common::Color::r
float r
Definition: Color.hh:268
gazebo::common::Color::ARGB
unsigned int ARGB
Definition: Color.hh:63
system.hh
gazebo::common::Color::GetAsARGB
ARGB GetAsARGB() const
Get as uint32 ARGB packed value.
CommonTypes.hh
gazebo::common::Color::Green
static const Color Green
(0, 1, 0)
Definition: Color.hh:45
gazebo::common::Color::White
static const Color White
(1, 1, 1)
Definition: Color.hh:39
gazebo::common::Color::b
float b
Definition: Color.hh:268
gazebo::common::Color::SetFromABGR
void SetFromABGR(const ABGR _v)
Set from uint32 ABGR packed value.
gazebo::common::Color::Ign
ignition::math::Color Ign() const
Convert to ignition type.
gazebo::common::Color::HSV
ignition::math::Vector3d HSV() const
Get the color in HSV colorspace.
gazebo::common::Color::Red
static const Color Red
(1, 0, 0)
Definition: Color.hh:43
gazebo::common::Color::RGBA
unsigned int RGBA
Definition: Color.hh:55
gazebo::common::Color::SetFromRGBA
void SetFromRGBA(const RGBA _v)
Set from uint32 RGBA packed value.
gazebo::msgs::Set
GAZEBO_VISIBLE void Set(common::Image &_img, const msgs::Image &_msg)
Convert a msgs::Image to a common::Image.
gazebo::common::Color::BGRA
unsigned int BGRA
Definition: Color.hh:59
gazebo::common::Color::GetAsBGRA
BGRA GetAsBGRA() const
Get as uint32 BGRA packed value.
gazebo::common::Color::Black
static const Color Black
(0, 0, 0)
Definition: Color.hh:41
gazebo::common::Color
Defines a color.
Definition: Color.hh:36
GAZEBO_DEPRECATED
#define GAZEBO_DEPRECATED(version)
Definition: system.hh:328
gazebo::common::Color::Blue
static const Color Blue
(0, 0, 1)
Definition: Color.hh:47
gazebo::common::Color::GetAsABGR
ABGR GetAsABGR() const
Get as uint32 ABGR packed value.
gazebo::common::Color::GetAsRGBA
RGBA GetAsRGBA() const
Get as uint32 RGBA packed value.
gazebo::common::Color::Magenta
static const Color Magenta
(1, 0, 1)
Definition: Color.hh:51
gazebo::common::Color::SetFromARGB
void SetFromARGB(const ARGB _v)
Set from uint32 ARGB packed value.
gazebo::common::Color::SetFromHSV
void SetFromHSV(float _h, float _s, float _v)
Set a color based on HSV values.
gazebo::common::Color::a
float a
Definition: Color.hh:268
gazebo::common::Color::Color
Color() GAZEBO_DEPRECATED(9.0)
Constructor.
gazebo::common::Color::g
float g
Definition: Color.hh:268
gazebo::common::Color::operator>>
friend std::istream & operator>>(std::istream &_in, Color &_pt)
Stream insertion operator.
Definition: Color.hh:259