Difference between revisions of "love.math.compress"

(Created page)
 
m
Line 5: Line 5:
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
compressedData = love.math.compress( rawstring, format )
+
compressedData = love.math.compress( rawstring, format, level )
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
 
{{param|string|rawstring|The raw (un-compressed) string to compress.}}
 
{{param|string|rawstring|The raw (un-compressed) string to compress.}}
 
{{param|CompressedDataFormat|format ("lz4")|The format to compress the string to.}}
 
{{param|CompressedDataFormat|format ("lz4")|The format to compress the string to.}}
 +
{{param|number|level|The level of compression to use, between 0 and 9. The meaning of this argument depends on the compression format being used.}}
 
=== Returns ===
 
=== Returns ===
 
{{param|CompressedData|compressedData|A new Data object containing the compressed version of the string.}}
 
{{param|CompressedData|compressedData|A new Data object containing the compressed version of the string.}}
Line 15: Line 16:
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
compressedData = love.math.compress( data, format )
+
compressedData = love.math.compress( data, format, level )
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
 
{{param|Data|data|A Data object containing the raw (un-compressed) data to compress.}}
 
{{param|Data|data|A Data object containing the raw (un-compressed) data to compress.}}
 
{{param|CompressedDataFormat|format ("lz4")|The format to compress the data to.}}
 
{{param|CompressedDataFormat|format ("lz4")|The format to compress the data to.}}
 +
{{param|number|level|The level of compression to use, between 0 and 9. The meaning of this argument depends on the compression format being used.}}
 
=== Returns ===
 
=== Returns ===
 
{{param|CompressedData|compressedData|A new Data object containing the compressed version of the raw data.}}
 
{{param|CompressedData|compressedData|A new Data object containing the compressed version of the raw data.}}

Revision as of 04:11, 3 October 2015

Available since LÖVE 0.10.0
This function is not supported in earlier versions.

Compresses a string or data using a specific compression algorithm.

O.png This function can be slow if it is called repeatedly, such as from love.update or love.draw. If you need to use a specific resource often, create it once and store it somewhere it can be reused!  



Function

Synopsis

compressedData = love.math.compress( rawstring, format, level )

Arguments

string rawstring
The raw (un-compressed) string to compress.
CompressedDataFormat format ("lz4")
The format to compress the string to.
number level
The level of compression to use, between 0 and 9. The meaning of this argument depends on the compression format being used.

Returns

CompressedData compressedData
A new Data object containing the compressed version of the string.

Function

Synopsis

compressedData = love.math.compress( data, format, level )

Arguments

Data data
A Data object containing the raw (un-compressed) data to compress.
CompressedDataFormat format ("lz4")
The format to compress the data to.
number level
The level of compression to use, between 0 and 9. The meaning of this argument depends on the compression format being used.

Returns

CompressedData compressedData
A new Data object containing the compressed version of the raw data.

See Also

Other Languages