mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-04 02:36:31 +00:00
color implementation
This commit is contained in:
+1
-17
@@ -7,22 +7,6 @@ set(BIN_NAME "ray")
|
||||
project("${BIN_NAME}")
|
||||
include_directories("./include")
|
||||
|
||||
FIND_PACKAGE(raylib REQUIRED)
|
||||
TARGET_LINK_LIBRARIES(target_name raylib)
|
||||
|
||||
if (NOT raylib_FOUND)
|
||||
INCLUDE(FetchContent)
|
||||
FetchContent_Declare(raylib URL https://github.com/raysan5/raylib/archive/master.tar.gz)
|
||||
FetchContent_GetProperties(raylib)
|
||||
if (NOT raylib_POPULATED)
|
||||
SET(FETCHCONTENT_QUIET NO)
|
||||
FetchContent_Populate(raylib)
|
||||
SET(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||
ADD_SUBDIRECTORY(${raylib_SOURCE_DIR} ${raylib_BINARY_DIR})
|
||||
SET(raylib_FOUND TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(GCC_COVERAGE_COMPILE_FLAGS "-Wall -Wextra -Werror -Wshadow -lray")
|
||||
@@ -69,7 +53,7 @@ set(HEADERS
|
||||
)
|
||||
|
||||
set(SRC
|
||||
|
||||
src/Color.cpp
|
||||
)
|
||||
|
||||
add_library(${BIN_NAME} STATIC ${SRC} ${HEADERS})
|
||||
|
||||
@@ -38,7 +38,6 @@ namespace RAY
|
||||
//! @brief unload ressources
|
||||
bool unload();
|
||||
|
||||
|
||||
protected:
|
||||
private:
|
||||
//! @brief Font, really, that's just it...
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2021
|
||||
** Bomberman
|
||||
** File description:
|
||||
** Color
|
||||
*/
|
||||
|
||||
#include "Color.hpp"
|
||||
|
||||
RAY::Color::Color(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
|
||||
{
|
||||
this->setA(a);
|
||||
this->setB(b);
|
||||
this->setR(r);
|
||||
this->setG(g);
|
||||
}
|
||||
|
||||
RAY::Color::Color(const ::Color &color)
|
||||
{
|
||||
_color = color;
|
||||
}
|
||||
|
||||
RAY::Color::Color(int hexValue)
|
||||
{
|
||||
this->setR(hexValue & 0xff000000);
|
||||
this->setG(hexValue & 0xff0000);
|
||||
this->setB(hexValue & 0xff00);
|
||||
this->setA(hexValue & 0xff);
|
||||
}
|
||||
|
||||
RAY::Color &RAY::Color::setR(unsigned char r)
|
||||
{
|
||||
_color.r = r;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
RAY::Color &RAY::Color::setG(unsigned char g)
|
||||
{
|
||||
_color.g = g;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
RAY::Color &RAY::Color::setB(unsigned char b)
|
||||
{
|
||||
_color.b = b;
|
||||
return *this;
|
||||
}
|
||||
|
||||
RAY::Color &RAY::Color::setA(unsigned char a)
|
||||
{
|
||||
_color.a = a;
|
||||
return *this;
|
||||
}
|
||||
|
||||
unsigned char RAY::Color::getR(void) const
|
||||
{
|
||||
return _color.r;
|
||||
}
|
||||
|
||||
unsigned char RAY::Color::getG(void) const
|
||||
{
|
||||
return _color.g;
|
||||
}
|
||||
|
||||
unsigned char RAY::Color::getB(void) const
|
||||
{
|
||||
return _color.b;
|
||||
}
|
||||
|
||||
unsigned char RAY::Color::getA(void) const
|
||||
{
|
||||
return _color.a;
|
||||
}
|
||||
|
||||
const ::Color &RAY::Color::getColor(void) const
|
||||
{
|
||||
return _color;
|
||||
}
|
||||
|
||||
int RAY::Color::toHex(void) const
|
||||
{
|
||||
int c = 0;
|
||||
|
||||
c += _color.a;
|
||||
c += _color.b * 0xff;
|
||||
c += _color.g * 0xff * 0xff;
|
||||
c += _color.r * 0xff * 0xff * 0xff;
|
||||
return c;
|
||||
}
|
||||
Reference in New Issue
Block a user