MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / DrawGradient

Function DrawGradient

LibLemon/src/gfx/graphics.cpp:146–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144 }
145
146 void DrawGradient(int x, int y, int width, int height, rgba_colour_t c1, rgba_colour_t c2, surface_t* surface){
147 if(x < 0){
148 width += x;
149 x = 0;
150 }
151
152 if(y < 0){
153 height += y;
154 y = 0;
155 }
156
157 for(int j = 0; j < width && (x + j) < surface->width; j++){
158 DrawRect(x + j, y, 1, height, (uint8_t)(j*(((double)c2.r - (double)c1.r)/width)+c1.r),(uint8_t)(j*(((double)c2.g - (double)c1.g)/width)+c1.g),(uint8_t)(j*(((double)c2.b - (double)c1.b)/width)+c1.b),surface);
159 }
160 }
161
162 void DrawGradientVertical(rect_t rect, rgba_colour_t c1, rgba_colour_t c2, surface_t* surface){
163 DrawGradientVertical(rect.pos.x, rect.pos.y, rect.size.x, rect.size.y, c1, c2, surface);

Callers 1

PaintMethod · 0.85

Calls 1

DrawRectFunction · 0.70

Tested by

no test coverage detected