al_draw_polyline(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ al_draw_polyline β€” Allegro 5 API ✨

okay bestie, so this is a page from the al_draw_polyline manual (that's the <pink>3alleg5</pink> bit, iykyk) and it's literally all about drawing a lil chain of connected lines. let's get into it πŸ’…


🌈 SYNOPSIS 🌈

#include <allegro5/allegro_primitives.h>

void al_draw_polyline(const float* vertices, int vertex_stride,
   int vertex_count, int join_style, int cap_style,
   ALLEGRO_COLOR color, float thickness, float miter_limit)

πŸ’– DESCRIPTION πŸ’–

no cap, the whole vibe is: draw a series of line segments. that's it, that's the function. but the args? let's break them down one by one 🫢

  • vertices β€” interleaved array of (x, y) vertex coordinates
  • vertex_stride β€” the number of bytes between pairs of vertices (aka the stride)
  • vertex_count β€” number of vertices in the array
  • join_style β€” a member of ALLEGRO_LINE_JOIN(3alleg5) that says how to render the joins between line segments
  • cap_style β€” a member of ALLEGRO_LINE_CAP(3alleg5) that says how to render the end caps
  • color β€” color of the line πŸŽ€
  • thickness β€” thickness of the line, and listen, pass <= 0 to draw hairline lines ✨
  • miter_limit β€” parameter for miter join style

so about that stride β€” normally it's 2 * sizeof(float), but it can be more if your vertex coordinates are chillin' inside an array of some struct type. like, for example:

struct VertexInfo {
   float x;
   float y;
   int id;
};

void my_draw(struct VertexInfo verts[], int vertex_count, ALLEGRO_COLOR c)
{
   al_draw_polyline((float *)verts, sizeof(VertexInfo), vertex_count,
      ALLEGRO_LINE_JOIN_NONE, ALLEGRO_LINE_CAP_NONE, c, 1.0, 1.0);
}

see how that works?? main character struct energy fr fr πŸ’€

and plot twist: the stride may also be negative if the vertices are stored in reverse order. yes, negative. iconic behavior honestly πŸ‘‘


🌸 SINCE 🌸

5.1.0 β€” she's been around since 5.1.0, a true legend ⭐


πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole page bestie!! this was the Allegro reference manual being adorable about al_draw_polyline, version 5.1.0 era vibes, and honestly? obsessed. go draw some polylines, you got this πŸ’œπŸ§š

πŸ“¦ where this page comes from