Strip Unicode U+202B (right-to-left-embedding) code; it looks like DoM does RTL ...
[libsub.git] / src / colour.h
index 4989277400ca2c083b4470daa2d93535874edbe7..f3a4964819d72d1e38821cd66a79e75e7d0f3283 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
 
     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
 
 */
 
+/** @file  src/colour.h
+ *  @brief Colour class.
+ */
+
 #ifndef LIBSUB_COLOUR_H
 #define LIBSUB_COLOUR_H
 
+#include <dcp/types.h>
 #include <string>
+#include <cmath>
 
 namespace sub {
 
+/** @class Colour
+ *  @brief An RGB colour.
+ */
 class Colour
 {
 public:
@@ -32,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;
@@ -47,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