* Removed unused MakeBlendColor().
* At least 15 bit mode is broken, and should probably be removed. * Cleanup - do we really need this class? git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16247 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,45 +1,18 @@
|
|||||||
//------------------------------------------------------------------------------
|
/*
|
||||||
// Copyright (c) 2001-2002, Haiku, Inc.
|
* Copyright 2001-2006, Haiku.
|
||||||
//
|
* Distributed under the terms of the MIT License.
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
*
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
* Authors:
|
||||||
// to deal in the Software without restriction, including without limitation
|
* DarkWyrm <[email protected]>
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
*/
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
#ifndef RGB_COLOR_H
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
#define RGB_COLOR_H
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in
|
|
||||||
// all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
//
|
|
||||||
// File Name: RGBColor.h
|
|
||||||
// Author: DarkWyrm <[email protected]>
|
|
||||||
// Description: Color encapsulation class for the app_server
|
|
||||||
//
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
#ifndef RGBCOLOR_H_
|
|
||||||
#define RGBCOLOR_H_
|
|
||||||
|
|
||||||
#include <GraphicsDefs.h>
|
#include <GraphicsDefs.h>
|
||||||
|
|
||||||
/*!
|
|
||||||
\class RGBColor RGBColor.h
|
|
||||||
\brief A color class to encapsulate color space ugliness in the app_server
|
|
||||||
|
|
||||||
RGBColors can be used to perform tasks much more difficult using rgb_colors. This
|
class RGBColor {
|
||||||
class is limited to the app_server because of the access to the system palette for
|
|
||||||
looking up the 32-bit value to each color index.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class RGBColor
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
RGBColor(uint8 r, uint8 g, uint8 b, uint8 a=255);
|
RGBColor(uint8 r, uint8 g, uint8 b, uint8 a=255);
|
||||||
RGBColor(int r, int g, int b, int a=255);
|
RGBColor(int r, int g, int b, int a=255);
|
||||||
@@ -49,8 +22,6 @@ public:
|
|||||||
RGBColor(const RGBColor &col);
|
RGBColor(const RGBColor &col);
|
||||||
RGBColor();
|
RGBColor();
|
||||||
|
|
||||||
void PrintToStream() const;
|
|
||||||
|
|
||||||
uint8 GetColor8() const;
|
uint8 GetColor8() const;
|
||||||
uint16 GetColor15() const;
|
uint16 GetColor15() const;
|
||||||
uint16 GetColor16() const;
|
uint16 GetColor16() const;
|
||||||
@@ -63,8 +34,6 @@ public:
|
|||||||
void SetColor(const rgb_color &color);
|
void SetColor(const rgb_color &color);
|
||||||
void SetColor(const RGBColor &col);
|
void SetColor(const RGBColor &col);
|
||||||
|
|
||||||
RGBColor MakeBlendColor(const RGBColor &color, const float &position);
|
|
||||||
|
|
||||||
const RGBColor & operator=(const RGBColor &col);
|
const RGBColor & operator=(const RGBColor &col);
|
||||||
const RGBColor & operator=(const rgb_color &col);
|
const RGBColor & operator=(const rgb_color &col);
|
||||||
bool operator==(const rgb_color &col) const;
|
bool operator==(const rgb_color &col) const;
|
||||||
@@ -72,16 +41,18 @@ public:
|
|||||||
|
|
||||||
bool IsTransparentMagic() const;
|
bool IsTransparentMagic() const;
|
||||||
|
|
||||||
|
void PrintToStream() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
rgb_color color32;
|
rgb_color fColor32;
|
||||||
|
|
||||||
// caching
|
// caching
|
||||||
mutable uint16 color16;
|
mutable uint16 fColor16;
|
||||||
mutable uint16 color15;
|
mutable uint16 fColor15;
|
||||||
mutable uint8 color8;
|
mutable uint8 fColor8;
|
||||||
mutable bool update8;
|
mutable bool fUpdate8;
|
||||||
mutable bool update15;
|
mutable bool fUpdate15;
|
||||||
mutable bool update16;
|
mutable bool fUpdate16;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // RGB_COLOR_H
|
||||||
|
|||||||
+133
-178
@@ -1,38 +1,20 @@
|
|||||||
//------------------------------------------------------------------------------
|
/*
|
||||||
// Copyright (c) 2001-2002, Haiku, Inc.
|
* Copyright 2001-2006, Haiku.
|
||||||
//
|
* Distributed under the terms of the MIT License.
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
*
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
* Authors:
|
||||||
// to deal in the Software without restriction, including without limitation
|
* DarkWyrm <[email protected]>
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
*/
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in
|
|
||||||
// all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
//
|
|
||||||
// File Name: RGBColor.cpp
|
|
||||||
// Author: DarkWyrm <[email protected]>
|
|
||||||
// Description: Color encapsulation class for the app_server
|
|
||||||
//
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Standard Includes -----------------------------------------------------------
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
// Local Includes --------------------------------------------------------------
|
|
||||||
#include "RGBColor.h"
|
#include "RGBColor.h"
|
||||||
#include "SystemPalette.h"
|
#include "SystemPalette.h"
|
||||||
|
|
||||||
#include <ColorUtils.h>
|
#include <ColorUtils.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Create an RGBColor from specified values
|
\brief Create an RGBColor from specified values
|
||||||
\param red red
|
\param red red
|
||||||
@@ -45,6 +27,7 @@ RGBColor::RGBColor(uint8 r, uint8 g, uint8 b, uint8 a)
|
|||||||
SetColor(r,g,b,a);
|
SetColor(r,g,b,a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Create an RGBColor from specified values
|
\brief Create an RGBColor from specified values
|
||||||
\param red red
|
\param red red
|
||||||
@@ -57,109 +40,119 @@ RGBColor::RGBColor(int r, int g, int b, int a)
|
|||||||
SetColor(r, g, b, a);
|
SetColor(r, g, b, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Create an RGBColor from an rgb_color
|
\brief Create an RGBColor from an rgb_color
|
||||||
\param col color to initialize from
|
\param color color to initialize from
|
||||||
*/
|
*/
|
||||||
RGBColor::RGBColor(const rgb_color &col)
|
RGBColor::RGBColor(const rgb_color &color)
|
||||||
{
|
{
|
||||||
SetColor(col);
|
SetColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Create an RGBColor from a 16-bit RGBA color
|
\brief Create an RGBColor from a 16-bit RGBA color
|
||||||
\param col color to initialize from
|
\param color color to initialize from
|
||||||
*/
|
*/
|
||||||
RGBColor::RGBColor(uint16 col)
|
RGBColor::RGBColor(uint16 color)
|
||||||
{
|
{
|
||||||
SetColor(col);
|
SetColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Create an RGBColor from an index color
|
\brief Create an RGBColor from an index color
|
||||||
\param col color to initialize from
|
\param color color to initialize from
|
||||||
*/
|
*/
|
||||||
RGBColor::RGBColor(uint8 col)
|
RGBColor::RGBColor(uint8 color)
|
||||||
{
|
{
|
||||||
SetColor(col);
|
SetColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Copy Contructor
|
\brief Copy Contructor
|
||||||
\param col color to initialize from
|
\param color color to initialize from
|
||||||
*/
|
*/
|
||||||
RGBColor::RGBColor(const RGBColor &col)
|
RGBColor::RGBColor(const RGBColor &color)
|
||||||
{
|
{
|
||||||
color32=col.color32;
|
fColor32 = color.fColor32;
|
||||||
color16=col.color16;
|
fColor16 = color.fColor16;
|
||||||
color8=col.color8;
|
fColor8 = color.fColor8;
|
||||||
update8=col.update8;
|
fUpdate8 = color.fUpdate8;
|
||||||
update16=col.update16;
|
fUpdate16 = color.fUpdate16;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Create an RGBColor with the values(0,0,0,0)
|
\brief Create an RGBColor with the values(0,0,0,0)
|
||||||
*/
|
*/
|
||||||
RGBColor::RGBColor()
|
RGBColor::RGBColor()
|
||||||
{
|
{
|
||||||
SetColor(0, 0, 0, 0);
|
SetColor(0, 0, 0, 0);
|
||||||
update8=update16=false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Returns the color as the closest 8-bit color in the palette
|
\brief Returns the color as the closest 8-bit color in the palette
|
||||||
\return The palette index for the current color
|
\return The palette index for the current color
|
||||||
*/
|
*/
|
||||||
uint8 RGBColor::GetColor8() const
|
uint8
|
||||||
|
RGBColor::GetColor8() const
|
||||||
{
|
{
|
||||||
if(update8)
|
if (fUpdate8) {
|
||||||
{
|
fColor8 = FindClosestColor(SystemPalette(), fColor32);
|
||||||
color8=FindClosestColor(SystemPalette(), color32);
|
fUpdate8 = false;
|
||||||
update8=false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return color8;
|
return fColor8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Returns the color as the closest 15-bit color
|
\brief Returns the color as the closest 15-bit color
|
||||||
\return 15-bit value of the current color plus 1-bit alpha
|
\return 15-bit value of the current color plus 1-bit alpha
|
||||||
*/
|
*/
|
||||||
uint16 RGBColor::GetColor15() const
|
uint16
|
||||||
|
RGBColor::GetColor15() const
|
||||||
{
|
{
|
||||||
if(update15)
|
if (fUpdate15) {
|
||||||
{
|
fColor15 = FindClosestColor15(fColor32);
|
||||||
color15=FindClosestColor15(color32);
|
fUpdate15 = false;
|
||||||
update15=false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return color15;
|
return fColor15;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Returns the color as the closest 16-bit color
|
\brief Returns the color as the closest 16-bit color
|
||||||
\return 16-bit value of the current color
|
\return 16-bit value of the current color
|
||||||
*/
|
*/
|
||||||
uint16 RGBColor::GetColor16() const
|
uint16
|
||||||
|
RGBColor::GetColor16() const
|
||||||
{
|
{
|
||||||
if(update16)
|
if (fUpdate16) {
|
||||||
{
|
fColor16 = FindClosestColor16(fColor32);
|
||||||
color16=FindClosestColor16(color32);
|
fUpdate16 = false;
|
||||||
update16=false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return color16;
|
return fColor16;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Returns the color as a 32-bit color
|
\brief Returns the color as a 32-bit color
|
||||||
\return current color, including alpha
|
\return current color, including alpha
|
||||||
*/
|
*/
|
||||||
rgb_color RGBColor::GetColor32() const
|
rgb_color
|
||||||
|
RGBColor::GetColor32() const
|
||||||
{
|
{
|
||||||
return color32;
|
return fColor32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Set the object to specified values
|
\brief Set the object to specified values
|
||||||
\param red red
|
\param red red
|
||||||
@@ -167,16 +160,18 @@ rgb_color RGBColor::GetColor32() const
|
|||||||
\param blue blue
|
\param blue blue
|
||||||
\param alpha alpha, defaults to 255
|
\param alpha alpha, defaults to 255
|
||||||
*/
|
*/
|
||||||
void RGBColor::SetColor(uint8 r, uint8 g, uint8 b, uint8 a)
|
void
|
||||||
|
RGBColor::SetColor(uint8 r, uint8 g, uint8 b, uint8 a)
|
||||||
{
|
{
|
||||||
color32.red=r;
|
fColor32.red = r;
|
||||||
color32.green=g;
|
fColor32.green = g;
|
||||||
color32.blue=b;
|
fColor32.blue = b;
|
||||||
color32.alpha=a;
|
fColor32.alpha = a;
|
||||||
|
|
||||||
update8=update16=true;
|
fUpdate8 = fUpdate16 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Set the object to specified values
|
\brief Set the object to specified values
|
||||||
\param red red
|
\param red red
|
||||||
@@ -184,185 +179,145 @@ void RGBColor::SetColor(uint8 r, uint8 g, uint8 b, uint8 a)
|
|||||||
\param blue blue
|
\param blue blue
|
||||||
\param alpha alpha, defaults to 255
|
\param alpha alpha, defaults to 255
|
||||||
*/
|
*/
|
||||||
void RGBColor::SetColor(int r, int g, int b, int a)
|
void
|
||||||
|
RGBColor::SetColor(int r, int g, int b, int a)
|
||||||
{
|
{
|
||||||
color32.red=(uint8)r;
|
fColor32.red = (uint8)r;
|
||||||
color32.green=(uint8)g;
|
fColor32.green = (uint8)g;
|
||||||
color32.blue=(uint8)b;
|
fColor32.blue = (uint8)b;
|
||||||
color32.alpha=(uint8)a;
|
fColor32.alpha = (uint8)a;
|
||||||
|
|
||||||
update8=update16=true;
|
fUpdate8 = fUpdate16 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Set the object to specified value
|
\brief Set the object to specified value
|
||||||
\param col16 color to copy
|
\param col16 color to copy
|
||||||
*/
|
*/
|
||||||
void RGBColor::SetColor(uint16 col16)
|
void
|
||||||
|
RGBColor::SetColor(uint16 col16)
|
||||||
{
|
{
|
||||||
color16=col16;
|
fColor16 = col16;
|
||||||
SetRGBColor(&color32,col16);
|
SetRGBColor(&fColor32,col16);
|
||||||
|
|
||||||
update8=true;
|
fUpdate8 = true;
|
||||||
update16=false;
|
fUpdate16 = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Set the object to specified index in the palette
|
\brief Set the object to specified index in the palette
|
||||||
\param col8 color to copy
|
\param col8 color to copy
|
||||||
*/
|
*/
|
||||||
void RGBColor::SetColor(uint8 col8)
|
void
|
||||||
|
RGBColor::SetColor(uint8 col8)
|
||||||
{
|
{
|
||||||
color8=col8;
|
fColor8 = col8;
|
||||||
color32=SystemPalette()[col8];
|
fColor32 = SystemPalette()[col8];
|
||||||
|
|
||||||
update8=false;
|
fUpdate8 = false;
|
||||||
update16=true;
|
fUpdate16 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Set the object to specified color
|
\brief Set the object to specified color
|
||||||
\param color color to copy
|
\param color color to copy
|
||||||
*/
|
*/
|
||||||
void RGBColor::SetColor(const rgb_color &color)
|
void
|
||||||
|
RGBColor::SetColor(const rgb_color &color)
|
||||||
{
|
{
|
||||||
color32=color;
|
fColor32 = color;
|
||||||
update8=update16=true;
|
fUpdate8 = fUpdate16 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Set the object to specified color
|
\brief Set the object to specified color
|
||||||
\param col color to copy
|
\param color color to copy
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
RGBColor::SetColor(const RGBColor &col)
|
RGBColor::SetColor(const RGBColor &color)
|
||||||
{
|
{
|
||||||
color32 = col.color32;
|
fColor32 = color.fColor32;
|
||||||
color16 = col.color16;
|
fColor16 = color.fColor16;
|
||||||
color8 = col.color8;
|
fColor8 = color.fColor8;
|
||||||
update8 = col.update8;
|
fUpdate8 = color.fUpdate8;
|
||||||
update16 = col.update16;
|
fUpdate16 = color.fUpdate16;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Set the object to specified color
|
\brief Set the object to specified color
|
||||||
\param col color to copy
|
\param color color to copy
|
||||||
*/
|
*/
|
||||||
const RGBColor&
|
const RGBColor&
|
||||||
RGBColor::operator=(const RGBColor &col)
|
RGBColor::operator=(const RGBColor &color)
|
||||||
{
|
{
|
||||||
color32 = col.color32;
|
fColor32 = color.fColor32;
|
||||||
color16 = col.color16;
|
fColor16 = color.fColor16;
|
||||||
color8 = col.color8;
|
fColor8 = color.fColor8;
|
||||||
update8 = col.update8;
|
fUpdate8 = color.fUpdate8;
|
||||||
update16 = col.update16;
|
fUpdate16 = color.fUpdate16;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Set the object to specified color
|
\brief Set the object to specified color
|
||||||
\param col color to copy
|
\param color color to copy
|
||||||
*/
|
*/
|
||||||
const RGBColor&
|
const RGBColor&
|
||||||
RGBColor::operator=(const rgb_color &col)
|
RGBColor::operator=(const rgb_color &color)
|
||||||
{
|
{
|
||||||
color32 = col;
|
fColor32 = color;
|
||||||
update8 = update16 = true;
|
fUpdate8 = fUpdate16 = true;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Returns a color blended between the object's value and
|
|
||||||
another color.
|
|
||||||
|
|
||||||
\param color The other color to be blended with.
|
|
||||||
\param position A weighted percentage of the second color to use. 0 <= value <= 1.0
|
|
||||||
\return The blended color
|
|
||||||
|
|
||||||
If the position passed to this function is invalid, the starting
|
|
||||||
color will be returned.
|
|
||||||
*/
|
|
||||||
RGBColor RGBColor::MakeBlendColor(const RGBColor &color, const float &position)
|
|
||||||
{
|
|
||||||
rgb_color col=color32;
|
|
||||||
rgb_color col2=color.color32;
|
|
||||||
|
|
||||||
rgb_color newcol={0,0,0,0};
|
|
||||||
float mod=0;
|
|
||||||
int16 delta;
|
|
||||||
if(position<0 || position>1)
|
|
||||||
return *this;
|
|
||||||
|
|
||||||
delta=int16(col2.red)-int16(col.red);
|
|
||||||
mod=col.red + (position * delta);
|
|
||||||
newcol.red=uint8(mod);
|
|
||||||
if(mod>255 )
|
|
||||||
newcol.red=255;
|
|
||||||
if(mod<0 )
|
|
||||||
newcol.red=0;
|
|
||||||
|
|
||||||
delta=int16(col2.green)-int16(col.green);
|
|
||||||
mod=col.green + (position * delta);
|
|
||||||
newcol.green=uint8(mod);
|
|
||||||
if(mod>255 )
|
|
||||||
newcol.green=255;
|
|
||||||
if(mod<0 )
|
|
||||||
newcol.green=0;
|
|
||||||
|
|
||||||
delta=int16(col2.blue)-int16(col.blue);
|
|
||||||
mod=col.blue + (position * delta);
|
|
||||||
newcol.blue=uint8(mod);
|
|
||||||
if(mod>255 )
|
|
||||||
newcol.blue=255;
|
|
||||||
if(mod<0 )
|
|
||||||
newcol.blue=0;
|
|
||||||
|
|
||||||
delta=int8(col2.alpha)-int8(col.alpha);
|
|
||||||
mod=col.alpha + (position * delta);
|
|
||||||
newcol.alpha=uint8(mod);
|
|
||||||
if(mod>255 )
|
|
||||||
newcol.alpha=255;
|
|
||||||
if(mod<0 )
|
|
||||||
newcol.alpha=0;
|
|
||||||
|
|
||||||
return RGBColor(newcol);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Prints the 32-bit values of the color to standard out
|
\brief Prints the 32-bit values of the color to standard out
|
||||||
*/
|
*/
|
||||||
void RGBColor::PrintToStream(void) const
|
void
|
||||||
|
RGBColor::PrintToStream(void) const
|
||||||
{
|
{
|
||||||
printf("RGBColor (%u,%u,%u,%u)\n", color32.red,color32.green,color32.blue,color32.alpha);
|
printf("RGBColor(%u,%u,%u,%u)\n",
|
||||||
|
fColor32.red, fColor32.green, fColor32.blue, fColor32.alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Overloaded comaparison
|
\brief Overloaded comaparison
|
||||||
\return true if all color elements are exactly equal
|
\return true if all color elements are exactly equal
|
||||||
*/
|
*/
|
||||||
bool RGBColor::operator==(const rgb_color &col) const
|
bool
|
||||||
|
RGBColor::operator==(const rgb_color &color) const
|
||||||
{
|
{
|
||||||
return color32.red == col.red &&
|
return fColor32.red == color.red
|
||||||
color32.green == col.green &&
|
&& fColor32.green == color.green
|
||||||
color32.blue == col.blue &&
|
&& fColor32.blue == color.blue
|
||||||
color32.alpha == col.alpha;
|
&& fColor32.alpha == color.alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Overloaded comaparison
|
\brief Overloaded comaparison
|
||||||
\return true if all color elements are exactly equal
|
\return true if all color elements are exactly equal
|
||||||
*/
|
*/
|
||||||
bool RGBColor::operator==(const RGBColor &col) const
|
bool
|
||||||
|
RGBColor::operator==(const RGBColor &color) const
|
||||||
{
|
{
|
||||||
return color32.red == col.color32.red &&
|
return fColor32.red == color.fColor32.red
|
||||||
color32.green == col.color32.green &&
|
&& fColor32.green == color.fColor32.green
|
||||||
color32.blue == col.color32.blue &&
|
&& fColor32.blue == color.fColor32.blue
|
||||||
color32.alpha == col.color32.alpha;
|
&& fColor32.alpha == color.fColor32.alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsTransparentMagic
|
|
||||||
bool
|
bool
|
||||||
RGBColor::IsTransparentMagic() const
|
RGBColor::IsTransparentMagic() const
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user