Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void drawPolygon(uint8_t r, uint8_t g, uint8_t b, int nombreDePoints, ...)
- // r, g, b, <number of points you want (4 for a square, for instance, not 8 because of x and y...)>, <x1,y1,x2,y2...>
- {
- // the number of arguments in the <...> must be even
- int i;
- int* pointsList = (int*)malloc(nombreDePoints*2*sizeof(int));
- va_list ap;
- int cur_arg = 1;
- va_start(ap, nombreDePoints);
- for (i = 0; i < nombreDePoints*2; i++)
- {
- cur_arg = va_arg(ap, int);
- *(pointsList + i) = cur_arg;
- }
- for (i = 0; i < nombreDePoints*2 - 2; i+=2)
- {
- drawLine(*(pointsList + i), *(pointsList + i + 1), *(pointsList + i + 2), *(pointsList + i + 3), r, g, b);
- }
- drawLine(*(pointsList + nombreDePoints*2 - 2), *(pointsList + nombreDePoints*2 - 1), *(pointsList), *(pointsList + 1), r, g, b);
- va_end(ap);
- free(pointsList);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement