parent
65d2c3fc6b
commit
0b872a0d8d
17
demo.lua
17
demo.lua
|
@ -11,6 +11,7 @@ file = io.open("output.py", "w")
|
|||
first = true
|
||||
pallet = {} --will store colors
|
||||
pallet_last = 1
|
||||
mem_pallet_last = 1
|
||||
|
||||
file:write([[from draw import *
|
||||
]])
|
||||
|
@ -27,9 +28,8 @@ for i = 1, 12, 1 do
|
|||
end
|
||||
local getpixel, setpixel = bitmap.pixel_interface(image_bitmap)
|
||||
|
||||
if first then
|
||||
file:write("width=", image_infos.width, "\n", [[data=b"]])
|
||||
end
|
||||
file:write("\n", [[data=b"]])
|
||||
--end
|
||||
|
||||
for j = 1, image_infos.height, 1 do
|
||||
for i = 1, image_infos.width, 1 do
|
||||
|
@ -41,18 +41,23 @@ for i = 1, 12, 1 do
|
|||
file:write(int_hex(pallet[r..","..g..","..b]))
|
||||
end
|
||||
end
|
||||
file:write('"')
|
||||
|
||||
--let's write the pallet
|
||||
if first then
|
||||
file:write("\"\npallet={")
|
||||
if pallet_last > mem_pallet_last then
|
||||
mem_pallet_last = pallet_last
|
||||
file:write("\npallet={")
|
||||
for i, v in pairs(pallet) do
|
||||
file:write(v, ":(", i, "),")
|
||||
end
|
||||
file:write("}")
|
||||
end
|
||||
|
||||
file:write("}\ndraw(", math.floor(192 - image_infos.width / 2), ",")
|
||||
file:write("\ndraw(", math.floor(192 - image_infos.width / 2), ",")
|
||||
file:write(math.floor(96 - image_infos.height / 2), ",data,pallet,")
|
||||
file:write(image_infos.width, ")")
|
||||
|
||||
first = false
|
||||
end
|
||||
|
||||
file:close()
|
||||
|
|
Loading…
Reference in New Issue