MCPcopy Create free account
hub / github.com/christophhart/HISE / setGradientFill

Method setGradientFill

hi_scripting/scripting/api/ScriptingGraphics.cpp:2086–2128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2084}
2085
2086void 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

Callers 15

setCurrentBrushMethod · 0.45
paintMethod · 0.45
BufferMonitor.jsFile · 0.45
drawLinearSliderMethod · 0.45
fillPathHiStyleMethod · 0.45
drawVectorRotaryKnobMethod · 0.45
drawBackgroundMethod · 0.45
drawFileBrowserRowMethod · 0.45
drawMenuBarBackgroundMethod · 0.45
drawFake3DMethod · 0.45
drawMenuBarItemMethod · 0.45

Calls 6

addDrawActionMethod · 0.80
isArrayMethod · 0.45
getArrayMethod · 0.45
sizeMethod · 0.45
getUncheckedMethod · 0.45
addColourMethod · 0.45

Tested by

no test coverage detected