3 Copyright 2007 Antoine Chavasse <a.chavasse@gmail.com>
5 This file is part of Fail.
7 Fail is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 3
9 as published by the Free Software Foundation.
11 Fail 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.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef FAIL_MATH_VECTOR4U8_H_
20 #define FAIL_MATH_VECTOR4U8_H_
22 #include "core/core.h"
24 namespace fail
{ namespace math
36 Vector4u8( uint8_t r
, uint8_t g
, uint8_t b
, uint8_t a
= 255 ) :
44 uint8_t& r() { return m_r
; }
45 uint8_t& g() { return m_g
; }
46 uint8_t& b() { return m_b
; }
47 uint8_t& a() { return m_a
; }
48 const uint8_t& r() const { return m_r
; }
49 const uint8_t& g() const { return m_g
; }
50 const uint8_t& b() const { return m_b
; }
51 const uint8_t& a() const { return m_a
; }
53 Vector4u8
operator+( const Vector4u8
& b
) const
55 return Vector4u8( m_r
+ b
.m_r
,
61 Vector4u8
operator-( const Vector4u8
& b
) const
63 return Vector4u8( m_r
- b
.m_r
,
69 const Vector4u8
& operator+=( const Vector4u8
& b
)
78 const Vector4u8
& operator-=( const Vector4u8
& b
)
87 bool operator==( const Vector4u8
& b
) const
89 return m_r
== b
.m_r
&&
95 bool operator!=( const Vector4u8
& b
) const
97 return m_r
!= b
.m_r
||
103 bool operator<( const Vector4u8
& b_
) const
105 uint32_t a
= ( m_r
<< 24 ) | ( m_g
<< 16 ) | ( m_b
<< 8 ) | m_a
;
106 uint32_t b
= ( b_
.m_r
<< 24 ) | ( b_
.m_g
<< 16 ) | ( b_
.m_b
<< 8 ) | b_
.m_a
;