1
\$\begingroup\$

I'd like to use Matricies to transform primitive geometric shapes and draw them using the Allegro library using version 4.2 (I can not switch to 5.x just yet). This works fine for non-filled objects that are just a series of lines and any filled object that require explicitly telling allegro each point in the shape (triangles and polygons).

However, I want to be able to draw a filled rectangle that is not axis-aligned.

Is there an algorithm that given the pixel locations of the four corners of a rectangle, allow drawing individual lines to fill it? That would solve the problem for the time being.

\$\endgroup\$
2
\$\begingroup\$

This is by design: rect() is a specifically optimised version for axis-aligned rectangles.

I suggest doing two calls to triangle() instead, splitting your rectangle along one of its diagonals.

\$\endgroup\$
  • \$\begingroup\$ That's a good idea. I did similar for implementing a filled Sector, essentially creating a triangle fan. \$\endgroup\$ – Casey May 25 '14 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.