Page 1 of 1

setting rectangle angle ? (not image)

Posted: Tue Apr 25, 2017 2:23 pm
by PGUp
so to spawn a basic rectangle, i use draw function, but i have no idea how to set its angle, help ?

Re: setting rectangle angle ? (not image)

Posted: Tue Apr 25, 2017 2:58 pm
by MasterLee
Angles in rectangles are always right angles (90°) by definition. You can't set em.
But you could rotate the rectangle.
https://love2d.org/wiki/love.graphics.rotate

Re: setting rectangle angle ? (not image)

Posted: Tue Apr 25, 2017 5:44 pm
by Ref
Example:

Code: Select all

function rotatingRectangle( mode,x,y,w,h,a,ox,oy,r )	
   ox = ox or 0	-- if ox & oy not provided, rotate around upper left corner
   oy = oy or 0	-- if ox,oy = w/2,h/2 then rotation is around center
   a = a or 0	-- if no angle provided, angle assumed to be zero
   r = r or 5	-- corner radius
   love.graphics.push()
   love.graphics.translate( x, y )
   love.graphics.rotate( a )
   love.graphics.rectangle( mode, -ox, -oy, w, h, r )
   love.graphics.pop()
end