| 2084 | } |
| 2085 | |
| 2086 | void ScriptingObjects::GraphicsObject::setGradientFill(var gradientData) |
| 2087 | { |
| 2088 | if (gradientData.isArray()) |
| 2089 | { |
| 2090 | Array<var>* data = gradientData.getArray(); |
| 2091 | |
| 2092 | if (gradientData.getArray()->size() == 6) |
| 2093 | { |
| 2094 | auto c1 = ScriptingApi::Content::Helpers::getCleanedObjectColour(data->getUnchecked(0)); |
| 2095 | auto c2 = ScriptingApi::Content::Helpers::getCleanedObjectColour(data->getUnchecked(3)); |
| 2096 | |
| 2097 | auto grad = ColourGradient(c1, (float)data->getUnchecked(1), (float)data->getUnchecked(2), |
| 2098 | c2, (float)data->getUnchecked(4), (float)data->getUnchecked(5), false); |
| 2099 | |
| 2100 | |
| 2101 | drawActionHandler.addDrawAction(new ScriptedDrawActions::setGradientFill(grad)); |
| 2102 | } |
| 2103 | else if (gradientData.getArray()->size() >= 7) |
| 2104 | { |
| 2105 | auto c1 = ScriptingApi::Content::Helpers::getCleanedObjectColour(data->getUnchecked(0)); |
| 2106 | auto c2 = ScriptingApi::Content::Helpers::getCleanedObjectColour(data->getUnchecked(3)); |
| 2107 | |
| 2108 | auto grad = ColourGradient(c1, (float)data->getUnchecked(1), (float)data->getUnchecked(2), |
| 2109 | c2, (float)data->getUnchecked(4), (float)data->getUnchecked(5), (bool)data->getUnchecked(6)); |
| 2110 | |
| 2111 | auto& ar = *gradientData.getArray(); |
| 2112 | |
| 2113 | if (ar.size() > 7) |
| 2114 | { |
| 2115 | for (int i = 7; i < ar.size(); i += 2) |
| 2116 | { |
| 2117 | auto c = ScriptingApi::Content::Helpers::getCleanedObjectColour(ar[i]); |
| 2118 | auto pos = (float)ar[i + 1]; |
| 2119 | grad.addColour(pos, c); |
| 2120 | } |
| 2121 | } |
| 2122 | |
| 2123 | drawActionHandler.addDrawAction(new ScriptedDrawActions::setGradientFill(grad)); |
| 2124 | } |
| 2125 | } |
| 2126 | else |
| 2127 | reportScriptError("Gradient Data is not sufficient"); |
| 2128 | } |
| 2129 | |
| 2130 | |
| 2131 |
no test coverage detected