Cleanup of code, and added better example gui
This commit is contained in:
parent
c3c5167127
commit
2dd490557f
@ -1,8 +1,4 @@
|
||||
mouse_trigger {
|
||||
input: MOUSE_BUTTON_1
|
||||
action: "click"
|
||||
}
|
||||
touch_trigger {
|
||||
input: TOUCH_MULTI
|
||||
action: "touch"
|
||||
}
|
||||
|
BIN
main/images/camera.png
Normal file
BIN
main/images/camera.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
9
main/images/icons.atlas
Normal file
9
main/images/icons.atlas
Normal file
@ -0,0 +1,9 @@
|
||||
images {
|
||||
image: "/main/images/camera.png"
|
||||
}
|
||||
images {
|
||||
image: "/main/images/qrcode.png"
|
||||
}
|
||||
margin: 0
|
||||
extrude_borders: 0
|
||||
inner_padding: 0
|
BIN
main/images/qrcode.png
Normal file
BIN
main/images/qrcode.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
@ -1,7 +1,7 @@
|
||||
name: "main"
|
||||
scale_along_z: 0
|
||||
embedded_instances {
|
||||
id: "go"
|
||||
id: "controller"
|
||||
data: "components {\n"
|
||||
" id: \"script\"\n"
|
||||
" component: \"/main/main.script\"\n"
|
||||
@ -40,7 +40,7 @@ embedded_instances {
|
||||
""
|
||||
position {
|
||||
x: 480.0
|
||||
y: 640.0
|
||||
y: 772.055
|
||||
z: 0.0
|
||||
}
|
||||
rotation {
|
||||
@ -58,114 +58,6 @@ embedded_instances {
|
||||
embedded_instances {
|
||||
id: "logo"
|
||||
data: "embedded_components {\n"
|
||||
" id: \"label\"\n"
|
||||
" type: \"label\"\n"
|
||||
" data: \"size {\\n"
|
||||
" x: 128.0\\n"
|
||||
" y: 32.0\\n"
|
||||
" z: 0.0\\n"
|
||||
" w: 0.0\\n"
|
||||
"}\\n"
|
||||
"scale {\\n"
|
||||
" x: 1.0\\n"
|
||||
" y: 1.0\\n"
|
||||
" z: 1.0\\n"
|
||||
" w: 0.0\\n"
|
||||
"}\\n"
|
||||
"color {\\n"
|
||||
" x: 1.0\\n"
|
||||
" y: 1.0\\n"
|
||||
" z: 1.0\\n"
|
||||
" w: 1.0\\n"
|
||||
"}\\n"
|
||||
"outline {\\n"
|
||||
" x: 0.0\\n"
|
||||
" y: 0.0\\n"
|
||||
" z: 0.0\\n"
|
||||
" w: 1.0\\n"
|
||||
"}\\n"
|
||||
"shadow {\\n"
|
||||
" x: 0.0\\n"
|
||||
" y: 0.0\\n"
|
||||
" z: 0.0\\n"
|
||||
" w: 1.0\\n"
|
||||
"}\\n"
|
||||
"leading: 1.0\\n"
|
||||
"tracking: 0.0\\n"
|
||||
"pivot: PIVOT_E\\n"
|
||||
"blend_mode: BLEND_MODE_ALPHA\\n"
|
||||
"line_break: false\\n"
|
||||
"text: \\\"QRCode: \\\"\\n"
|
||||
"font: \\\"/dirtylarry/larryfont.font\\\"\\n"
|
||||
"material: \\\"/builtins/fonts/label-df.material\\\"\\n"
|
||||
"\"\n"
|
||||
" position {\n"
|
||||
" x: 200.54617\n"
|
||||
" y: 47.57482\n"
|
||||
" z: 0.0\n"
|
||||
" }\n"
|
||||
" rotation {\n"
|
||||
" x: 0.0\n"
|
||||
" y: 0.0\n"
|
||||
" z: 0.0\n"
|
||||
" w: 1.0\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"embedded_components {\n"
|
||||
" id: \"qrcode\"\n"
|
||||
" type: \"label\"\n"
|
||||
" data: \"size {\\n"
|
||||
" x: 128.0\\n"
|
||||
" y: 32.0\\n"
|
||||
" z: 0.0\\n"
|
||||
" w: 0.0\\n"
|
||||
"}\\n"
|
||||
"scale {\\n"
|
||||
" x: 1.0\\n"
|
||||
" y: 1.0\\n"
|
||||
" z: 1.0\\n"
|
||||
" w: 0.0\\n"
|
||||
"}\\n"
|
||||
"color {\\n"
|
||||
" x: 1.0\\n"
|
||||
" y: 1.0\\n"
|
||||
" z: 1.0\\n"
|
||||
" w: 1.0\\n"
|
||||
"}\\n"
|
||||
"outline {\\n"
|
||||
" x: 0.0\\n"
|
||||
" y: 0.0\\n"
|
||||
" z: 0.0\\n"
|
||||
" w: 1.0\\n"
|
||||
"}\\n"
|
||||
"shadow {\\n"
|
||||
" x: 0.0\\n"
|
||||
" y: 0.0\\n"
|
||||
" z: 0.0\\n"
|
||||
" w: 1.0\\n"
|
||||
"}\\n"
|
||||
"leading: 1.0\\n"
|
||||
"tracking: 0.0\\n"
|
||||
"pivot: PIVOT_NW\\n"
|
||||
"blend_mode: BLEND_MODE_ALPHA\\n"
|
||||
"line_break: true\\n"
|
||||
"text: \\\"...\\\"\\n"
|
||||
"font: \\\"/dirtylarry/larryfont.font\\\"\\n"
|
||||
"material: \\\"/builtins/fonts/label-df.material\\\"\\n"
|
||||
"\"\n"
|
||||
" position {\n"
|
||||
" x: 73.19203\n"
|
||||
" y: 21.95761\n"
|
||||
" z: 0.0\n"
|
||||
" }\n"
|
||||
" rotation {\n"
|
||||
" x: 0.0\n"
|
||||
" y: 0.0\n"
|
||||
" z: 0.0\n"
|
||||
" w: 1.0\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"embedded_components {\n"
|
||||
" id: \"sprite\"\n"
|
||||
" type: \"sprite\"\n"
|
||||
" data: \"tile_set: \\\"/main/logo.atlas\\\"\\n"
|
||||
@ -203,3 +95,38 @@ embedded_instances {
|
||||
z: 1.0
|
||||
}
|
||||
}
|
||||
embedded_instances {
|
||||
id: "gui"
|
||||
data: "components {\n"
|
||||
" id: \"main\"\n"
|
||||
" component: \"/main/main.gui\"\n"
|
||||
" position {\n"
|
||||
" x: 0.0\n"
|
||||
" y: 0.0\n"
|
||||
" z: 0.0\n"
|
||||
" }\n"
|
||||
" rotation {\n"
|
||||
" x: 0.0\n"
|
||||
" y: 0.0\n"
|
||||
" z: 0.0\n"
|
||||
" w: 1.0\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
""
|
||||
position {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale3 {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
}
|
||||
}
|
||||
|
943
main/main.gui
Normal file
943
main/main.gui
Normal file
@ -0,0 +1,943 @@
|
||||
script: "/main/main.gui_script"
|
||||
fonts {
|
||||
name: "larryfont"
|
||||
font: "/dirtylarry/larryfont.font"
|
||||
}
|
||||
textures {
|
||||
name: "icons"
|
||||
texture: "/main/images/icons.atlas"
|
||||
}
|
||||
textures {
|
||||
name: "camera"
|
||||
texture: "/main/camera.atlas"
|
||||
}
|
||||
background_color {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 0.0
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 474.796
|
||||
y: 606.683
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 64.0
|
||||
y: 64.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 0.101960786
|
||||
y: 0.101960786
|
||||
z: 0.101960786
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
texture: ""
|
||||
id: "background"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 0.0
|
||||
}
|
||||
clipping_mode: CLIPPING_MODE_NONE
|
||||
clipping_visible: true
|
||||
clipping_inverted: false
|
||||
alpha: 1.0
|
||||
template_node_child: false
|
||||
size_mode: SIZE_MODE_MANUAL
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 178.793
|
||||
y: 1190.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 200.0
|
||||
y: 100.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_TEMPLATE
|
||||
id: "scan_bn"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
alpha: 1.0
|
||||
template: "/dirtylarry/button.gui"
|
||||
template_node_child: false
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 300.0
|
||||
y: 88.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
texture: "button/button_normal"
|
||||
id: "scan_bn/larrybutton"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
parent: "scan_bn"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 32.0
|
||||
y: 32.0
|
||||
z: 32.0
|
||||
w: 32.0
|
||||
}
|
||||
clipping_mode: CLIPPING_MODE_NONE
|
||||
clipping_visible: true
|
||||
clipping_inverted: false
|
||||
alpha: 1.0
|
||||
template_node_child: true
|
||||
size_mode: SIZE_MODE_MANUAL
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: -34.921
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 200.0
|
||||
y: 100.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_TEXT
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
text: "Scan\n"
|
||||
""
|
||||
font: "larryfont"
|
||||
id: "scan_bn/larrylabel"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
outline {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
shadow {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
line_break: false
|
||||
parent: "scan_bn/larrybutton"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
alpha: 1.0
|
||||
outline_alpha: 1.0
|
||||
shadow_alpha: 1.0
|
||||
overridden_fields: 1
|
||||
overridden_fields: 8
|
||||
template_node_child: true
|
||||
text_leading: 1.0
|
||||
text_tracking: 0.0
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 780.0
|
||||
y: 1190.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 200.0
|
||||
y: 100.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_TEMPLATE
|
||||
id: "generate_bn"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
alpha: 1.0
|
||||
template: "/dirtylarry/button.gui"
|
||||
template_node_child: false
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 300.0
|
||||
y: 88.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
texture: "button/button_normal"
|
||||
id: "generate_bn/larrybutton"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
parent: "generate_bn"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 32.0
|
||||
y: 32.0
|
||||
z: 32.0
|
||||
w: 32.0
|
||||
}
|
||||
clipping_mode: CLIPPING_MODE_NONE
|
||||
clipping_visible: true
|
||||
clipping_inverted: false
|
||||
alpha: 1.0
|
||||
template_node_child: true
|
||||
size_mode: SIZE_MODE_MANUAL
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: -30.73
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 200.0
|
||||
y: 100.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_TEXT
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
text: "QRCode"
|
||||
font: "larryfont"
|
||||
id: "generate_bn/larrylabel"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
outline {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
shadow {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
line_break: false
|
||||
parent: "generate_bn/larrybutton"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
alpha: 1.0
|
||||
outline_alpha: 1.0
|
||||
shadow_alpha: 1.0
|
||||
overridden_fields: 1
|
||||
overridden_fields: 8
|
||||
template_node_child: true
|
||||
text_leading: 1.0
|
||||
text_tracking: 0.0
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 243.047
|
||||
y: 1190.751
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 0.25
|
||||
y: 0.25
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 256.0
|
||||
y: 256.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
texture: "icons/camera"
|
||||
id: "camera_icon"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 0.0
|
||||
}
|
||||
clipping_mode: CLIPPING_MODE_NONE
|
||||
clipping_visible: true
|
||||
clipping_inverted: false
|
||||
alpha: 1.0
|
||||
template_node_child: false
|
||||
size_mode: SIZE_MODE_AUTO
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 866.031
|
||||
y: 1190.751
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 0.25
|
||||
y: 0.25
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 256.0
|
||||
y: 256.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
texture: "icons/qrcode"
|
||||
id: "camera_icon1"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 0.0
|
||||
}
|
||||
clipping_mode: CLIPPING_MODE_NONE
|
||||
clipping_visible: true
|
||||
clipping_inverted: false
|
||||
alpha: 1.0
|
||||
template_node_child: false
|
||||
size_mode: SIZE_MODE_AUTO
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 476.318
|
||||
y: 811.556
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 100.0
|
||||
y: 100.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
texture: "camera/logo"
|
||||
id: "camera"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 0.0
|
||||
}
|
||||
clipping_mode: CLIPPING_MODE_NONE
|
||||
clipping_visible: true
|
||||
clipping_inverted: false
|
||||
alpha: 1.0
|
||||
template_node_child: false
|
||||
size_mode: SIZE_MODE_MANUAL
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 476.318
|
||||
y: 811.556
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 100.0
|
||||
y: 100.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
texture: "camera/logo"
|
||||
id: "qrcode"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 0.0
|
||||
}
|
||||
clipping_mode: CLIPPING_MODE_NONE
|
||||
clipping_visible: true
|
||||
clipping_inverted: false
|
||||
alpha: 1.0
|
||||
template_node_child: false
|
||||
size_mode: SIZE_MODE_MANUAL
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 124.016
|
||||
y: 181.747
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 200.0
|
||||
y: 100.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_TEMPLATE
|
||||
id: "url"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
alpha: 1.0
|
||||
template: "/dirtylarry/input.gui"
|
||||
template_node_child: false
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: -43.71
|
||||
y: -68.422
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 800.0
|
||||
y: 72.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
texture: "button/button_pressed"
|
||||
id: "url/bg"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_W
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
parent: "url"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 32.0
|
||||
y: 32.0
|
||||
z: 32.0
|
||||
w: 32.0
|
||||
}
|
||||
clipping_mode: CLIPPING_MODE_NONE
|
||||
clipping_visible: true
|
||||
clipping_inverted: false
|
||||
alpha: 1.0
|
||||
overridden_fields: 1
|
||||
overridden_fields: 4
|
||||
template_node_child: true
|
||||
size_mode: SIZE_MODE_MANUAL
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 13.0
|
||||
y: 3.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 0.0
|
||||
y: 32.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 0.18431373
|
||||
y: 0.18431373
|
||||
z: 0.18431373
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
texture: ""
|
||||
id: "url/inner"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_W
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
parent: "url/bg"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 0.0
|
||||
}
|
||||
clipping_mode: CLIPPING_MODE_STENCIL
|
||||
clipping_visible: true
|
||||
clipping_inverted: false
|
||||
alpha: 0.0
|
||||
template_node_child: true
|
||||
size_mode: SIZE_MODE_MANUAL
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 8.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 0.0
|
||||
y: 48.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 0.3254902
|
||||
y: 0.6666667
|
||||
z: 0.9960785
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
texture: ""
|
||||
id: "url/cursor"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_W
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
parent: "url/inner"
|
||||
layer: ""
|
||||
inherit_alpha: false
|
||||
slice9 {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 0.0
|
||||
}
|
||||
clipping_mode: CLIPPING_MODE_NONE
|
||||
clipping_visible: true
|
||||
clipping_inverted: false
|
||||
alpha: 1.0
|
||||
template_node_child: true
|
||||
size_mode: SIZE_MODE_MANUAL
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 4.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 200.0
|
||||
y: 32.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_TEXT
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
text: ""
|
||||
font: "larryfont"
|
||||
id: "url/content"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_W
|
||||
outline {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
shadow {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
line_break: false
|
||||
parent: "url/inner"
|
||||
layer: ""
|
||||
inherit_alpha: false
|
||||
alpha: 1.0
|
||||
outline_alpha: 1.0
|
||||
shadow_alpha: 1.0
|
||||
overridden_fields: 8
|
||||
template_node_child: true
|
||||
text_leading: 1.0
|
||||
text_tracking: 0.0
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 96.219
|
||||
y: 113.325
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 200.0
|
||||
y: 100.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_TEXT
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
text: ""
|
||||
font: "larryfont"
|
||||
id: "text"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_W
|
||||
outline {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
shadow {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
line_break: false
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
alpha: 1.0
|
||||
outline_alpha: 1.0
|
||||
shadow_alpha: 1.0
|
||||
template_node_child: false
|
||||
text_leading: 1.0
|
||||
text_tracking: 0.0
|
||||
}
|
||||
material: "/builtins/materials/gui.material"
|
||||
adjust_reference: ADJUST_REFERENCE_PARENT
|
||||
max_nodes: 512
|
76
main/main.gui_script
Normal file
76
main/main.gui_script
Normal file
@ -0,0 +1,76 @@
|
||||
local dirtylarry = require "dirtylarry/dirtylarry"
|
||||
|
||||
function init(self)
|
||||
msg.post(".", "acquire_input_focus")
|
||||
|
||||
local logosize = 256
|
||||
local screen_width = sys.get_config("display.width", 600)
|
||||
local screen_height = sys.get_config("display.height", 800)
|
||||
local scale_width = screen_width / logosize
|
||||
local scale_height = screen_height / logosize
|
||||
|
||||
local bg = gui.get_node("background")
|
||||
gui.set_position(bg, vmath.vector3(screen_width/2, screen_height/2, 0))
|
||||
gui.set_size(bg, vmath.vector3(screen_width, screen_height, 0))
|
||||
|
||||
local camera = gui.get_node("camera")
|
||||
gui.set_position(camera, vmath.vector3(screen_width/2, screen_height/2, 0))
|
||||
gui.set_size(camera, vmath.vector3(screen_width/2, screen_height/2, 0))
|
||||
|
||||
local qrcode = gui.get_node("qrcode")
|
||||
gui.set_position(qrcode, vmath.vector3(screen_width/2, screen_height/2, 0))
|
||||
gui.set_size(qrcode, vmath.vector3(screen_width/2, screen_height/2, 0))
|
||||
|
||||
local n = gui.get_node("scan_bn/larrylabel")
|
||||
self.scan_label_pos = gui.get_position(n)
|
||||
|
||||
n = gui.get_node("generate_bn/larrylabel")
|
||||
self.generate_label_pos = gui.get_position(n)
|
||||
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
|
||||
|
||||
local function set_text(self, text)
|
||||
local n = gui.get_node("text")
|
||||
gui.set_text(n, text)
|
||||
end
|
||||
|
||||
function on_message(self, message_id, message, sender)
|
||||
if message_id == hash("set_text") then
|
||||
set_text(self, message.text)
|
||||
end
|
||||
end
|
||||
|
||||
local function isempty(s)
|
||||
return s == nil or s == ''
|
||||
end
|
||||
|
||||
function on_input(self, action_id, action)
|
||||
dirtylarry:button("scan_bn", action_id, action, function ()
|
||||
msg.post("controller", "click", {mode="SCAN"})
|
||||
end)
|
||||
dirtylarry:button("generate_bn", action_id, action, function ()
|
||||
local text = sys.get_sys_info().device_ident
|
||||
if isempty(text) then
|
||||
text = "DEFOLD RULES!"
|
||||
end
|
||||
set_text(self, text)
|
||||
msg.post("controller", "click", {mode="GENERATE", text=text})
|
||||
end)
|
||||
|
||||
-- for some reason, the text recenters, and I don't want that
|
||||
local n = gui.get_node("scan_bn/larrylabel")
|
||||
gui.set_position(n, self.scan_label_pos)
|
||||
|
||||
n = gui.get_node("generate_bn/larrylabel")
|
||||
gui.set_position(n, self.generate_label_pos)
|
||||
end
|
||||
|
153
main/main.script
153
main/main.script
@ -1,19 +1,9 @@
|
||||
|
||||
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)
|
||||
local scale_width = screen_width / logosize
|
||||
local scale_height = screen_height / logosize
|
||||
|
||||
go.set("#sprite", "scale", vmath.vector3(scale_width, scale_height, 1) )
|
||||
|
||||
local function start_scan(self)
|
||||
if camera ~= nil then
|
||||
|
||||
local sysinfo = sys.get_sys_info()
|
||||
|
||||
|
||||
local quality = camera.CAPTURE_QUALITY_HIGH
|
||||
local type = camera.CAMERA_TYPE_FRONT
|
||||
self.flip = 0
|
||||
@ -22,88 +12,105 @@ function init(self)
|
||||
quality = camera.CAPTURE_QUALITY_MEDIUM
|
||||
self.flip = 1
|
||||
end
|
||||
|
||||
|
||||
if camera.start_capture(type, quality) then
|
||||
self.cameraframe = camera.get_frame()
|
||||
self.camerainfo = camera.get_info()
|
||||
print("Initialized camera")
|
||||
pprint(self.camerainfo)
|
||||
|
||||
self.cameratextureheader = {width=self.camerainfo.width,
|
||||
height=self.camerainfo.height,
|
||||
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 }
|
||||
self.cameraframe = camera.get_frame()
|
||||
self.camerainfo = camera.get_info()
|
||||
print("Initialized camera")
|
||||
self.cameratextureheader = {width=self.camerainfo.width,
|
||||
height=self.camerainfo.height,
|
||||
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")
|
||||
end
|
||||
end
|
||||
|
||||
local function end_scan(self)
|
||||
if self.cameraframe ~= nil then
|
||||
self.cameraframe = nil
|
||||
camera.stop_capture()
|
||||
self.first = 0
|
||||
end
|
||||
end
|
||||
|
||||
local function update_scan(self)
|
||||
|
||||
if self.cameraframe ~= nil then
|
||||
local pathmodelcamera = go.get("#sprite", "texture0")
|
||||
resource.set_texture(pathmodelcamera, self.cameratextureheader, self.cameraframe)
|
||||
|
||||
local text = qrcode.scan(self.cameraframe, self.camerainfo.width, self.camerainfo.height, self.flip)
|
||||
|
||||
if text ~= nil then
|
||||
msg.post("gui", "set_text", {text=text})
|
||||
end_scan(self)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function generate_qrcode(self, text)
|
||||
--self.qrcode =
|
||||
end
|
||||
|
||||
function init(self)
|
||||
local logosize = 256
|
||||
local screen_width = sys.get_config("display.width", 600)
|
||||
local screen_height = sys.get_config("display.height", 800)
|
||||
local scale_width = screen_width / logosize
|
||||
local scale_height = screen_height / logosize
|
||||
|
||||
go.set("#sprite", "scale", vmath.vector3(scale_width, scale_height, 1) )
|
||||
|
||||
start_scan(self)
|
||||
|
||||
if qrcode == nil then
|
||||
print("could not find qrcode module")
|
||||
end
|
||||
|
||||
self.mode = "SCAN"
|
||||
end
|
||||
|
||||
function final(self)
|
||||
if self.cameraframe ~= nil then
|
||||
camera.stop_capture()
|
||||
end
|
||||
end_scan(self)
|
||||
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 text = qrcode.scan(self.cameraframe, self.camerainfo.width, self.camerainfo.height, self.flip)
|
||||
|
||||
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.mode == "SCAN" then
|
||||
update_scan(self)
|
||||
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", "...")
|
||||
--pprint(action)
|
||||
--label.set_text("logo#qrcode", "...")
|
||||
print("foo")
|
||||
end
|
||||
end
|
||||
|
||||
function on_message(self, message_id, message)
|
||||
if self.mode ~= message.mode then
|
||||
if message.mode == "SCAN" then
|
||||
start_scan(self)
|
||||
|
||||
pprint(self.cameraframe)
|
||||
else
|
||||
end_scan(self)
|
||||
generate_qrcode(self)
|
||||
end
|
||||
self.mode = message.mode
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
@ -30,11 +30,6 @@ struct QRCodeContext
|
||||
|
||||
QRCodeContext g_QRContext;
|
||||
|
||||
uint8_t* g_DebugPixels = 0;
|
||||
uint32_t g_DebugWidth = 0;
|
||||
uint32_t g_DebugHeight = 0;
|
||||
|
||||
|
||||
static int Scan(lua_State* L)
|
||||
{
|
||||
DM_LUA_STACK_CHECK(L, 1);
|
||||
@ -44,105 +39,50 @@ static int Scan(lua_State* L)
|
||||
int height = luaL_checkint(L, 3);
|
||||
int flip = luaL_checkint(L, 4);
|
||||
|
||||
struct quirc *qr;
|
||||
struct quirc* qr;
|
||||
|
||||
qr = quirc_new();
|
||||
if (!qr) {
|
||||
return luaL_error(L, "qrcode.scan: Failed to allocate memory");
|
||||
}
|
||||
|
||||
uint8_t* filedata = 0;
|
||||
// if( dmScript::IsBuffer(L, 4) )
|
||||
// {
|
||||
// dmBuffer::HBuffer* buffer2 = dmScript::CheckBuffer(L, 4);
|
||||
|
||||
// uint8_t* file;
|
||||
// uint32_t filesize;
|
||||
// dmBuffer::GetBytes(*buffer2, (void**)&file, &filesize);
|
||||
|
||||
// int x,y,n;
|
||||
// //filedata = Xstbi_load("/Users/mathiaswesterdahl/work/external/quirc/defold.png", &x, &y, &n, 0);
|
||||
// filedata = Xstbi_load_from_memory(file, filesize, &x, &y, &n, 0);
|
||||
// if( filedata )
|
||||
// {
|
||||
// width = x;
|
||||
// height = y;
|
||||
// }
|
||||
// printf("filedata: %p %d %d %d\n", filedata, width, height, n);
|
||||
// }
|
||||
|
||||
|
||||
if (quirc_resize(qr, width, height) < 0) {
|
||||
return luaL_error(L, "qrcode.scan: Failed to allocate video memory");
|
||||
}
|
||||
|
||||
uint8_t* image = quirc_begin(qr, &width, &height);
|
||||
|
||||
if( filedata )
|
||||
uint8_t* data;
|
||||
uint32_t datasize;
|
||||
dmBuffer::GetBytes(buffer->m_Buffer, (void**)&data, &datasize);
|
||||
|
||||
// Make it grey scale
|
||||
for( int y = 0; y < height; ++y )
|
||||
{
|
||||
for( int y = 0; y < height; ++y )
|
||||
for( int x = 0; x < width; ++x )
|
||||
{
|
||||
for( int x = 0; x < width; ++x )
|
||||
float r = (float)data[y * width * 3 + x * 3 + 0] / 255.0f;
|
||||
float g = (float)data[y * width * 3 + x * 3 + 1] / 255.0f;
|
||||
float b = (float)data[y * width * 3 + x * 3 + 2] / 255.0f;
|
||||
|
||||
float value = (r+g+b)/3.0f;
|
||||
|
||||
value = value*value;
|
||||
value += 0.1f;
|
||||
if(value>1.0f)
|
||||
{
|
||||
image[y * width + x] = filedata[y * width * 3 + x * 3];
|
||||
value = 1.0f;
|
||||
}
|
||||
|
||||
if( flip == 0 )
|
||||
image[y * width + x] = (uint8_t)(value * 255.0f);
|
||||
else
|
||||
image[y * width + (width - x - 1)] = (uint8_t)(value * 255.0f);
|
||||
}
|
||||
|
||||
free(filedata);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t* data;
|
||||
uint32_t datasize;
|
||||
dmBuffer::GetBytes(buffer->m_Buffer, (void**)&data, &datasize);
|
||||
|
||||
for( int y = 0; y < height; ++y )
|
||||
{
|
||||
for( int x = 0; x < width; ++x )
|
||||
{
|
||||
float r = (float)data[y * width * 3 + x * 3 + 0] / 255.0f;
|
||||
float g = (float)data[y * width * 3 + x * 3 + 1] / 255.0f;
|
||||
float b = (float)data[y * width * 3 + x * 3 + 2] / 255.0f;
|
||||
|
||||
float value = (r+g+b)/3.0f;
|
||||
|
||||
value = value*value;
|
||||
value += 0.1f;
|
||||
if(value>1.0f)
|
||||
{
|
||||
value = 1.0f;
|
||||
}
|
||||
|
||||
if( flip == 0 )
|
||||
image[y * width + x] = (uint8_t)(value * 255.0f);
|
||||
else
|
||||
image[y * width + (width - x - 1)] = (uint8_t)(value * 255.0f);
|
||||
//image[y * width + x] = data[y * width * 3 + x * 3];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if( g_DebugPixels != 0 )
|
||||
{
|
||||
free(g_DebugPixels);
|
||||
}
|
||||
g_DebugWidth = width;
|
||||
g_DebugHeight = height;
|
||||
g_DebugPixels = (uint8_t*)malloc( width * height * 3 );
|
||||
for( int i = 0; i < width * height; ++i )
|
||||
{
|
||||
g_DebugPixels[i*3 + 0] = image[i];
|
||||
g_DebugPixels[i*3 + 1] = image[i];
|
||||
g_DebugPixels[i*3 + 2] = image[i];
|
||||
}
|
||||
|
||||
|
||||
quirc_end(qr);
|
||||
|
||||
|
||||
//stbi_write_png("/Users/mathiaswesterdahl/work/external/quirc/test.png", width, height, 1, image, width);
|
||||
//printf("Wrote: /Users/mathiaswesterdahl/work/external/quirc/test.png\n");
|
||||
|
||||
int num_codes = quirc_count(qr);
|
||||
for( int i = 0; i < num_codes; i++)
|
||||
{
|
||||
@ -154,13 +94,10 @@ static int Scan(lua_State* L)
|
||||
quirc_decode_error_t err = quirc_decode(&code, &data);
|
||||
if (err)
|
||||
{
|
||||
printf("qrcode.scan: quirc decode error: %s\n", quirc_strerror(err));
|
||||
num_codes = 0;
|
||||
//return luaL_error(L, "qrcode.scan: quirc decode error: %s\n", quirc_strerror(err));
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Data: %s\n", data.payload);
|
||||
lua_pushstring(L, (const char*)data.payload);
|
||||
}
|
||||
break;
|
||||
@ -173,42 +110,23 @@ static int Scan(lua_State* L)
|
||||
lua_pushnil(L);
|
||||
}
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int GetDebugImage(lua_State* L)
|
||||
static int Generate(lua_State* L)
|
||||
{
|
||||
DM_LUA_STACK_CHECK(L, 1);
|
||||
|
||||
const dmBuffer::StreamDeclaration streams_decl[] = {
|
||||
{dmHashString64("rgb"), dmBuffer::VALUE_TYPE_UINT8, 3},
|
||||
};
|
||||
|
||||
dmBuffer::HBuffer buffer;
|
||||
dmBuffer::Result r = dmBuffer::Create(g_DebugWidth*g_DebugHeight, streams_decl, 1, &buffer);
|
||||
if (r != dmBuffer::RESULT_OK)
|
||||
{
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t* data;
|
||||
uint32_t datasize;
|
||||
dmBuffer::GetBytes(buffer, (void**)&data, &datasize);
|
||||
|
||||
memcpy(data, g_DebugPixels, datasize);
|
||||
|
||||
dmScript::LuaHBuffer luabuf = { buffer, true };
|
||||
PushBuffer(L, luabuf);
|
||||
|
||||
return 1;
|
||||
dmScript::LuaHBuffer* buffer = dmScript::CheckBuffer(L, 1);
|
||||
int width = luaL_checkint(L, 2);
|
||||
int height = luaL_checkint(L, 3);
|
||||
int flip = luaL_checkint(L, 4);
|
||||
}
|
||||
|
||||
static const luaL_reg Module_methods[] =
|
||||
{
|
||||
{"scan", Scan},
|
||||
{"get_debug_image", GetDebugImage},
|
||||
{"generate", Generate},
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user