Simplifying Quads

Issue #502 invalid
created an issue

I think using quads could be simplified in a few ways.

  • The reference width and height could be aquired from the Image used in the drawq function. If there's something cool that you can do by changing the reference width and height to something other than the width and height of the Image, these values could optionally be given.
  • A table of values could be used instead of the quad type. Since a quad is just an array of numbers (Edit: Actually not quite, it can also flip the drawn image/canvas too), I think there is no need for a quad type, just as there is no color type.
  • The function could have the name (#487) instead. It's pronouncable (which I find makes it more aesthetically appealing), I think it describes the functionality better, and it is more different from, which isn't quite the same as it draws Drawables instead of only Images (Edit: and Canvases), and being more visually distinct may improve readability.

Here's an example using what I propose:

image ='image.png')
quad = {128, 0, 32, 32}, quad, 0, 0)

Comments (4)

  1. Bart van Strien

    This would certainly make the calls more expensive, especially the table one, since it needs to be completely read through lua every time it's needed.

    Regarding the name, I agree that drawq might not be as obvious, but quad makes it sound so different from draw, while it is in the same 'family'. As for Drawables vs Images, actually, drawq doesn't accept Images only, it accepts Drawqables. Perhaps drawQuad is better, at the expense of a longer name?

  2. hahawoo reporter

    Ah, I see. Would the using the image/canvas width and height as the default reference be that much more expensive though? If the difference is negligible I'd suggest it would be worth it, and if the difference is not too much but potentially significant, perhaps the Quad could be "optimized" by explicitly specifying the reference width and height?

    I wasn't aware of Drawqables, thanks! :D

    I think drawQuad is a really good name actually, it's longer but I feel it's more consistent with the LÖVE naming aesthetic.

  3. Alex Szpakowski

    Most of these points no longer apply now that Geometries have replaced Quads. Geometries are also a fair bit "heavier" (more computation is involved when creating them, and they use a bit more memory), so doing create-on-draw is even less of a good idea.

    It still might be good to rename drawg to drawGeometry or something else. Maybe open a new issue.

  4. Log in to comment