21Color::Color(
unsigned char Red,
unsigned char Green,
unsigned char Blue,
unsigned char Alpha) :
22 red(static_cast<double>(Red)),
23 green(static_cast<double>(Green)),
24 blue(static_cast<double>(Blue)),
25 alpha(static_cast<double>(Alpha)) { }
41 :
Color::
Color(QString::fromStdString(color_hex)) {}
49 int r =
red.GetInt(frame_number);
50 int g =
green.GetInt(frame_number);
51 int b =
blue.GetInt(frame_number);
52 int a =
alpha.GetInt(frame_number);
54 return QColor( r,g,b,a ).name().toStdString();
59 std::vector<int> rgba;
60 rgba.push_back(
red.GetInt(frame_number));
61 rgba.push_back(
green.GetInt(frame_number));
62 rgba.push_back(
blue.GetInt(frame_number));
63 rgba.push_back(
alpha.GetInt(frame_number));
71 long rmean = ( R1 + R2 ) / 2;
75 return sqrt((((512+rmean)*r*r)>>8) + 4*g*g + (((767-rmean)*b*b)>>8));
90 root[
"red"] =
red.JsonValue();
91 root[
"green"] =
green.JsonValue();
92 root[
"blue"] =
blue.JsonValue();
93 root[
"alpha"] =
alpha.JsonValue();
109 catch (
const std::exception& e)
112 throw InvalidJSON(
"JSON is invalid (missing keys or invalid data types)");
120 if (!root[
"red"].isNull())
121 red.SetJsonValue(root[
"red"]);
122 if (!root[
"green"].isNull())
123 green.SetJsonValue(root[
"green"]);
124 if (!root[
"blue"].isNull())
125 blue.SetJsonValue(root[
"blue"]);
126 if (!root[
"alpha"].isNull())
127 alpha.SetJsonValue(root[
"alpha"]);
Header file for Color class.
Header file for all Exception classes.
std::string Json() const
Generate JSON string of this object.
std::string GetColorHex(int64_t frame_number)
Get the HEX value of a color at a specific frame.
openshot::Keyframe blue
Curve representing the red value (0 - 255).
openshot::Keyframe red
Curve representing the red value (0 - 255).
openshot::Keyframe green
Curve representing the green value (0 - 255).
Color()
Default constructor.
void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
openshot::Keyframe alpha
Curve representing the alpha value (0 - 255).
static long GetDistance(long R1, long G1, long B1, long R2, long G2, long B2)
Get the distance between 2 RGB pairs. (0=identical colors, 10=very close colors, 760=very different c...
std::vector< int > GetColorRGBA(int64_t frame_number)
void SetJson(const std::string value)
Load JSON string into this object.
Json::Value JsonValue() const
Generate Json::Value for this object.
Exception for invalid JSON.
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
This namespace is the default namespace for all code in the openshot library.
const Json::Value stringToJson(const std::string value)