Fixed a few issues with Color keyframes

This commit is contained in:
Jonathan Thomas
2015-10-01 18:51:59 -05:00
parent af3ad48455
commit ac7be90544
3 changed files with 4 additions and 3 deletions

View File

@@ -136,5 +136,5 @@ void Color::SetJsonValue(Json::Value root) {
if (!root["blue"].isNull())
blue.SetJsonValue(root["blue"]);
if (!root["alpha"].isNull())
blue.SetJsonValue(root["alpha"]);
alpha.SetJsonValue(root["alpha"]);
}

View File

@@ -202,10 +202,10 @@ Point Keyframe::GetClosestPoint(Point p) {
// Handle edge cases (if no point was found)
if (closest.co.X == -1) {
if (p.co.X < 1)
if (p.co.X < 1 && Points.size() > 0)
// Assign 1st point
closest = Points[0];
else
else if (Points.size() > 0)
// Assign last point
closest = Points[Points.size() - 1];
}

View File

@@ -169,6 +169,7 @@ string ChromaKey::PropertiesJSON(long int requested_frame) {
root["duration"] = add_property_json("Duration", Duration(), "float", "", false, 0, 0, 1000 * 60 * 30, CONSTANT, -1, true);
// Keyframes
root["color"] = add_property_json("Key Color", 0.0, "color", "", color.red.Contains(requested_point), color.red.GetCount(), -10000, 10000, color.red.GetClosestPoint(requested_point).interpolation, color.red.GetClosestPoint(requested_point).co.X, false);
root["color"]["red"] = add_property_json("Red", color.red.GetValue(requested_frame), "float", "", color.red.Contains(requested_point), color.red.GetCount(), -10000, 10000, color.red.GetClosestPoint(requested_point).interpolation, color.red.GetClosestPoint(requested_point).co.X, false);
root["color"]["blue"] = add_property_json("Blue", color.blue.GetValue(requested_frame), "float", "", color.blue.Contains(requested_point), color.blue.GetCount(), -10000, 10000, color.blue.GetClosestPoint(requested_point).interpolation, color.blue.GetClosestPoint(requested_point).co.X, false);
root["color"]["green"] = add_property_json("Green", color.green.GetValue(requested_frame), "float", "", color.green.Contains(requested_point), color.green.GetCount(), -10000, 10000, color.green.GetClosestPoint(requested_point).interpolation, color.green.GetClosestPoint(requested_point).co.X, false);