Skip to content

Instantly share code, notes, and snippets.

@DragoniteSpam
Created December 8, 2020 23:10
Show Gist options
  • Save DragoniteSpam/80e18d748b33d24a14c0bc3f8c4b7530 to your computer and use it in GitHub Desktop.
Save DragoniteSpam/80e18d748b33d24a14c0bc3f8c4b7530 to your computer and use it in GitHub Desktop.
function draw_ngon(x, y, n, length, rot) {
draw_primitive_begin(pr_trianglefan);
draw_vertex_colour(x, y, c_white, 1);
for (var i = 0; i <= n; i++) {
var angle = 2 * pi / n * i + rot;
draw_vertex_colour(x + length * cos(angle), y - length * sin(angle), make_colour_hsv(255 / (n + 1) * i, 255, 255), 1);
}
draw_primitive_end();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment