setting rectangle angle ? (not image)

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
PGUp
Party member
Posts: 105
Joined: Fri Apr 21, 2017 9:17 am

setting rectangle angle ? (not image)

Post by PGUp »

so to spawn a basic rectangle, i use draw function, but i have no idea how to set its angle, help ?
-
MasterLee
Party member
Posts: 141
Joined: Tue Mar 07, 2017 4:03 pm
Contact:

Re: setting rectangle angle ? (not image)

Post 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
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: setting rectangle angle ? (not image)

Post 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
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 242 guests