MCPcopy Create free account
hub / github.com/beefytech/Beef / CreateGradientDataTable

Function CreateGradientDataTable

BeefySysLib/img/ImgEffects.cpp:39–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39static uint32* CreateGradientDataTable(ImageGradient* colorGradient)
40{
41 uint32* gradientData = new uint32[GRADIENT_DATA_SIZE];
42 for (int i = 0; i < GRADIENT_DATA_SIZE; i++)
43 {
44 float yVal = i / (float) (GRADIENT_DATA_SIZE - 1);
45
46 uint32 color = 0;
47 for (int colorIdx = 0; colorIdx < 4; colorIdx++)
48 {
49 float gradientPos = 1.0f - yVal;
50 if ((colorIdx == 3) && (colorGradient[colorIdx].mPoints.size() > 2))
51 {
52 // Strange effect where alpha gradient never fully reaches end when there's more than one stop
53 gradientPos = std::min(gradientPos, 0.95f);
54 }
55
56 color |= (colorGradient[colorIdx].GetVal(gradientPos * colorGradient[colorIdx].mXSize)) << (colorIdx * 8);
57 }
58
59 gradientData[i] = color;
60 }
61
62 return gradientData;
63}
64
65
66

Callers 2

ApplyMethod · 0.85

Calls 2

sizeMethod · 0.45
GetValMethod · 0.45

Tested by

no test coverage detected