X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fcolour.h;h=f3a4964819d72d1e38821cd66a79e75e7d0f3283;hb=207ed52da31616de2d80c5ff0c65182a6f92acf2;hp=673bb9f84e3be0379a23c4f22aff4bd6838d233d;hpb=d6b067d2a2ec5f0490c9fb17ddd605d0e860480d;p=libsub.git diff --git a/src/colour.h b/src/colour.h index 673bb9f..f3a4964 100644 --- a/src/colour.h +++ b/src/colour.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2018 Carl Hetherington 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 @@ -17,10 +17,16 @@ */ +/** @file src/colour.h + * @brief Colour class. + */ + #ifndef LIBSUB_COLOUR_H #define LIBSUB_COLOUR_H +#include #include +#include namespace sub { @@ -35,14 +41,15 @@ public: , g (0) , b (0) {} - + Colour (float r, float g, float b) : r (r) , g (g) , b (b) {} - Colour (std::string); + static Colour from_argb_hex (std::string); + static Colour from_rgb_hex (std::string); /** red component (from 0 to 1) */ float r; @@ -50,11 +57,15 @@ public: float g; /** blue component (from 0 to 1) */ float b; + + dcp::Colour dcp() const { + return dcp::Colour(lrintf(r * 255), lrintf(g * 255), lrintf(b * 255)); + } }; bool operator== (Colour const & a, Colour const & b); - + } #endif