polygon function
Implementation
bool polygon(Pointer<SdlRenderer> renderer, Pointer<Int16> vx,
Pointer<Int16> vy, int n) {
/*
* Draw
*/
bool result = true;
int i, nn;
/*
* Vertex array NULL check
*/
if (vx == nullptr) {
return false;
}
if (vy == nullptr) {
return false;
}
/*
* Sanity check
*/
if (n < 3) {
return false;
}
/*
* Create array of points
*/
nn = n + 1;
var points = calloc<SdlFPoint>(nn);
// points = (SDL_Point*)malloc(sizeof(SDL_Point) * nn);
if (points == nullptr) {
return false;
}
for (i = 0; i < n; i++) {
points[i].x = vx[i].toDouble();
points[i].y = vy[i].toDouble();
}
points[n].x = vx[0].toDouble();
points[n].y = vy[0].toDouble();
/*
* Draw
*/
if (result) {
result = sdlRenderLines(renderer, points, nn);
}
calloc.free(points);
return result;
}