Commit Graph

36 Commits

Author SHA1 Message Date
Alex Szpakowski 0752f27bdf Update copyright year for 2019 2019-01-03 21:09:05 -04:00
Alex Szpakowski 5d5c2f9a96 math and data module instances are now deleted when they have no more Lua references (matches the behaviour of other modules.) Fixes the deprecation system not fully restarting when love.event.quit("restart") is called.
Resolves issue #1462.
2018-12-17 16:44:13 -04:00
Alex Szpakowski d37c53584e Fixed the mipmaps flag in love.graphics.newImage; cleaned up a bit of vector code in love.math.isConvex. 2018-01-28 22:32:40 -04:00
Bart van Strien e80247c191 Happy new year! 2018-01-03 19:47:35 +01:00
Alex Szpakowski 90e86c329d Add love.data module.
- Moved love.math.compress / decompress / decode / encode / hash to love.data.
- Changed love.data.compress/decompress to take the format argument first instead of second.
- Added love.data.newDataView. Returns a read-only subsection of an existing Data object.
- Added love.data.newByteData. Mostly useful in combination with LuaJIT's FFI as it has no extra methods currently.
- Added implementations of Lua 5.3's data packing APIs: love.data.packString / packData / unpack / getPackedSize.

Resolves issue #1336.
Resolves issue #1331.

--HG--
branch : minor
2017-09-24 19:25:27 -03:00
Alex Szpakowski ef5897b22c Seed love.math.random when the math module is loaded, instead of in love.run.
--HG--
branch : minor
2017-07-23 19:45:49 -03:00
Alex Szpakowski ac697ddb0f Clean up love’s internal Vector code a bit, and rename it to Vector2 so it’s more obvious what it is.
--HG--
branch : minor
2017-05-16 22:07:01 -03:00
Alex Szpakowski abb72cb813 Happy new year! 🥂
--HG--
branch : minor
2017-01-02 01:28:29 -04:00
Alex Szpakowski 14aa6965b3 Added Transform objects to love.math (resolves issue #1228).
- Added love.math.newTransform.
- Added love.graphics.applyTransform and love.graphics.replaceTransform.
- love.graphics.draw/print/printf, Text:add/addf, and SpriteBatch:add can accept a Transform argument.
- love.graphics.push can accept an optional Transform as a second argument, which will apply the Transform after pushing the matrix stack,
- Shader:send can accept Transform objects when sending to a mat4 uniform variable.

--HG--
branch : minor
2016-11-24 21:30:45 -04:00
Alex Szpakowski ef61573cd3 Merge default into minor
--HG--
branch : minor
2016-08-29 22:41:24 -03:00
Alex Szpakowski 677a8d60b8 Use love::Vector (8 bytes) instead of love::Vertex (20 bytes) for love.math.triangulate and love.math.isConvex. 2016-08-24 18:02:27 -03:00
Bart van Strien 3a2e859acd Add love.math.hash, which supports MD5/SHA-1/SHA-2.
--HG--
branch : minor
2016-04-02 18:39:53 +02:00
Alex Szpakowski cc1b9bc619 Moved most love.math functions out of the Math class, since they're pure functions.
--HG--
branch : minor
2016-03-28 19:46:29 -03:00
Alex Szpakowski 734789eb93 Added love.math.encode(format, data | string [, linelength]) and love.math.decode(format, data | string). Current formats are "base64" and "hex". The optional line length only applies to base64 and specifies the maximum number of characters per line in the encoded string.
Removed the variant of love.filesystem.newFileData which decoded a base64-encoded string since it's redundant.

--HG--
branch : minor
2016-03-28 19:28:40 -03:00
Alex Szpakowski 314a82b126 Fixed the piecewise function in linearToGamma to use <= instead of < when determining whether to use the linear part of the function. 2016-01-13 21:23:56 -04:00
Alex Szpakowski 46a2e7b85c Happy new year! 🎉 2016-01-01 00:05:06 -04:00
Alex Szpakowski 2e9154283c Added gzip support to love.math.compress and love.math.decompress. 2015-10-02 03:18:11 -03:00
Alex Szpakowski d215d8a91e Reworked sRGB / gamma-correct APIs:
Gamma-correct blending and shader math can be enabled globally via the new 't.gammacorrect' boolean flag in love.conf.
The new function love.graphics.isGammaCorrect will return true if it was requested in love.conf and is supported on the system.

When gamma correct rendering is enabled, colors (including the colors of pixels from images) are automatically converted from sRGB to linear RGB before use. When drawing to the main screen or to a canvas with the 'normal' or 'srgb' format, the final output colors of pixel shaders are automatically converted from linear RGB to sRGB after blending and before the color is stored in the pixel.

This lets the rendering pipeline do math using linear RGB values for colors rather than sRGB values, so the math is correct, without making users of the APIs manually linearize their colors with the love.math.gammaToLinear function (which still exists). The final output of the screen is encoded as sRGB, which is what systems expect. Canvases (except when otherwise requested) store their contents with sRGB encoding for increased precision with darker colors.

the 'srgb' window setting flag has been removed, as well as the 'srgb' image flag. A new image flag 'linear' has been added, which when set to true will cause the colors of the image to always be treated as linear RGB rather than sRGB, when gamma-correct rendering is enabled.

A new function 'Shader:sendColor' has been added, which has the same argument structure as 'Shader:send' but expects colors in the range of [0, 255]. When gamma-correct rendering is enabled it automatically gamma-corrects the given colors (by applying gammaToLinear to them.)

New shader code functions have been added: gammaToLinear, linearToGamma, gammaCorrectColor, and unGammaCorrectColor. When gamma-correct rendering is enabled, the LOVE_GAMMA_CORRECT #define is set and gammaCorrectColor and unGammaCorrectColor are aliases for gammaToLinear and linearToGamma respectively, otherwise the functions do nothing.

The new shader functions have 'precise' and 'fast' variants. If the LOVE_PRECISE_GAMMA define is set, then the normal functions default to the precise variants, otherwise they default to the fast variants. Currently the define is set in vertex shaders and not set in pixel shaders.

The default per-vertex color is automatically gamma-corrected by LÖVE when gamma correct rendering is enabled, but any custom named per-vertex attribute specified with the new custom attribute Mesh functionality won't be, unless 'gammaCorrectColor' or similar functions are explicitly used (preferably inside the vertex shader code that has the custom attribute.)
2015-08-09 21:46:21 -03:00
Alex Szpakowski a29b349014 Added love.math.compress(data, format [, level]) and love.math.decompress(compresseddata) / love.math.decompress(compressedstring, format).
Renamed the love.image CompressedData type to CompressedImageData.

love.math.compress returns a love.math CompressedData object which holds the newly compressed data. Currently supported formats are "lz4" and "zlib". Note that the formats are not file formats and don't compress filesystem hierarchies.
2015-03-23 11:28:14 -03:00
Alex Szpakowski c7b45b3505 Updated copyright for the new year 2014-12-31 19:32:43 -04:00
Alex Szpakowski d52bab4221 Updated the new module changes to use more compile/link-time checking rather than runtime checking. 2014-07-21 15:12:01 -03:00
Alex Szpakowski 014b9a46e5 Updated the Lua wrapper code for modules to account for cases where the module's instance is removed from memory completely and recreated during the program's lifetime. 2014-07-21 14:52:01 -03:00
Alex Szpakowski 4faddcd9aa Fixed some trivial compiler warnings 2014-03-12 17:55:19 -03:00
Alex Szpakowski e54d771be4 Added love.math.gammaToLinear and love.math.linearToGamma for converting RGB color values from the sRGB color-space to linear and vice-versa. 2014-02-04 19:45:50 -04:00
Alex Szpakowski 3120a0e650 Goodbye 2013, hello 2014! 2014-01-03 17:28:58 -04:00
Alex Szpakowski cded0e4a3b Fixed a typo when love.math.triangulate errors 2013-11-05 15:17:54 -04:00
Alex Szpakowski 5de43a7207 The Vertex struct is now recognized as POD by C++, also fixed the name to be consistent with other love structs 2013-09-24 11:09:18 -03:00
vrld 19eade843c Add support for Bezier curves of arbitrary degree.
New functions:

bezier = love.math.newBezierCurve(control-points)
degree = bezier:getDegree() -- degree = #control-points - 1
x,y = bezier:getControlPoint(pos) -- pos < 0 => string.sub semantics
bezier:setControlPoint(pos, x, y) -- pos < 0 => string.sub semantics
bezier:insertControlPoint(x,y, [pos = -1])
x,y = bezier:eval(t) -- 0 <= t <= 1
polyline = bezier:render([accuracy = 5]) -- returns a table of points

Example:

function love.load()
	b = love.math.newBezierCurve(10,10, 80,400, 380,400, 470,10)
end

function love.draw()
	if not curve then -- curve rendering is expensive-ish
		curve = b:render()
	end
	love.graphics.line(curve)
end
2013-05-12 21:57:06 +02:00
vrld d454be7025 Add love.math.isConvex()
Checks whether a given polygon is convex or not.
2013-05-12 13:00:08 +02:00
Alex Szpakowski 7ab3809165 Fixed Object:typeOf for love.physics objects new to 0.8.0, removed vestigial ColorMode code 2013-05-07 15:23:26 -03:00
Alex Szpakowski 3bf43dadd8 Renamed CompressedData:getNumMipmaps to CompressedData:getMipmapCount; Improved type-checking error messages for some functions which expect function arguments 2013-05-02 17:26:50 -04:00
vrld 71317c4359 Add Geometries (replaces Quads).
A Geometry is a collection of vertices describing a non self-intersecting
(simple) polygon. In addition to screen coordinates, the vertices have
attributes for texture coordinates (s,t) and color (r,g,b,a).

It can be used as a quad, to display distorted images, or anything in between.

Added:
^^^^^^

-- geometry from table, where table has the format:
-- info = {
-- {x,y, s,t, [r = 255, g = 255, b = 255, a = 255]}
-- {x,y, s,t, [r = 255, g = 255, b = 255, a = 255]}
-- ...
-- }
geom = love.graphics.newGeometry(info)

-- convenience wrapper for quads (same as before)
geom = love.graphics.newQuad(x,y, w,h, sw,sh)

-- retrieve vertex i (1-indexed)
x,y,s,t,r,g,b,a = geom:getVertex(i)

-- set vertex i (1-indexed)
geom:setVertex(i, x,y, s,t, [r,g,b,a])

-- flip geometry
geom:flip(x, y)


Renamed:
^^^^^^^^

love.graphics.drawq() -> love.graphics.drawg()


Removed:
^^^^^^^^

quad:setViewport()
quad:getViewport()
2013-04-21 18:53:13 +02:00
Alex Szpakowski bf6d1c258b Misc. code cosmetics and improvements 2013-04-18 02:14:35 -03:00
Alex Szpakowski 3046981fce Added love.math.newRandomGenerator. Returns a RNG object with its own seed and random methods.
--HG--
branch : math-randobject
2013-04-14 23:02:44 -03:00
vrld db86fa4b83 Make love.math.triangulate with any polygon winding order. 2013-03-14 17:21:13 +01:00
vrld 1a407a6af3 Make non-gcc compilers happy... 2013-03-13 23:09:25 +01:00