Page 1 of 1

Linking/merging drawings

Posted: Sun Oct 26, 2014 3:11 pm
by citrus_psyche
Hi guys,

I've just started working with LOVE and I have one small question.

Is it possible to draw multiple objects as one? For example, instead of doing
love.graphics.rectangle( "fill", x1, y1, width1, height1)
love.graphics.rectangle( "fill", x2, y2, width2, height2),
I want to draw both rectangle with just one line of code, by pre-defining them somehow, like
double_rectangle = rectangle1 + rectangle2
draw double_rectangle
I'm asking because I'm working with multiple stacked rectangles of different transparencies and drawing them every frame is very CPU-intensive.

Hope you can help!

Re: Linking/merging drawings

Posted: Sun Oct 26, 2014 4:38 pm
by DaedalusYoung
If they're static, you can draw them to a Canvas, then draw the Canvas to screen.

Re: Linking/merging drawings

Posted: Mon Oct 27, 2014 12:57 am
by caldur
Love doesn't have a built-in "shape batch" so to speak, but you can use Mesh to pack the vertices and draw them with one draw call... requires a little extra work though.

Re: Linking/merging drawings

Posted: Mon Oct 27, 2014 10:56 am
by Plu
You can also wrap them into a function, and call that for the actual drawing.