al_draw_rotated_bitmap(3alleg5)

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

✨ NAME ✨

al_draw_rotated_bitmap β€” like, the Allegro 5 API function that spins your bitmap around πŸ’« (this one lives in the Allegro 5 API, bestie, section 3 of the manual, iykyk)


πŸŽ€ SYNOPSIS πŸŽ€

#include <allegro5/allegro.h>

void al_draw_rotated_bitmap(ALLEGRO_BITMAP *bitmap,
   float cx, float cy, float dx, float dy, float angle, int flags)

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so this one draws a rotated version of the bitmap you hand it, onto the target bitmap. The rotation is by angle radians, and it goes clockwise, no cap πŸ•

Here's the tea: the point at cx/cy β€” measured relative to the upper left corner of the bitmap β€” is the point that gets drawn at dx/dy, and the whole bitmap rotates around it. So if cx,cy is 0,0, your bitmap spins around its upper left corner. That's it, that's the mechanic πŸ’…

  • cx β€” center x, and it's relative to the bitmap, not the screen
  • cy β€” center y, same deal, relative to the bitmap
  • dx β€” destination x, where the party actually lands
  • dy β€” destination y, fr fr
  • angle β€” the angle you're rotating by, in radians
  • flags β€” literally the same as for al_draw_bitmap(3alleg5), nothing new here

🌸 Example 🌸

float w = al_get_bitmap_width(bitmap);
float h = al_get_bitmap_height(bitmap);
al_draw_rotated_bitmap(bitmap, w / 2, h / 2, x, y, ALLEGRO_PI / 2, 0);

So what that little cutie above is doing: it draws the bitmap centered on x/y and rotates it 90° clockwise. Iconic behaviour, honestly ✨

Heads up bestie β€” go read al_draw_bitmap(3alleg5) for a note on restrictions on which bitmaps can be drawn where. Don't skip it, it's giving important πŸ™ˆ

πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, bestie πŸ’– this was the Allegro reference manual dropping al_draw_rotated_bitmap(3alleg5) for you β€” go rotate something slay, ily, bye 🫢

πŸ“¦ where this page comes from