ImageTransparencyCalculator - Check sprite on click

I made a few more optimizations, the changes are available on the github.
Please update those using large images.
Large image data takes a while to initialize. There are no lags with click detection, only with initializations.

Comparison made by @russelkgd

Loading time.
Before: 0.65s
After: 0.28

The size of the generated data
Decreased by 30-35%

If you generate large images and generating data takes time, you can use this code and do not generate data again
It must be put into the init function once (check_click.lua), the data in the new format will appear in the new_generated_data folder.

code
local str_begin = "/generated_data/"
for k, v in pairs(init_list) do
		local loaded_data = sys_load_resource(str_begin..v..".data")
		if loaded_data then
			loaded_data = zlib_inflate(loaded_data)

                        -- Should be executed once and then removed:
			local file = io.open("new_generated_data/"..v..".data", "wb")
			local new_data = string.gsub(loaded_data, "255", "1")
			file:write(zlib.deflate(new_data))
			file:close()
6 Likes