MCPcopy Create free account
hub / github.com/Snapchat/Valdi / makeGradientValue

Function makeGradientValue

valdi/test/runtime/AttributeProcessors_tests.cpp:15–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13static auto kColorPalette = makeShared<ColorPalette>();
14
15static Value makeGradientValue(std::vector<Color> colors, std::vector<double> locations, int32_t angle, bool radial) {
16 auto outColors = ValueArray::make(colors.size());
17 auto outLocations = ValueArray::make(locations.size());
18
19 for (size_t i = 0; i < colors.size(); i++) {
20 outColors->emplace(i, Value(colors[i].value));
21 }
22 for (size_t i = 0; i < locations.size(); i++) {
23 outLocations->emplace(i, Value(locations[i]));
24 }
25
26 return Value(ValueArray::make({Value(outColors), Value(outLocations), Value(angle), Value(radial)}));
27}
28
29TEST(AttributeProcessor, canParseSimpleBackground) {
30 auto result = preprocessGradient(kColorPalette, Value(STRING_LITERAL("red")));

Callers 1

TESTFunction · 0.85

Calls 3

ValueInterface · 0.50
sizeMethod · 0.45
emplaceMethod · 0.45

Tested by

no test coverage detected