MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / DrawRects

Function DrawRects

deps/SDL2/test/testdraw2.c:133–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131}
132
133void
134DrawRects(SDL_Renderer * renderer)
135{
136 int i;
137 SDL_Rect rect;
138 SDL_Rect viewport;
139
140 /* Query the sizes */
141 SDL_RenderGetViewport(renderer, &viewport);
142
143 for (i = 0; i < num_objects / 4; ++i) {
144 /* Cycle the color and alpha, if desired */
145 if (cycle_color) {
146 current_color += cycle_direction;
147 if (current_color < 0) {
148 current_color = 0;
149 cycle_direction = -cycle_direction;
150 }
151 if (current_color > 255) {
152 current_color = 255;
153 cycle_direction = -cycle_direction;
154 }
155 }
156 if (cycle_alpha) {
157 current_alpha += cycle_direction;
158 if (current_alpha < 0) {
159 current_alpha = 0;
160 cycle_direction = -cycle_direction;
161 }
162 if (current_alpha > 255) {
163 current_alpha = 255;
164 cycle_direction = -cycle_direction;
165 }
166 }
167 SDL_SetRenderDrawColor(renderer, 255, (Uint8) current_color,
168 (Uint8) current_color, (Uint8) current_alpha);
169
170 rect.w = rand() % (viewport.h / 2);
171 rect.h = rand() % (viewport.h / 2);
172 rect.x = (rand() % (viewport.w*2) - viewport.w) - (rect.w / 2);
173 rect.y = (rand() % (viewport.h*2) - viewport.h) - (rect.h / 2);
174 SDL_RenderFillRect(renderer, &rect);
175 }
176}
177
178void
179loop()

Callers 1

loopFunction · 0.70

Calls 4

SDL_RenderGetViewportFunction · 0.85
SDL_SetRenderDrawColorFunction · 0.85
SDL_RenderFillRectFunction · 0.85
randFunction · 0.50

Tested by

no test coverage detected