Small tweaks, added encode lib source files

This commit is contained in:
Mathias Westerdahl
2017-02-28 17:31:58 +01:00
parent fccebd8f6d
commit 3ae18c3b4c
14 changed files with 1761 additions and 25 deletions

View File

@@ -1,5 +1,7 @@
function init(self)
msg.post(".", "acquire_input_focus")
local logosize = 128
local screen_width = sys.get_config("display.width", 600)
local screen_height = sys.get_config("display.height", 800)
@@ -14,9 +16,11 @@ function init(self)
local quality = camera.CAPTURE_QUALITY_HIGH
local type = camera.CAMERA_TYPE_FRONT
self.flip = 0
if sysinfo.system_name == 'iPhone OS' then
type = camera.CAMERA_TYPE_BACK
quality = camera.CAPTURE_QUALITY_MEDIUM
self.flip = 1
end
if camera.start_capture(type, quality) then
@@ -30,6 +34,13 @@ function init(self)
type=resource.TEXTURE_TYPE_2D,
format=resource.TEXTURE_FORMAT_RGB,
num_mip_maps=1 }
self.debugtextureheader = {width=self.camerainfo.width,
height=self.camerainfo.height,
type=resource.TEXTURE_TYPE_2D,
format=resource.TEXTURE_FORMAT_RGB,
num_mip_maps=1 }
end
else
print("could not start camera capture")
@@ -46,20 +57,53 @@ function final(self)
end
end
local first = 1
function update(self, dt)
if first == 0 then
first = 1
local img = resource.load("/main/images/defold.png")
local text = qrcode.scan(self.cameraframe, self.camerainfo.width, self.camerainfo.height, img)
if text ~= nil then
label.set_text("logo#qrcode", text)
end
local path = go.get("logo#sprite", "texture0")
local image = qrcode.get_debug_image()
if image ~= nil then
resource.set_texture(path, self.debugtextureheader, image)
end
end
if self.cameraframe then
local pathmodelcamera = go.get("#sprite", "texture0")
resource.set_texture(pathmodelcamera, self.cameratextureheader, self.cameraframe)
local url = qrcode.scan(self.cameraframe, self.camerainfo.width, self.camerainfo.height)
local text = qrcode.scan(self.cameraframe, self.camerainfo.width, self.camerainfo.height, self.flip)
if url ~= nil then
label.set_text("logo#qrcode", url)
else
label.set_text("logo#qrcode", "...")
if text ~= nil then
label.set_text("logo#qrcode", text)
end
local path = go.get("logo#sprite", "texture0")
local image = qrcode.get_debug_image()
if image ~= nil then
resource.set_texture(path, self.debugtextureheader, image)
end
end
end
function on_input(self, action_id, action)
if action_id == hash("click") or action_id == hash("touch") then
pprint(action)
label.set_text("logo#qrcode", "...")
end
end

29
main/new_file.script Normal file
View File

@@ -0,0 +1,29 @@
function init(self)
-- Add initialization code here
-- Remove this function if not needed
end
function final(self)
-- Add finalization code here
-- Remove this function if not needed
end
function update(self, dt)
-- Add update code here
-- Remove this function if not needed
end
function on_message(self, message_id, message, sender)
-- Add message-handling code here
-- Remove this function if not needed
end
function on_input(self, action_id, action)
-- Add input-handling code here
-- Remove this function if not needed
end
function on_reload(self)
-- Add reload-handling code here
-- Remove this function if not needed
end