Commit Graph

66 Commits

Author SHA1 Message Date
Sasha Szpakowski 0b75f6cfa5 Missed some files... 2022-12-31 22:36:48 -04:00
Miku AuahDark fb815edc28 Change luaL_loadbuffer chunkname with prefixes. 2021-12-12 09:23:00 +08:00
Alex Szpakowski fc4847c69d Update copyright for the new year 2020-01-03 22:40:36 -04:00
Alex Szpakowski 32f381576e Avoid using lightuserdata in internal wrapper code for the math module. 2019-07-20 10:51:59 -03:00
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
Bart van Strien e80247c191 Happy new year! 2018-01-03 19:47:35 +01:00
Alex Szpakowski 9fa73f8b87 Several love.data functions now take an enum ("data" or "string") to determine whether they return a Data object or a string.
Changed functions are love.data.compress, decompress, encode, decode, and pack.
2017-12-22 16:13:20 -04:00
Alex Szpakowski 6dea2ab714 Clamp all color arguments to [0, 1] in cases where values outside that range don't make sense (fixed-point color values & sRGB colors). Closes issue #1315.
--HG--
branch : minor
2017-11-21 19:49:52 -04:00
Bart van Strien 9e4374935d Show (short) list of possible enum values when an invalid value is encountered (resolves #1318)
All enum errors have (hopefully) been changed to a luax_enumerror, which has a
fixed error message. If additionally a list of valid options is passed, it
lists that in the error message. For every enum error with few options I've
implemented this using a getConstants call.

This solution has been designed specifically to reduce the number of template
instantiations (as I've been told that was a concern). All new template code
happens in places where there already was an instantiation of the relevant
StringMap. Of course there is still std::vector<std::string>...

--HG--
branch : minor
2017-10-02 17:11:53 +02: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 34ebe18f14 Use luaL_check/optinteger instead of luaL_check/optnumber when getting integer arguments to functions. Resolves issue #1251.
--HG--
branch : minor
2017-07-16 12:17:50 -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
Bart van Strien 24a7a3d367 Merge minor into dynamiccore2
--HG--
branch : dynamiccore2
2016-11-26 22:19:12 +01: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
Bart van Strien 5d43c9601a Automatically deduce the type in luax_pushtype, if possible
--HG--
branch : dynamiccore2
2016-11-13 17:38:42 +01:00
Bart van Strien 7dd960619d Automatically deduce the type in luax_checktype, luax_getmodule, luax_optmodule and luax_totype
--HG--
branch : dynamiccore2
2016-11-13 17:13:40 +01:00
Bart van Strien c761202486 Build type information on first use (load-time), instead of using a hardcoded list
--HG--
branch : dynamiccore2
2016-11-13 16:38:57 +01: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 ed933847f8 Color values in love's APIs are now in the range of [0, 1] rather than [0, 255].
--HG--
branch : minor
2016-01-31 10:49:29 -04:00
Alex Szpakowski 46a2e7b85c Happy new year! 🎉 2016-01-01 00:05:06 -04:00
Alex Szpakowski 20fb7f44df Cleaned up the code for love.math.random and related functions. 2015-12-10 13:09:54 -04:00
Alex Szpakowski 52b1bd78f2 Implemented LuaJIT FFI versions of love.math.random and RandomGenerator:random. 2015-12-10 12:45:53 -04:00
Alex Szpakowski 374d1ae0e1 Implemented LuaJIT FFI versions of love.math.noise, love.math.gammaToLinear, and love.math.linearToGamma.
The new versions of the functions are only used if LuaJIT's JIT compiler is enabled.

Those functions are often combined with ImageData:mapPixel or ImageData:setPixel, which also have LuaJIT FFI versions in 0.10.0 - so without JIT-able implementations of the math functions, the FFI code in the ImageData methods would not be JIT-compiled and would end up taking up to 10 times as long to execute compared to the non-FFI versions in 0.9.2.
2015-12-08 21:24:16 -04:00
Alex Szpakowski 004ffb8819 Fixed the build. 2015-12-07 23:14:27 -04:00
Alex Szpakowski e0dca60380 Cleaned up some code. 2015-12-07 23:01:52 -04:00
Alex Szpakowski d587c206f0 Added a new variant love.math.decompress(data, format), where data is any Data object. 2015-10-03 01:49:12 -03:00
Bart van Strien 3cb777e2b7 Add basic lua 5.3 support 2015-06-16 10:25:41 +02:00
Alex Szpakowski 0f986b10aa Cleaned up some code, the 'ry' parameter of love.graphics.rectangle now defaults to the value of 'rx' rather than defaulting to 0. 2015-05-27 17:36:27 -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 2f419c1c83 Replaced most cases of type bits and type name strings in love's Lua wrapper code with type id's.
--HG--
branch : minor
2015-03-01 18:32:41 -04:00
Alex Szpakowski ebc68023a7 Fix many warnings about implicit integer conversions when compiling for 64 bits.
--HG--
branch : minor
2015-02-20 01:20:08 -04:00
Alex Szpakowski 811f574ef6 Reference counting for love objects in 0.9.2 is now atomic (using SDL's atomic operation functions.) 2015-01-14 15:52:05 -04:00
Alex Szpakowski c7b45b3505 Updated copyright for the new year 2014-12-31 19:32:43 -04:00
Alex Szpakowski da7cd267ea Changed luax_pushtype to retain the pushed object itself, but only if the object isn't in the Lua state already.
Previously, calling e.g. love.graphics.getFont() 10,000 times would retain the object 10,000 times (and release it 10,000 times when the Font object was garbage-collected in the Lua state.) Now it will only retain it once and release it once.
2014-08-09 16:04:59 -03:00
Alex Szpakowski dfa319e01a Replaced the EXCEPT_GUARD macro for converting love exceptions into Lua errors with the new luax_catchexcept function, which takes lambda function arguments. 2014-06-03 19:27:00 -03:00
Alex Szpakowski 4faddcd9aa Fixed some trivial compiler warnings 2014-03-12 17:55:19 -03:00
Alex Szpakowski d07e31370d Added RandomGenerator:getState and RandomGenerator:setState (resolves issue #831.)
getState returns an implementation-dependent string representing the current state of the RandomGenerator's PRNG. setState sets the PRNG's state to an implementation-dependent string.
2014-02-08 20:28:41 -04: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 2ee869b0e8 Fixed some compiler warnings 2013-12-07 05:07:54 -04:00
Alex Szpakowski 1c8abc74aa Renamed love.math.g/setRandomState and rng:g/setState to love.math.g/setRandomSeed and rng:g/setSeed.
getRandomSeed now always returns the previously set random seed instead of the current (implementation-dependent) random state.
2013-12-01 21:25:27 -04:00
Alex Szpakowski 83d3eae1e7 Fixed error messages in Shader:send and love.math.newRandomGenerator to include the line number 2013-11-04 15:03:45 -04:00
Alex Szpakowski bcee9a222b Made some float/int/unsigned char conversions explicit, fixed ParticleSystem:getColors, fixed love.mouse.isDown with x1 and x2 buttons 2013-09-26 00:36:50 -03: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