FBDRJ53NJ5BWDQGU2GWZ6NEYHKCCRD7RODMIG7QQZBRFUB4HR7OAC
to_text = function(x,y)
for _,node in ipairs(Surface) do
if node.type == 'text' then
if x >= vx(node.x) and node.w and x < vx(node.x + node.w) then
if y >= vy(node.y) and node.h and y < vy(node.y + node.h) then
return node
end
end
end
end
end
{"to_text":180,"on.mouse_pressed":179,"on.mouse_released":178,"initialize_editor":74,"box_height":44,"on.keychord_pressed":176,"on":1,"on.textinput":177,"font":104,"on.code_changed":140,"parent":179,"Surface":165,"on.draw":162,"vx":5,"Page":111,"Viewport":29,"compute_layout":157,"scale":7,"vy":8,"Cursor_node":172,"on.update":14}
on.mouse_pressed = function(x,y, mouse_button)
if Cursor_node then
Cursor_node.show_cursor = nil
Cursor_node = nil
end
local node = to_text(x,y)
if node then
Cursor_node = node
edit.mouse_pressed(node.editor, x,y, mouse_button)
else
Pan = {x=Viewport.x+x,y=Viewport.y+y}
end
end
{"Surface":165,"to_text":168,"on.code_changed":140,"vx":5,"on":1,"Viewport":29,"on.textinput":177,"vy":8,"on.mouse_pressed":179,"on.mouse_released":178,"on.update":14,"on.keychord_pressed":176,"Cursor_node":172,"on.draw":162,"initialize_editor":74,"box_height":44,"scale":7,"compute_layout":157,"Page":111,"font":104,"parent":178}
on.mouse_released = function(x,y, mouse_button)
if Pan then
Pan = nil
elseif Cursor_node then
Cursor_node.show_cursor = true
edit.mouse_released(Cursor_node.editor, x,y, mouse_button)
end
end
{"Surface":165,"to_text":168,"on.code_changed":140,"vx":5,"on":1,"Viewport":29,"on.textinput":177,"vy":8,"on.mouse_pressed":174,"on.mouse_released":178,"on.update":14,"on.keychord_pressed":176,"Cursor_node":172,"on.draw":162,"initialize_editor":74,"box_height":44,"scale":7,"compute_layout":157,"Page":111,"font":104,"parent":177}
on.textinput = function(t)
if Cursor_node then
edit.textinput(Cursor_node.editor, t)
end
end
{"Surface":165,"to_text":168,"on.code_changed":140,"vx":5,"on":1,"Viewport":29,"on.textinput":177,"vy":8,"on.mouse_pressed":174,"on.mouse_released":175,"on.update":14,"on.keychord_pressed":176,"Cursor_node":172,"on.draw":162,"initialize_editor":74,"box_height":44,"scale":7,"compute_layout":157,"Page":111,"font":104,"parent":176}
on.keychord_pressed = function(chord, key)
if chord == 'C-=' then
-- zoom in
Viewport.zoom = Viewport.zoom+0.1
elseif chord == 'C--' then
-- zoom out
Viewport.zoom = Viewport.zoom-0.1
elseif chord == 'C-0' then
-- reset zoom
Viewport.zoom = 1.0
elseif Cursor_node then
edit.keychord_pressed(Cursor_node.editor, chord, key)
end
end
{"Surface":165,"to_text":168,"on.code_changed":140,"vx":5,"on":1,"Viewport":29,"vy":8,"on.mouse_pressed":174,"on.mouse_released":175,"on.update":14,"on.keychord_pressed":176,"Cursor_node":172,"on.draw":162,"initialize_editor":74,"box_height":44,"scale":7,"compute_layout":157,"Page":111,"font":104,"parent":175}
on.mouse_released = function(x,y, mouse_button)
if Pan then
Pan = nil
elseif Cursor_node then
edit.mouse_released(Cursor_node.editor, x,y, mouse_button)
end
end
{"Surface":165,"to_text":168,"on.code_changed":140,"vx":5,"on":1,"Viewport":29,"vy":8,"on.mouse_pressed":174,"on.mouse_released":175,"on.update":14,"on.keychord_pressed":17,"Cursor_node":172,"on.draw":162,"initialize_editor":74,"box_height":44,"scale":7,"compute_layout":157,"Page":111,"font":104,"parent":174}
on.mouse_pressed = function(x,y, mouse_button)
if Cursor_node then
Cursor_node.show_cursor = nil
Cursor_node = nil
end
local node = to_text(x,y)
if node then
Cursor_node = node
node.show_cursor = true
edit.mouse_pressed(node.editor, x,y, mouse_button)
else
Pan = {x=Viewport.x+x,y=Viewport.y+y}
end
end
{"Surface":165,"to_text":168,"on.code_changed":140,"vx":5,"on":1,"Viewport":29,"vy":8,"on.mouse_pressed":174,"on.mouse_released":171,"on.update":14,"on.keychord_pressed":17,"Cursor_node":172,"on.draw":162,"initialize_editor":74,"box_height":44,"scale":7,"compute_layout":157,"Page":111,"font":104,"parent":173}
on.mouse_pressed = function(x,y, mouse_button)
local node = to_text(x,y)
if node then
Cursor_node = node
node.show_cursor = true
edit.mouse_pressed(node.editor, x,y, mouse_button)
else
Pan = {x=Viewport.x+x,y=Viewport.y+y}
end
end
{"Surface":165,"to_text":168,"on.code_changed":140,"vx":5,"on":1,"Viewport":29,"vy":8,"on.mouse_pressed":173,"on.mouse_released":171,"on.update":14,"on.keychord_pressed":17,"Cursor_node":172,"on.draw":162,"initialize_editor":74,"box_height":44,"scale":7,"compute_layout":157,"Page":111,"font":104,"parent":172}
{"Surface":165,"to_text":168,"on.code_changed":140,"vx":5,"on":1,"Viewport":29,"vy":8,"on.mouse_pressed":169,"on.mouse_released":171,"on.update":14,"on.keychord_pressed":17,"Cursor_node":172,"on.draw":162,"initialize_editor":74,"box_height":44,"scale":7,"compute_layout":157,"Page":111,"font":104,"parent":171}
Cursor_node = nil
on.mouse_released = function(x,y, mouse_button)
if Pan then
Pan = nil
else
local node = to_text(x,y)
if node then
edit.mouse_released(node.editor, x,y, mouse_button)
end
end
end
{"Surface":165,"to_text":168,"on.code_changed":140,"vx":5,"on":1,"Viewport":29,"vy":8,"on.mouse_pressed":169,"on.mouse_released":171,"on.update":14,"on.keychord_pressed":17,"on.draw":162,"initialize_editor":74,"box_height":44,"scale":7,"compute_layout":157,"Page":111,"font":104,"parent":169}
on.mouse_released = function(x,y, mouse_button)
if Pan then
Pan = nil
else
local node = to_text(x,y)
if node then
edit.mouse_released(node.editor, x,y, mouse_button)
end
end
{"Surface":165,"to_text":168,"on.code_changed":140,"parent":169,"on":1,"Viewport":29,"vy":8,"on.mouse_pressed":169,"on.mouse_released":170,"on.update":14,"on.keychord_pressed":17,"vx":5,"initialize_editor":74,"box_height":44,"scale":7,"compute_layout":157,"font":104,"Page":111,"on.draw":162}
on.mouse_pressed = function(x,y, mouse_button)
local node = to_text(x,y)
if node then
node.show_cursor = true
print('show cursor')
edit.mouse_pressed(node.editor, x,y, mouse_button)
else
print('pan')
Pan = {x=Viewport.x+x,y=Viewport.y+y}
end
end
{"Surface":165,"to_text":168,"on.code_changed":140,"parent":168,"on":1,"Viewport":29,"vy":8,"on.mouse_pressed":169,"on.mouse_released":13,"on.update":14,"on.keychord_pressed":17,"vx":5,"initialize_editor":74,"box_height":44,"scale":7,"compute_layout":157,"font":104,"Page":111,"on.draw":162}
to_text = function(x,y)
for _,node in ipairs(Surface) do
if node.type == 'text' then
print(x, y, node.data[1], node.x, node.y, node.w, node.h)
if x >= vx(node.x) and node.w and x < vx(node.x + node.w) then
if y >= vy(node.y) and node.h and y < vy(node.y + node.h) then
return node
end
end
end
end
end
{"Surface":165,"to_text":168,"on.code_changed":140,"parent":167,"on":1,"Viewport":29,"vy":8,"on.mouse_pressed":167,"on.mouse_released":13,"on.update":14,"on.keychord_pressed":17,"vx":5,"initialize_editor":74,"box_height":44,"scale":7,"compute_layout":157,"font":104,"Page":111,"on.draw":162}
on.mouse_pressed = function(x,y, mouse_button)
local node = to_text(x,y)
if node then
node.show_cursor = true
print('show cursor')
else
print('pan')
Pan = {x=Viewport.x+x,y=Viewport.y+y}
end
end
{"Surface":165,"to_text":166,"on.code_changed":140,"parent":166,"on":1,"Viewport":29,"vy":8,"on.mouse_pressed":167,"on.mouse_released":13,"on.update":14,"on.keychord_pressed":17,"vx":5,"initialize_editor":74,"box_height":44,"scale":7,"compute_layout":157,"font":104,"Page":111,"on.draw":162}
to_text = function(x,y)
for _,node in ipairs(Surface) do
if node.type == 'text' then
print(x, y, node.data[1], node.x, node.y, node.w, node.h)
if x >= node.x and node.w and x < node.x + node.w then
if y >= node.y and node.h and y < node.y + node.h then
return node
end
end
end
end
end
{"Surface":165,"to_text":166,"on.code_changed":140,"parent":165,"on":1,"Viewport":29,"vy":8,"on.mouse_pressed":160,"on.mouse_released":13,"on.update":14,"on.keychord_pressed":17,"vx":5,"initialize_editor":74,"box_height":44,"scale":7,"compute_layout":157,"font":104,"Page":111,"on.draw":162}
{"Surface":165,"to_text":164,"on.code_changed":140,"parent":164,"on":1,"Viewport":29,"vy":8,"on.mouse_pressed":160,"on.mouse_released":13,"on.update":14,"on.keychord_pressed":17,"vx":5,"initialize_editor":74,"box_height":44,"scale":7,"compute_layout":157,"font":104,"Page":111,"on.draw":162}
Surface = {
-- test data
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data={'0'}, x=-20,y=-20},
{type='rectangle', x=50,y=50, w=20,h=80, r=1,g=0,b=0},
{type='text', data={'abc', 'def'}, x=150, y=50, w=50,h=50, fg={r=0,g=0.4, b=0.9}},
{type='circle', x=300,y=200, radius=40, r=1,g=0,b=1},
{type='arc', x=0,y=0, radius=50, angle1=0, angle2=math.pi*2/3},
{type='ellipse', x=100,y=100, radiusx=10, radiusy=50},
{type='bezier', data={25,25, 25,125, 75,25, 125,25}},
}
to_text = function(x,y)
for _,node in ipairs(Surface) do
if node.type == 'text' then
print(x, y, node.data[1], node.x, node.y, node.w, node.h)
if x >= node.x and x < node.x + node.w then
if y >= node.y and y < node.y + node.h then
return node
end
end
end
end
end
{"Surface":116,"to_text":164,"on.code_changed":140,"parent":163,"on":1,"Viewport":29,"vy":8,"on.mouse_pressed":160,"on.mouse_released":13,"on.update":14,"on.keychord_pressed":17,"vx":5,"initialize_editor":74,"box_height":44,"scale":7,"compute_layout":157,"font":104,"Page":111,"on.draw":162}
to_text = function(x,y)
for _,node in ipairs(Surface) do
if node.type == 'text' then
print(node.data[1])
if x >= node.x and x < node.x + node.w then
if y >= node.y and y < node.y + node.h then
return node
end
end
end
end
end
{"Surface":116,"to_text":163,"on.code_changed":140,"parent":162,"on":1,"Viewport":29,"vy":8,"on.mouse_pressed":160,"on.mouse_released":13,"on.update":14,"on.keychord_pressed":17,"vx":5,"initialize_editor":74,"box_height":44,"scale":7,"compute_layout":157,"font":104,"Page":111,"on.draw":162}
on.draw = function()
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
obj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"Surface":116,"to_text":159,"on.code_changed":140,"parent":161,"on":1,"Viewport":29,"vy":8,"on.mouse_pressed":160,"on.mouse_released":13,"on.update":14,"on.keychord_pressed":17,"vx":5,"initialize_editor":74,"box_height":44,"scale":7,"compute_layout":157,"font":104,"Page":111,"on.draw":162}
on.draw = function()
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.zdata = {}
for i=1,#obj.data,2 do
table.insert(obj.zdata, vx(obj.data[i]))
table.insert(obj.zdata, vy(obj.data[i+1]))
end
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
zdata = {}
for i=1,#obj.data,2 do
table.insert(zdata, vx(obj.data[i]))
table.insert(zdata, vy(obj.data[i+1]))
end
obj.zdata = love.math.newBezierCurve(zdata):render()
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y or obj.scaled_fontsize ~= scaled_fontsize then
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
obj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)
initialize_editor(obj)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, obj.show_cursor)
end
end
end
end
{"Surface":116,"to_text":159,"on.code_changed":140,"parent":160,"on":1,"Viewport":29,"vy":8,"on.mouse_pressed":160,"on.mouse_released":13,"on.update":14,"on.keychord_pressed":17,"vx":5,"initialize_editor":74,"box_height":44,"scale":7,"compute_layout":157,"font":104,"Page":111,"on.draw":161}
on.mouse_pressed = function(x,y, mouse_button)
local node = to_text(x,y)
if node then
node.show_cursor = true
else
Pan = {x=Viewport.x+x,y=Viewport.y+y}
end
end
{"Surface":116,"to_text":159,"on.code_changed":140,"parent":159,"on":1,"Viewport":29,"vy":8,"on.mouse_pressed":160,"on.mouse_released":13,"on.update":14,"on.keychord_pressed":17,"vx":5,"initialize_editor":74,"box_height":44,"scale":7,"compute_layout":157,"font":104,"Page":111,"on.draw":158}
to_text = function(x,y)
for _,node in ipairs(Surface) do
if node.type == 'text' then
if x >= node.x and x < node.x + node.w then
if y >= node.y and y < node.y + node.h then
return node
end
end
end
end
end
{"Surface":116,"to_text":159,"on.code_changed":140,"parent":158,"on":1,"Viewport":29,"vy":8,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"on.keychord_pressed":17,"vx":5,"initialize_editor":74,"box_height":44,"scale":7,"compute_layout":157,"font":104,"Page":111,"on.draw":158}