Compress/decompress and Encode/Decode DataBase64.
This commit is contained in:
43
examples/compress_data/main.lua
Normal file
43
examples/compress_data/main.lua
Normal file
@@ -0,0 +1,43 @@
|
||||
local textColor = RL.BLACK
|
||||
local text = "Put data here"
|
||||
local deCompressedText = ""
|
||||
local editMode = false
|
||||
|
||||
function RL.init()
|
||||
RL.SetWindowTitle( "Buffer" )
|
||||
RL.SetWindowState( RL.FLAG_VSYNC_HINT )
|
||||
end
|
||||
|
||||
local function compressDecompressData()
|
||||
local strT = {}
|
||||
|
||||
for i = 1, #text do
|
||||
table.insert( strT, string.byte( text:sub( i, i ) ) )
|
||||
end
|
||||
|
||||
local strBuffer = RL.LoadBuffer( strT, RL.BUFFER_UNSIGNED_CHAR )
|
||||
local compBuffer = RL.CompressData( strBuffer )
|
||||
local deCompBuffer = RL.DecompressData( compBuffer )
|
||||
|
||||
deCompressedText = ""
|
||||
|
||||
for _, c in ipairs( RL.GetBufferData( deCompBuffer ) ) do
|
||||
deCompressedText = deCompressedText..string.char( c )
|
||||
end
|
||||
end
|
||||
|
||||
function RL.draw()
|
||||
RL.ClearBackground( RL.RAYWHITE )
|
||||
RL.DrawText( "Decompressed text: "..deCompressedText, { 20, 200 }, 20, textColor )
|
||||
|
||||
if RL.GuiButton( { 20, 20, 168, 32 }, "Compress/Decompress Data" ) then
|
||||
compressDecompressData()
|
||||
end
|
||||
|
||||
local pressed = false
|
||||
pressed, text = RL.GuiTextBox( { 220, 20, 400, 32 }, text, 64, editMode )
|
||||
|
||||
if pressed then
|
||||
editMode = not editMode
|
||||
end
|
||||
end
|
||||
@@ -9,13 +9,12 @@ local TILE_SIZE = 32
|
||||
|
||||
local monitor = 0
|
||||
local camera = {}
|
||||
local groundRenderTexture = -1
|
||||
local groundTexture = -1
|
||||
local tilesetTex = -1
|
||||
local heigthImage = -1
|
||||
local mesh = -1
|
||||
local material = -1
|
||||
local lightmap = -1
|
||||
local groundRenderTexture = nil
|
||||
local groundTexture = nil
|
||||
local tilesetTex = nil
|
||||
local heigthImage = nil
|
||||
local mesh = nil
|
||||
local material = nil
|
||||
|
||||
local grassRec = { 6 * TILE_SIZE, 0 * TILE_SIZE, TILE_SIZE, TILE_SIZE }
|
||||
local dirtRec = { 4 * TILE_SIZE, 0 * TILE_SIZE, TILE_SIZE, TILE_SIZE }
|
||||
@@ -77,8 +76,6 @@ function RL.init()
|
||||
RL.EndTextureMode()
|
||||
|
||||
material = RL.LoadMaterialDefault()
|
||||
-- RL.GenTextureMipmaps( groundTexture )
|
||||
-- RL.SetTextureFilter( groundTexture, RL.TEXTURE_FILTER_TRILINEAR )
|
||||
RL.SetMaterialTexture( material, RL.MATERIAL_MAP_ALBEDO, groundTexture )
|
||||
|
||||
matrix = RL.MatrixMultiply( RL.MatrixIdentity(), RL.MatrixTranslate( { -4, 0, -4 } ) )
|
||||
@@ -101,6 +98,5 @@ function RL.draw()
|
||||
|
||||
camera:beginMode3D()
|
||||
RL.DrawMesh( mesh, material, matrix )
|
||||
-- camera:draw()
|
||||
camera:endMode3D()
|
||||
end
|
||||
|
||||
@@ -822,6 +822,14 @@ function Container:delete()
|
||||
Gui.delete( self )
|
||||
end
|
||||
|
||||
function Container:clear()
|
||||
for _, cell in ipairs( self.cells ) do
|
||||
cell:delete()
|
||||
end
|
||||
|
||||
self.cells = {}
|
||||
end
|
||||
|
||||
function Container:set2Top()
|
||||
Gui.set2Top( self )
|
||||
|
||||
|
||||
@@ -146,6 +146,13 @@ function utillib.printt( t )
|
||||
print( "}" )
|
||||
end
|
||||
|
||||
function utillib.colorLerp( a, b, f )
|
||||
return {
|
||||
utillib.round( utillib.lerp( a[1], b[1], f ) ),
|
||||
utillib.round( utillib.lerp( a[2], b[2], f ) ),
|
||||
utillib.round( utillib.lerp( a[3], b[3], f ) ) }
|
||||
end
|
||||
|
||||
-- Move secuence of elements inside table.
|
||||
function utillib.tableMove( t, src, len, dest )
|
||||
local copy = table.move( t, src, src + len - 1, 1, {} )
|
||||
|
||||
Reference in New Issue
Block a user