local graphics = love.graphics local setColor = graphics.setColor -- Love2D changed color values to be 0-1 -- Allow 0-255 values again.. function graphics.setColor(r,g,b,a) if type(r) == "table" then r, g, b, a = r.r, r.g, r.b, r.a else r, g, b, a = r or 255, g or 255, b or 255, a or 255 end setColor(r/255,g/255,b/255,a/255) end -- Draw an image using width and height in pixels -- OriginX and OriginY should be between 0 and 1 -- An origin of 0.5, 0.5 would be the center function graphics.easyDraw(obj, x, y, rotation, width, height, originX, originY, ...) if not obj then return end local objW, objH = obj:getWidth(), obj:getHeight() rotation = rotation or 0 width = width or objW height = height or objH originX = originX or 0 originY = originY or 0 local scaledW = width / objW local scaledH = height / objH graphics.draw(obj, x, y, rotation, scaledW, scaledH, objW * originX, objH * originY, ...) end --applies a transformation that maps -- 0,0 => ox, oy -- 1,0 => xx, xy -- 0,1 => yx, yy -- via love.graphics.translate, .rotate and .scale local sqrt = math.sqrt local atan2 = math.atan2 local acos = math.acos local tan = math.tan local cos = math.cos local sin = math.sin function graphics.transform(ox, oy, xx, xy, yx, yy) local ex, ey, fx,fy = xx-ox, xy-oy, yx-ox, yy-oy if ex*fy