| 305 | } |
| 306 | } |
| 307 | void CanvasDrawRectA(int x1, int y1, int x2, int y2, double alpha, Canvas* ptr) |
| 308 | { |
| 309 | if(!ptr) |
| 310 | { |
| 311 | nullcThrowError("ERROR: Canvas object is nullptr"); |
| 312 | return; |
| 313 | } |
| 314 | for(int x = x1 < 0 ? 0 : x1, xe = x2 > ptr->width ? ptr->width : x2; x < xe; x++) |
| 315 | { |
| 316 | for(int y = y1 < 0 ? 0 : y1, ye = y2 > ptr->height ? ptr->height : y2; y < ye; y++) |
| 317 | { |
| 318 | float *pixel = &((float*)ptr->data.ptr)[y * ptr->width * 4 + x * 4]; |
| 319 | |
| 320 | pixel[0] = float(ptr->color[0] * alpha + pixel[0] * (1.0 - alpha)); |
| 321 | pixel[1] = float(ptr->color[1] * alpha + pixel[1] * (1.0 - alpha)); |
| 322 | pixel[2] = float(ptr->color[2] * alpha + pixel[2] * (1.0 - alpha)); |
| 323 | pixel[3] = 1.0f; |
| 324 | } |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | float saturate(float x){ if(x < 0.0) return 0.0; if(x > 255.0) return 255.0; return x; } |
| 329 |
nothing calls this directly
no test coverage detected