• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code Draw a rectangle but define all 4 positions?

hdarren

Member
I would like to draw a titled rectangle using draw_rectangle. The function only gives two points though. Are there any similar functions that will allow me to draw a rectangle that's tilted by defining all four points?

If not, this is my feature request.

Thanks.
 
A

Ampersand

Guest
A "tilted rectangle" could be defined as a few different shapes. Parallelogram or rhombus? Depending on the shape you'll most likely have to also define interior or exterior angles. I don't think anything that's not a true rectangle and be defined by only two points.
 
A

Ampersand

Guest
You can definitely do that, but you will have to work with primitives. Could possibly just draw triangles. If all four points are defined, draw lines between each point. Draw two triangles to fill the middle rectangle using your two innermost points on the x axis. Then draw a triangle from each of the outermost points to the two nearest points that make up your inner rectangle.
 
A

Ampersand

Guest
An alternative to using primitives would be to create a plain white mask sprite and use draw_sprite_pos.
Slick! ;) Good suggestion, I've never tried this but I'm gonna check the performance on this and see how big the speed difference is between pushing primitive polys and pseudo-polys from a sprite mask :)
 
Top