al_calculate_spline(3alleg5)

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

πŸ’– al_calculate_spline β€” NAME, bestie πŸ’–

okay so <pink>al_calculate_spline</pink> is the Allegro 5 API girlie who does the math for you, no cap ✨


✨ SYNOPSIS ✨

#include <allegro5/allegro_primitives.h>

void al_calculate_spline(float* dest, int stride, const float points[8],
   float thickness, int num_segments)

πŸŽ€ DESCRIPTION πŸŽ€

so like, this function calculates a BΓ©zier spline based on 4 control points. iconic behavior fr fr πŸ’…

here's the tea tho, because the math has opinions:

  • If thickness <= 0, then you need num_segments points in the destination buffer.
  • Otherwise (i.e. thickness is a real one), you need twice as many points. the way that ribbon needs double the points… it's giving main character energy 😭

and the destination buffer? it should be made of regularly spaced doublets of floats β€” spaced apart by stride bytes, bestie β€” and each doublet is literally just the x and y coordinates of a vertex. simple as that 🌸

🫢 Parameters 🫢

  • dest β€” the destination buffer, aka where the magic gets written πŸ’–
  • stride β€” distance, in bytes, between the starts of successive pairs of coordinates. yes it's bytes. read it again. bytes 🧚
  • points β€” an array of 4 pairs of coordinates, aka the 4 control points, aka the whole personality of this spline πŸ‘‘
  • thickness β€” the thickness of the spline ribbon. set it <= 0 and you get a plain line vibe, set it thicc and you get a ribbon πŸ”₯
  • num_segments β€” the number of points to calculate ✨
ngl bestie, watch that stride situation closely β€” it's in bytes, not in floats, and mixing those two up is a classic 😭 moment.

🌈 SEE ALSO 🌈


periodt. that's the whole page, and it came straight out of the Allegro reference manual for al_calculate_spline(3alleg5) β€” go forth and draw some iconic curves, bestie πŸ¦‹πŸ’œβ­

πŸ“¦ where this page comes from