We can't edit any text yet.
YUQ4YINAT5YTK3CAY4VK3HSYQ4D63FXLLPMC4R3DUFHIZIUQO7WQC
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}, true) -- hide cursor
end
end
end
end
{"compute_layout":157,"on.keychord_pressed":17,"Page":111,"on.code_changed":140,"scale":7,"Surface":116,"font":104,"on.draw":158,"vx":5,"Viewport":29,"parent":157,"vy":8,"initialize_editor":74,"on.mouse_pressed":12,"on":1,"on.mouse_released":13,"box_height":44,"on.update":14}
{"compute_layout":157,"on.keychord_pressed":17,"Page":111,"on.code_changed":140,"scale":7,"Surface":116,"font":104,"on.draw":155,"vx":5,"Viewport":29,"parent":156,"vy":8,"initialize_editor":74,"on.mouse_pressed":12,"on":1,"on.mouse_released":13,"box_height":44,"on.update":14}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
if node.type == 'text' then
-- leaf node containing raw text
node.x = x
node.y = y
-- render background if necessary
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
-- render contents
if node.width then
node.w = node.width
else
local scaled_fontsize = scale(node.fontsize or 20)
node.w = 0
for _,s in ipairs(node.data) do
local text = love.graphics.newText(font(node, scaled_fontsize), node.data)
local width = text:getWidth()
if node.w < width then node.w = width end
end
end
initialize_editor(node)
node.h = box_height(node)
table.insert(nodes_to_render, node)
if node_to_render then
node_to_render.w = node.w
node_to_render.h = node.h
end
elseif node.type == 'rows' then
node.x = x
node.y = y
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
if node_to_render then
node_to_render.w = w
node_to_render.h = h
end
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
if node_to_render then
node_to_render.w = w
node_to_render.h = h
end
end
return x+node.w,y+node.h
end
{"Viewport":29,"parent":155,"vy":8,"on":1,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"box_height":44,"on.keychord_pressed":17,"compute_layout":156,"Page":111,"on.code_changed":140,"Surface":116,"scale":7,"on.draw":155,"font":104,"vx":5,"initialize_editor":74}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
if node.type == 'text' then
-- leaf node containing raw text
node.x = x
node.y = y
-- render background if necessary
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
-- render contents
if node.width then
node.w = node.width
else
local scaled_fontsize = scale(node.fontsize or 20)
node.w = 0
for _,s in ipairs(node.data) do
local text = love.graphics.newText(font(node, scaled_fontsize), node.data)
local width = text:getWidth()
if node.w < width then node.w = width end
end
end
initialize_editor(node)
node.h = box_height(node)
table.insert(nodes_to_render, node)
if node_to_render then
node_to_render.w = node.w
node_to_render.h = node.h
end
elseif node.type == 'rows' then
node.x = x
node.y = y
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
if node_to_render then
node_to_render.w = w
node_to_render.h = h
end
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
if node_to_render then
node_to_render.w = w
node_to_render.h = h
end
end
return x+node.w,y+node.h
end
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
print('draw rectangle', obj.x)
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}, true) -- hide cursor
end
end
end
end
{"Viewport":29,"parent":154,"vy":8,"on":1,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"box_height":44,"on.keychord_pressed":17,"compute_layout":154,"Page":111,"on.code_changed":140,"Surface":116,"scale":7,"on.draw":155,"font":104,"vx":5,"initialize_editor":74}
{"Page":111,"on.code_changed":140,"Surface":116,"on":1,"on.draw":150,"vx":5,"Viewport":29,"vy":8,"parent":153,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":154,"font":104,"scale":7}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
if node.type == 'text' then
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
-- leaf node containing raw text
node.x = x
node.y = y
if node.width then
node.w = node.width
else
local scaled_fontsize = scale(node.fontsize or 20)
node.w = 0
for _,s in ipairs(node.data) do
local text = love.graphics.newText(font(node, scaled_fontsize), node.data)
local width = text:getWidth()
if node.w < width then node.w = width end
end
end
initialize_editor(node)
node.h = box_height(node)
table.insert(nodes_to_render, node)
if node_to_render then
node_to_render.w = node.w
node_to_render.h = node.h
end
elseif node.type == 'rows' then
node.x = x
node.y = y
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
if node_to_render then
node_to_render.w = w
node_to_render.h = h
end
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
if node_to_render then
node_to_render.w = w
node_to_render.h = h
end
end
return x+node.w,y+node.h
end
{"Page":111,"on.code_changed":140,"Surface":116,"on":1,"on.draw":150,"vx":5,"Viewport":29,"vy":8,"parent":152,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":153,"font":104,"scale":7}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
if node.type == 'text' then
-- leaf node containing raw text
node.x = x
node.y = y
if node.width then
node.w = node.width
else
local scaled_fontsize = scale(node.fontsize or 20)
node.w = 0
for _,s in ipairs(node.data) do
local text = love.graphics.newText(font(node, scaled_fontsize), node.data)
local width = text:getWidth()
if node.w < width then node.w = width end
end
end
initialize_editor(node)
node.h = box_height(node)
table.insert(nodes_to_render, node)
elseif node.type == 'rows' then
node.x = x
node.y = y
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
if node_to_render then
node_to_render.w = w
node_to_render.h = h
end
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
if node_to_render then
node_to_render.w = w
node_to_render.h = h
end
end
return x+node.w,y+node.h
end
{"Page":111,"on.code_changed":140,"Surface":116,"on":1,"on.draw":150,"vx":5,"Viewport":29,"vy":8,"parent":151,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":152,"font":104,"scale":7}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
if node.type == 'text' then
-- leaf node containing raw text
node.x = x
node.y = y
if node.width then
node.w = node.width
else
local scaled_fontsize = scale(node.fontsize or 20)
node.w = 0
for _,s in ipairs(node.data) do
local text = love.graphics.newText(font(node, scaled_fontsize), node.data)
local width = text:getWidth()
if node.w < width then node.w = width end
end
end
initialize_editor(node)
node.h = box_height(node)
table.insert(nodes_to_render, node)
elseif node.type == 'rows' then
node.x = x
node.y = y
-- lay out children top to bottom
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
if node_to_render then
node_to_render.w = w
node_to_render.h = h
end
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
if node.bg then
table.insert(nodes_to_render, {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y, w=node.w, h=node.h})
end
end
return x+node.w,y+node.h
end
{"Page":111,"on.code_changed":140,"Surface":116,"on":1,"on.draw":150,"vx":5,"Viewport":29,"vy":8,"parent":150,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":151,"font":104,"scale":7}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
if node.type == 'text' then
-- leaf node containing raw text
node.x = x
node.y = y
if node.width then
node.w = node.width
else
local scaled_fontsize = scale(node.fontsize or 20)
node.w = 0
for _,s in ipairs(node.data) do
local text = love.graphics.newText(font(node, scaled_fontsize), node.data)
local width = text:getWidth()
if node.w < width then node.w = width end
end
end
initialize_editor(node)
node.h = box_height(node)
table.insert(nodes_to_render, node)
elseif node.type == 'rows' then
node.x = x
node.y = y
-- lay out children top to bottom
local node_to_render
if node.bg then
node_to_render = {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y}
table.insert(nodes_to_render, node_to_render)
end
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
if node_to_render then
node_to_render.w = w
node_to_render.h = h
end
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
if node.bg then
table.insert(nodes_to_render, {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y, w=node.w, h=node.h})
end
end
return x+node.w,y+node.h
end
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
print('draw rectangle')
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}, true) -- hide cursor
end
end
end
end
{"Page":111,"on.code_changed":140,"Surface":116,"on":1,"on.draw":150,"vx":5,"Viewport":29,"vy":8,"parent":149,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":122,"font":104,"scale":7}
on.draw = function()
print('== draw')
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
print('draw rectangle')
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
print('draw text', obj.data[1], obj.editor.lines[1].data, obj.editor.line_cache[1].fragments)
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursor
end
end
end
end
{"Page":111,"on.code_changed":140,"Surface":116,"on":1,"on.draw":149,"vx":5,"Viewport":29,"vy":8,"parent":148,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":122,"font":104,"scale":7}
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
print('draw text', obj.data[1], obj.editor.lines[1].data, obj.editor.line_cache[1].fragments)
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursor
end
end
end
end
{"Page":111,"on.code_changed":140,"Surface":116,"on":1,"on.draw":148,"vx":5,"Viewport":29,"vy":8,"parent":147,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":122,"font":104,"scale":7}
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
print('draw text', obj.data[1], obj.editor.lines[1].data, obj.editor.line_cache[1])
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursor
end
end
end
end
{"Page":111,"on.code_changed":140,"Surface":116,"on":1,"on.draw":147,"vx":5,"Viewport":29,"vy":8,"parent":146,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":122,"font":104,"scale":7}
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
print('draw text', obj.data[1], obj.editor.lines[1].data, obj.w)
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursor
end
end
end
end
{"Page":111,"on.code_changed":140,"Surface":116,"on":1,"on.draw":146,"vx":5,"Viewport":29,"vy":8,"parent":145,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":122,"font":104,"scale":7}
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
print('draw text', obj.data[1], obj.editor.lines[1].data, obj.w)
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}, true) -- hide cursor
end
end
end
end
{"Page":111,"on.code_changed":140,"Surface":116,"on":1,"on.draw":145,"vx":5,"Viewport":29,"vy":8,"parent":144,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":122,"font":104,"scale":7}
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}, true) -- hide cursor
end
end
end
end
{"Page":111,"on.code_changed":140,"Surface":116,"on":1,"on.draw":144,"vx":5,"Viewport":29,"vy":8,"parent":143,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":122,"font":104,"scale":7}
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
print('draw text', obj.data, obj.data[1], obj.w, obj.fg)
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}, true) -- hide cursor
end
end
end
end
{"Page":111,"on.code_changed":140,"Surface":116,"on":1,"on.draw":143,"vx":5,"Viewport":29,"vy":8,"parent":142,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":122,"font":104,"scale":7}
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
print('draw text', obj.data, obj.data[1], obj.w)
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}, true) -- hide cursor
end
end
end
end
{"Page":111,"on.code_changed":140,"Surface":116,"on":1,"on.draw":142,"vx":5,"Viewport":29,"vy":8,"parent":141,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":122,"font":104,"scale":7}
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}, true) -- hide cursor
end
end
end
end
{"font":104,"initialize_editor":74,"on.mouse_pressed":12,"parent":140,"on.mouse_released":13,"on.update":14,"box_height":44,"on.keychord_pressed":17,"vy":8,"on.code_changed":140,"Page":111,"on":1,"scale":7,"Viewport":29,"vx":5,"on.draw":141,"Surface":116,"compute_layout":122}
on.code_changed = function()
while #Surface > 3 do
table.remove(Surface)
end
compute_layout(
Page,
--[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- ]]
0,0,
Surface)
end
{"Surface":116,"on.code_changed":140,"on.draw":139,"vx":5,"Viewport":29,"vy":8,"on":1,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"box_height":44,"on.keychord_pressed":17,"initialize_editor":74,"Page":111,"parent":139,"compute_layout":122,"scale":7,"font":104}
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
print('updating editor', obj.data[1])
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}, true) -- hide cursor
end
end
end
end
{"vy":8,"scale":7,"on.mouse_pressed":12,"Surface":116,"on.mouse_released":13,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":122,"Page":111,"on.code_changed":109,"parent":138,"font":104,"vx":5,"on.update":14,"Viewport":29,"on.draw":139,"on":1}
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}, true) -- hide cursor
end
end
end
end
{"font":104,"on.update":14,"box_height":44,"on.keychord_pressed":17,"compute_layout":122,"Page":111,"Surface":116,"on.code_changed":109,"on.draw":138,"parent":137,"Viewport":29,"vy":8,"on":1,"initialize_editor":74,"vx":5,"on.mouse_pressed":12,"scale":7,"on.mouse_released":13}
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
print('draw text', obj.w, obj.data[1], obj.fg)
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
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursor
end
end
end
{"font":104,"on.update":14,"box_height":44,"on.keychord_pressed":17,"compute_layout":122,"Page":111,"Surface":116,"on.code_changed":109,"on.draw":137,"parent":136,"Viewport":29,"vy":8,"on":1,"initialize_editor":74,"vx":5,"on.mouse_pressed":12,"scale":7,"on.mouse_released":13}
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
print('draw', obj.data[1], obj.fg)
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
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursor
end
end
end
{"font":104,"on.update":14,"box_height":44,"on.keychord_pressed":17,"compute_layout":122,"Page":111,"Surface":116,"on.code_changed":109,"on.draw":136,"parent":135,"Viewport":29,"vy":8,"on":1,"initialize_editor":74,"vx":5,"on.mouse_pressed":12,"scale":7,"on.mouse_released":13}
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
print('draw', obj.data[1], obj.fg)
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
assert(obj.w)
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursor
end
end
end
{"font":104,"on.update":14,"box_height":44,"on.keychord_pressed":17,"compute_layout":122,"Page":111,"Surface":116,"on.code_changed":109,"on.draw":135,"parent":125,"Viewport":29,"vy":8,"on":1,"initialize_editor":74,"vx":5,"on.mouse_pressed":12,"scale":7,"on.mouse_released":13}
on.code_changed = function()
print('on.code_changed')
while #Surface > 3 do
table.remove(Surface)
end
compute_layout(
Page,
--[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- ]]
0,0,
Surface)
end
{"on.mouse_released":13,"scale":7,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":130,"Page":111,"on.code_changed":134,"on.draw":133,"vx":5,"Viewport":29,"on.update":14,"vy":8,"font":104,"Surface":116,"on":1,"parent":133,"on.mouse_pressed":12}
on.draw = function()
print('on.draw')
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
print('draw', obj.data[1], obj.fg)
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
print('initializing editor')
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
initialize_editor(obj)
print('updating editor', obj.editor)
end
print('editor', obj.editor)
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursor
end
end
end
{"on.mouse_released":13,"scale":7,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":130,"Page":111,"on.code_changed":129,"on.draw":133,"vx":5,"Viewport":29,"on.update":14,"vy":8,"font":104,"Surface":116,"on":1,"parent":132,"on.mouse_pressed":12}
on.draw = function()
print('on.draw')
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
print('draw', obj.data[1], obj.fg)
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
print('initializing editor')
obj.saved_zoom = Viewport.zoom
obj.saved_x = Viewport.x
obj.saved_y = Viewport.y
obj.scaled_fontsize = scaled_fontsize
initialize_editor(obj)
print('updating editor', obj.editor)
end
print('editor', obj.editor)
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursor
end
end
end
{"on.mouse_released":13,"scale":7,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":130,"Page":111,"on.code_changed":129,"on.draw":132,"vx":5,"Viewport":29,"on.update":14,"vy":8,"font":104,"Surface":116,"on":1,"parent":131,"on.mouse_pressed":12}
on.draw = function()
print('on.draw')
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
print('draw', obj.data[1], obj.fg)
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
initialize_editor(obj)
print('updating editor', obj.editor)
end
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursor
end
end
end
{"on.draw":131,"vx":5,"Viewport":29,"vy":8,"parent":130,"font":104,"on.mouse_pressed":12,"on.mouse_released":13,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":130,"on":1,"scale":7,"on.code_changed":129,"Page":111,"Surface":116,"on.update":14}
{"on.draw":128,"vx":5,"Viewport":29,"vy":8,"parent":129,"font":104,"on.mouse_pressed":12,"on.mouse_released":13,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":130,"on":1,"scale":7,"on.code_changed":129,"Page":111,"Surface":116,"on.update":14}
compute_layout = function(node, x,y, nodes_to_render)
print('compute_layout')
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
if node.type == 'text' then
-- leaf node containing raw text
node.x = x
node.y = y
if node.width then
node.w = node.width
else
local scaled_fontsize = scale(node.fontsize or 20)
node.w = 0
for _,s in ipairs(node.data) do
local text = love.graphics.newText(font(node, scaled_fontsize), node.data)
local width = text:getWidth()
if node.w < width then node.w = width end
end
end
initialize_editor(node)
print('node editor', node.editor)
node.h = box_height(node)
table.insert(nodes_to_render, node)
elseif node.type == 'rows' then
node.x = x
node.y = y
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
if node.bg then
table.insert(nodes_to_render, {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y, w=node.w, h=node.h})
end
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
if node.bg then
table.insert(nodes_to_render, {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y, w=node.w, h=node.h})
end
end
return x+node.w,y+node.h
end
on.code_changed = function()
print('on.code_changed')
while #Surface > 3 do
table.remove(Surface)
end
compute_layout(
Page,
--[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- ]]
0,0,
Surface)
end
{"on.draw":128,"vx":5,"Viewport":29,"vy":8,"parent":128,"font":104,"on.mouse_pressed":12,"on.mouse_released":13,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":127,"on":1,"scale":7,"on.code_changed":129,"Page":111,"Surface":116,"on.update":14}
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
print('draw', obj.data[1], obj.fg)
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
initialize_editor(obj)
print('updating editor', obj.editor)
end
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursor
end
end
end
{"vx":5,"Viewport":29,"on":1,"vy":8,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"on.keychord_pressed":17,"Page":111,"Surface":116,"on.draw":128,"parent":127,"scale":7,"on.code_changed":109,"initialize_editor":74,"box_height":44,"font":104,"compute_layout":127}
{"vx":5,"Viewport":29,"on":1,"vy":8,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"on.keychord_pressed":17,"Page":111,"Surface":116,"on.draw":125,"parent":126,"scale":7,"on.code_changed":109,"initialize_editor":74,"box_height":44,"font":104,"compute_layout":127}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
if node.type == 'text' then
-- leaf node containing raw text
node.x = x
node.y = y
if node.width then
node.w = node.width
else
local scaled_fontsize = scale(node.fontsize or 20)
node.w = 0
for _,s in ipairs(node.data) do
local text = love.graphics.newText(font(node, scaled_fontsize), node.data)
local width = text:getWidth()
if node.w < width then node.w = width end
end
end
initialize_editor(node)
print('node editor', node.editor)
node.h = box_height(node)
table.insert(nodes_to_render, node)
elseif node.type == 'rows' then
node.x = x
node.y = y
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
if node.bg then
table.insert(nodes_to_render, {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y, w=node.w, h=node.h})
end
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
if node.bg then
table.insert(nodes_to_render, {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y, w=node.w, h=node.h})
end
end
return x+node.w,y+node.h
end
{"vx":5,"Viewport":29,"on":1,"vy":8,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"on.keychord_pressed":17,"Page":111,"Surface":116,"on.draw":125,"parent":125,"scale":7,"on.code_changed":109,"initialize_editor":74,"box_height":44,"font":104,"compute_layout":126}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
if node.type == 'text' then
-- leaf node containing raw text
node.x = x
node.y = y
if node.width then
node.w = node.width
else
local scaled_fontsize = scale(node.fontsize or 20)
node.w = 0
for _,s in ipairs(node.data) do
local text = love.graphics.newText(font(node, scaled_fontsize), node.data)
local width = text:getWidth()
if node.w < width then node.w = width end
end
end
initialize_editor(node)
print(node.editor)
node.h = box_height(node)
table.insert(nodes_to_render, node)
elseif node.type == 'rows' then
node.x = x
node.y = y
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
if node.bg then
table.insert(nodes_to_render, {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y, w=node.w, h=node.h})
end
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
if node.bg then
table.insert(nodes_to_render, {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y, w=node.w, h=node.h})
end
end
return x+node.w,y+node.h
end
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
print('draw', obj.data[1], obj.fg)
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
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursor
end
end
end
{"on.code_changed":109,"on.draw":125,"font":104,"vx":5,"Viewport":29,"vy":8,"scale":7,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"on.keychord_pressed":17,"Page":111,"compute_layout":122,"parent":124,"box_height":44,"on":1,"Surface":116}
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
print('draw', obj.data[1], obj.fg)
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}, true) -- hide cursor
end
end
end
end
{"on.code_changed":109,"on.draw":124,"font":104,"vx":5,"Viewport":29,"vy":8,"scale":7,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"on.keychord_pressed":17,"Page":111,"compute_layout":122,"parent":123,"box_height":44,"on":1,"Surface":116}
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
print('draw', obj.data[1])
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}, true) -- hide cursor
end
end
end
end
{"on.code_changed":109,"on.draw":123,"font":104,"vx":5,"Viewport":29,"vy":8,"scale":7,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"on.keychord_pressed":17,"Page":111,"compute_layout":122,"parent":122,"box_height":44,"on":1,"Surface":116}
{"on.code_changed":109,"on.draw":119,"font":104,"vx":5,"Viewport":29,"vy":8,"scale":7,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"on.keychord_pressed":17,"Page":111,"compute_layout":122,"parent":121,"box_height":44,"on":1,"Surface":116}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
if node.type == 'text' then
-- leaf node containing raw text
node.x = x
node.y = y
if node.width then
node.w = node.width
else
local scaled_fontsize = scale(node.fontsize or 20)
node.w = 0
for _,s in ipairs(node.data) do
local text = love.graphics.newText(font(node, scaled_fontsize), node.data)
local width = text:getWidth()
if node.w < width then node.w = width end
end
end
initialize_editor(node)
node.h = box_height(node)
table.insert(nodes_to_render, node)
elseif node.type == 'rows' then
node.x = x
node.y = y
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
if node.bg then
table.insert(nodes_to_render, {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y, w=node.w, h=node.h})
end
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
if node.bg then
table.insert(nodes_to_render, {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y, w=node.w, h=node.h})
end
end
return x+node.w,y+node.h
end
{"on.code_changed":109,"on.draw":119,"font":104,"vx":5,"Viewport":29,"vy":8,"scale":7,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"on.keychord_pressed":17,"Page":111,"compute_layout":121,"parent":120,"box_height":44,"on":1,"Surface":116}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
if node.type == 'text' then
-- leaf node containing raw text
node.x = x
node.y = y
if node.width then
node.w = node.width
else
local scaled_fontsize = scale(node.fontsize or 20)
node.text = love.graphics.newText(font(node, scaled_fontsize), node.data)
print(node.data[1], node.w)
node.w = node.text:getWidth()
end
initialize_editor(node)
node.h = box_height(node)
table.insert(nodes_to_render, node)
elseif node.type == 'rows' then
node.x = x
node.y = y
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
if node.bg then
table.insert(nodes_to_render, {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y, w=node.w, h=node.h})
end
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
if node.bg then
table.insert(nodes_to_render, {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y, w=node.w, h=node.h})
end
end
return x+node.w,y+node.h
end
{"on.code_changed":109,"on.draw":119,"font":104,"vx":5,"Viewport":29,"vy":8,"scale":7,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"on.keychord_pressed":17,"Page":111,"compute_layout":120,"parent":119,"box_height":44,"on":1,"Surface":116}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
if node.type == 'text' then
-- leaf node containing raw text
node.x = x
node.y = y
if node.width then
node.w = node.width
else
local scaled_fontsize = scale(node.fontsize or 20)
node.text = love.graphics.newText(font(node, scaled_fontsize), node.data)
print(node.w)
node.w = node.text:getWidth()
end
initialize_editor(node)
node.h = box_height(node)
table.insert(nodes_to_render, node)
elseif node.type == 'rows' then
node.x = x
node.y = y
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
if node.bg then
table.insert(nodes_to_render, {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y, w=node.w, h=node.h})
end
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
if node.bg then
table.insert(nodes_to_render, {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y, w=node.w, h=node.h})
end
end
return x+node.w,y+node.h
end
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}, true) -- hide cursor
end
end
end
end
{"on.code_changed":109,"on.draw":119,"font":104,"vx":5,"Viewport":29,"vy":8,"scale":7,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"on.keychord_pressed":17,"Page":111,"compute_layout":115,"parent":118,"box_height":44,"on":1,"Surface":116}
on.draw = function()
for _,obj in ipairs(Surface) do
print(obj.type, obj.data)
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}, true) -- hide cursor
end
end
end
end
{"on.code_changed":109,"on.draw":118,"font":104,"vx":5,"Viewport":29,"vy":8,"scale":7,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"on.keychord_pressed":17,"Page":111,"compute_layout":115,"parent":117,"box_height":44,"on":1,"Surface":116}
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}, true) -- hide cursor
end
end
end
end
{"on.code_changed":109,"on.draw":117,"font":104,"vx":5,"Viewport":29,"vy":8,"scale":7,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"on.keychord_pressed":17,"Page":111,"compute_layout":115,"parent":116,"box_height":44,"on":1,"Surface":116}
{"on.code_changed":109,"on.draw":113,"font":104,"vx":5,"Viewport":29,"vy":8,"scale":7,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"on.keychord_pressed":17,"Page":111,"compute_layout":115,"parent":115,"box_height":44,"on":1,"Surface":116}
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}},
}
{"on.code_changed":109,"on.draw":113,"font":104,"vx":5,"Viewport":29,"vy":8,"scale":7,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"on.keychord_pressed":17,"Page":111,"compute_layout":115,"parent":114,"box_height":44,"on":1,"Surface":93}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
if node.type == 'text' then
-- leaf node containing raw text
node.x = x
node.y = y
if node.width then
node.w = node.width
else
local scaled_fontsize = scale(node.fontsize or 20)
node.text = love.graphics.newText(font(node, scaled_fontsize), node.data)
node.w = node.text:getWidth()
end
initialize_editor(node)
node.h = box_height(node)
table.insert(nodes_to_render, node)
elseif node.type == 'rows' then
node.x = x
node.y = y
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
if node.bg then
table.insert(nodes_to_render, {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y, w=node.w, h=node.h})
end
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
if node.bg then
table.insert(nodes_to_render, {type='rectangle', r=node.bg.r, g=node.bg.g, b=node.bg.b, x=node.x, y=node.y, w=node.w, h=node.h})
end
end
return x+node.w,y+node.h
end
{"on.code_changed":109,"on.draw":113,"font":104,"vx":5,"Viewport":29,"vy":8,"scale":7,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"on.keychord_pressed":17,"Page":111,"compute_layout":114,"parent":113,"box_height":44,"on":1,"Surface":93}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
if node.type == 'text' then
-- leaf node containing raw text
node.x = x
node.y = y
if node.width then
node.w = node.width
else
local scaled_fontsize = scale(node.fontsize or 20)
node.text = love.graphics.newText(font(node, scaled_fontsize), node.data)
node.w = node.text:getWidth()
end
initialize_editor(node)
node.h = box_height(node)
table.insert(nodes_to_render, node)
elseif node.type == 'rows' then
node.x = x
node.y = y
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
end
return x+node.w,y+node.h
end
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.width),scale(obj.height))
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}, true) -- hide cursor
end
end
end
end
{"on.code_changed":109,"on.draw":113,"font":104,"vx":5,"Viewport":29,"vy":8,"scale":7,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"on.keychord_pressed":17,"Page":111,"compute_layout":112,"parent":112,"box_height":44,"on":1,"Surface":93}
{"on.code_changed":109,"on.draw":105,"font":104,"vx":5,"Viewport":29,"vy":8,"scale":7,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"on.keychord_pressed":17,"Page":111,"compute_layout":112,"parent":111,"box_height":44,"on":1,"Surface":93}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
table.insert(nodes_to_render, node)
if node.type == 'text' then
-- leaf node containing raw text
node.x = x
node.y = y
if node.width then
node.w = node.width
else
local scaled_fontsize = scale(node.fontsize or 20)
node.text = love.graphics.newText(font(node, scaled_fontsize), node.data)
node.w = node.text:getWidth()
end
initialize_editor(node)
node.h = box_height(node)
elseif node.type == 'rows' then
node.x = x
node.y = y
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
end
return x+node.w,y+node.h
end
{"on.code_changed":109,"on.draw":105,"font":104,"vx":5,"Viewport":29,"vy":8,"scale":7,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"on.keychord_pressed":17,"Page":111,"compute_layout":107,"parent":110,"box_height":44,"on":1,"Surface":93}
Page = {
-- page
type='cols', x=0, y=0,
width=800, data={
-- editor covering left side
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- a table on the right
{ type='rows', name='searches', margin=50, data={
{ type='text', data={''},},
{ type='cols', data={
{ type='text', data={'search:'},},
{ type='text', name='search', bg={r=0.8,g=0.8,b=0.8}, data={''}, width=90,},
}},
{ type='text', data={'table:'},},
{ type='cols', bg={r=0.8,g=0.8,b=0.8}, data={
{ type='rows', width=90, data={
{type='text', data={'abc'},},
{type='text', data={'abc'},},
}},
{ type='rows', width=90, data={
{type='text', data={'def'},},
{type='text', data={'def'},},
}},
}},
}},
},
}
{"on.code_changed":109,"on.draw":105,"font":104,"vx":5,"Viewport":29,"vy":8,"scale":7,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"on.keychord_pressed":17,"Page":110,"compute_layout":107,"parent":109,"box_height":44,"on":1,"Surface":93}
Page = {
-- page
type='cols', x=0, y=0,
width=800, data={
-- editor covering left side
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- a table on the right
{ type='rows', name='searches', margin=50, data={
{ type='text', data={''},},
{ type='cols', data={
{ type='text', data={'search:'},},
{ type='text', name='search', bg={r=0.8,g=0.8,b=0.8}, data={''}, width=90,},
}},
{ type='text', data={'table:'},},
{ type='cols', bg={r=0.8,g=0.8,b=0.8}, data={
{ type='rows', width=90, data={
{data={'abc'},},
{data={'abc'},},
}},
{ type='rows', width=90, data={
{data={'def'},},
{data={'def'},},
}},
}},
}},
},
}
on.code_changed = function()
while #Surface > 3 do
table.remove(Surface)
end
compute_layout(
Page,
--[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- ]]
0,0,
Surface)
end
{"on.code_changed":109,"on.draw":105,"font":104,"vx":5,"Viewport":29,"vy":8,"scale":7,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"initialize_editor":74,"on.keychord_pressed":17,"Page":76,"compute_layout":107,"parent":108,"box_height":44,"on":1,"Surface":93}
on.code_changed = function()
while #Surface > 3 do
table.remove(Surface)
end
compute_layout(
Page,
--[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- ]]
0,0,
Surface)
end
{"vy":8,"compute_layout":107,"on.mouse_pressed":12,"on.mouse_released":13,"on.code_changed":108,"scale":7,"on.keychord_pressed":17,"Page":76,"on":1,"Surface":93,"on.update":14,"on.draw":105,"font":104,"vx":5,"parent":107,"Viewport":29,"initialize_editor":74,"box_height":44}
{"vy":8,"compute_layout":107,"on.mouse_pressed":12,"on.mouse_released":13,"on.code_changed":103,"scale":7,"on.keychord_pressed":17,"Page":76,"on":1,"Surface":93,"on.update":14,"on.draw":105,"font":104,"vx":5,"parent":106,"Viewport":29,"initialize_editor":74,"box_height":44}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
print('compute_layout: node of type', node.type, 'at', x,y)
table.insert(nodes_to_render, node)
if node.type == 'text' then
-- leaf node containing raw text
node.x = x
node.y = y
if node.width then
node.w = node.width
else
local scaled_fontsize = scale(node.fontsize or 20)
node.text = love.graphics.newText(font(node, scaled_fontsize), node.data)
node.w = node.text:getWidth()
end
initialize_editor(node)
node.h = box_height(node)
elseif node.type == 'rows' then
node.x = x
node.y = y
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
end
return x+node.w,y+node.h
end
{"on.draw":105,"vx":5,"Viewport":29,"vy":8,"on":1,"parent":105,"on.mouse_pressed":12,"on.mouse_released":13,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":106,"Page":76,"font":104,"on.code_changed":103,"scale":7,"Surface":93,"on.update":14}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
print('compute_layout: node of type', node.type, 'at', x,y)
table.insert(nodes_to_render, node)
if node.type == 'text' then
-- leaf node containing raw text
node.x = x
node.y = y
if node.width then
node.w = node.width
else
local scaled_fontsize = scale(node.fontsize or 20)
node.text = love.graphics.newText(font(node, scaled_fontsize), node.data)
node.w = node.text:getWidth()
end
initialize_editor(node)
node.h = box_height(node)
elseif node.type == 'rows' then
node.x = x
node.y = y
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
end
return x+node.w,y+node.h
end
on.draw = function()
for i,obj in ipairs(Surface) do
print(i, obj.type)
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.width),scale(obj.height))
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}, true) -- hide cursor
end
end
end
end
{"on.draw":105,"vx":5,"Viewport":29,"vy":8,"on":1,"parent":104,"on.mouse_pressed":12,"on.mouse_released":13,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":102,"Page":76,"font":104,"on.code_changed":103,"scale":7,"Surface":93,"on.update":14}
{"on.draw":91,"vx":5,"Viewport":29,"vy":8,"on":1,"parent":103,"on.mouse_pressed":12,"on.mouse_released":13,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":102,"Page":76,"font":104,"on.code_changed":103,"scale":7,"Surface":93,"on.update":14}
font = function(obj, fontsize)
if Font == nil then Font = {} end
if Font[fontsize] == nil then
Font[fontsize] = love.graphics.newFont(fontsize)
end
return Font[fontsize]
end
on.code_changed = function()
while #Surface > 3 do
table.remove(Surface)
end
compute_layout(
Page,
--[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- ]]
0,0,
Surface)
end
{"on.mouse_released":13,"on.update":14,"box_height":44,"on.keychord_pressed":17,"Page":76,"scale":7,"initialize_editor":74,"Surface":93,"compute_layout":102,"on.draw":91,"vx":5,"on":1,"Viewport":29,"on.code_changed":103,"vy":8,"parent":102,"on.mouse_pressed":12}
{"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"box_height":44,"on.keychord_pressed":17,"compute_layout":102,"scale":7,"Page":76,"on.code_changed":98,"Surface":93,"parent":101,"on.draw":91,"vx":5,"Viewport":29,"on":1,"vy":8,"initialize_editor":74}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
print('compute_layout: node of type', node.type, 'at', x,y)
table.insert(nodes_to_render, node)
if node.type == 'text' and node.width then
-- leaf node containing raw text
node.x = x
node.y = y
node.w = node.width
initialize_editor(node)
node.h = box_height(node)
elseif node.type == 'rows' then
node.x = x
node.y = y
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
end
return x+node.w,y+node.h
end
{"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"box_height":44,"on.keychord_pressed":17,"compute_layout":101,"scale":7,"Page":76,"on.code_changed":98,"Surface":93,"parent":100,"on.draw":91,"vx":5,"Viewport":29,"on":1,"vy":8,"initialize_editor":74}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
print('compute_layout: node of type', node.type)
table.insert(nodes_to_render, node)
if node.type == 'text' and node.width then
-- leaf node containing raw text
node.x = x
node.y = y
node.w = node.width
initialize_editor(node)
node.h = box_height(node)
elseif node.type == 'rows' then
node.x = x
node.y = y
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
end
return x+node.w,y+node.h
end
{"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"box_height":44,"on.keychord_pressed":17,"compute_layout":100,"scale":7,"Page":76,"on.code_changed":98,"Surface":93,"parent":99,"on.draw":91,"vx":5,"Viewport":29,"on":1,"vy":8,"initialize_editor":74}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
print(node.type)
table.insert(nodes_to_render, node)
if node.type == 'text' and node.width then
-- leaf node containing raw text
node.x = x
node.y = y
node.w = node.width
initialize_editor(node)
node.h = box_height(node)
elseif node.type == 'rows' then
node.x = x
node.y = y
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
end
return x+node.w,y+node.h
end
{"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"box_height":44,"on.keychord_pressed":17,"compute_layout":99,"scale":7,"Page":76,"on.code_changed":98,"Surface":93,"parent":98,"on.draw":91,"vx":5,"Viewport":29,"on":1,"vy":8,"initialize_editor":74}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
table.insert(nodes_to_render, node)
if node.type == 'text' and node.width then
-- leaf node containing raw text
node.x = x
node.y = y
node.w = node.width
initialize_editor(node)
node.h = box_height(node)
elseif node.type == 'rows' then
node.x = x
node.y = y
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
end
return x+node.w,y+node.h
end
on.code_changed = function()
while #Surface > 3 do
table.remove(Surface)
end
compute_layout(
Page,
--[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- ]]
0,0,
Surface)
end
{"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"box_height":44,"on.keychord_pressed":17,"compute_layout":95,"scale":7,"Page":76,"on.code_changed":98,"Surface":93,"parent":97,"on.draw":91,"vx":5,"Viewport":29,"on":1,"vy":8,"initialize_editor":74}
on.code_changed = function()
while #Surface > 3 do
table.remove(Surface)
end
compute_layout(
Page,
-- --[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- ]]
0,0,
Surface)
end
{"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"box_height":44,"on.keychord_pressed":17,"compute_layout":95,"scale":7,"Page":76,"on.code_changed":97,"Surface":93,"parent":96,"on.draw":91,"vx":5,"Viewport":29,"on":1,"vy":8,"initialize_editor":74}
on.code_changed = function()
while #Surface > 3 do
table.remove(Surface)
end
compute_layout(
Page,
-- --[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- ]]
0,0,
Surface)
end
{"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"box_height":44,"on.keychord_pressed":17,"compute_layout":95,"scale":7,"Page":76,"on.code_changed":96,"Surface":93,"parent":95,"on.draw":91,"vx":5,"Viewport":29,"on":1,"vy":8,"initialize_editor":74}
{"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"box_height":44,"on.keychord_pressed":17,"compute_layout":95,"scale":7,"Page":76,"on.code_changed":94,"Surface":93,"parent":94,"on.draw":91,"vx":5,"Viewport":29,"on":1,"vy":8,"initialize_editor":74}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
table.insert(nodes_to_render, node)
if node.type == 'text' and node.width then
-- leaf node containing raw text
node.x = x
node.y = y
node.w = node.width
initialize_editor(node)
node.h = box_height(node)
elseif node.type == 'rows' then
node.x = x
node.y = y
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = dom.compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = dom.compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
end
return x+node.w,y+node.h
end
on.code_changed = function()
while #Surface > 3 do
table.remove(Surface)
end
local node = compute_layout(
Page,
-- --[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- ]]
0,0,
Surface)
end
{"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"box_height":44,"on.keychord_pressed":17,"compute_layout":92,"scale":7,"Page":76,"on.code_changed":94,"Surface":93,"parent":93,"on.draw":91,"vx":5,"Viewport":29,"on":1,"vy":8,"initialize_editor":74}
{"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"box_height":44,"on.keychord_pressed":17,"compute_layout":92,"scale":7,"Page":76,"on.code_changed":89,"Surface":93,"parent":92,"on.draw":91,"vx":5,"Viewport":29,"on":1,"vy":8,"initialize_editor":74}
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, width=20,height=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}},
}
{"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"box_height":44,"on.keychord_pressed":17,"compute_layout":92,"scale":7,"Page":76,"on.code_changed":89,"Surface":70,"parent":91,"on.draw":91,"vx":5,"Viewport":29,"on":1,"vy":8,"initialize_editor":74}
compute_layout = function(node, x,y, nodes_to_render)
-- append to nodes_to_render flattened instructions to render a hierarchy of nodes
-- return x,y rendered until (surface coordinates)
table.insert(nodes_to_render, node)
if node.type == 'text' and node.width then
-- leaf node containing raw text
node.x = x
node.y = y
node.w = node.width
initialize_editor(node)
node.h = box_height(node)
elseif node.type == 'rows' then
node.x = x
node.y = y
-- lay out children top to bottom
local subx,suby = x,y
local w,h = 0,0
local subnodes
for _,child in ipairs(node.data) do
if child.margin then
suby = suby+child.margin
h = h+child.margin
end
subx,suby = dom.compute_layout(child, x,suby, nodes_to_render)
if w < child.w then
w = child.w
end
h = h+child.h
end
node.w = w
node.h = h
elseif node.type == 'cols' then
node.x = x
node.y = y
-- lay out children left to right
local subx,suby = x,y
local w,h = 0,0
for _,child in ipairs(node.data) do
if child.margin then
subx = subx+child.margin
w = w+child.margin
end
subx,suby = dom.compute_layout(child, subx,y, nodes_to_render)
w = w + child.w
if h < child.h then
h = child.h
end
end
node.w = w
node.h = h
end
return x+node.w,y+node.h
end
on.draw = function()
for i,obj in ipairs(Surface) do
print(i, obj.type)
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.width),scale(obj.height))
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
print(obj.data)
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
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.text = love.graphics.newText(Font[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}, true) -- hide cursor
end
end
end
end
{"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"box_height":44,"on.keychord_pressed":17,"compute_layout":75,"scale":7,"Page":76,"on.code_changed":89,"Surface":70,"parent":90,"on.draw":91,"vx":5,"Viewport":29,"on":1,"vy":8,"initialize_editor":74}
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.width),scale(obj.height))
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
print(obj.data)
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
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.text = love.graphics.newText(Font[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}, true) -- hide cursor
end
end
end
end
{"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"box_height":44,"on.keychord_pressed":17,"compute_layout":75,"scale":7,"Page":76,"on.code_changed":89,"Surface":70,"parent":89,"on.draw":90,"vx":5,"Viewport":29,"on":1,"vy":8,"initialize_editor":74}
on.code_changed = function()
local node = compute_layout(
Page,
-- --[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- ]]
0,0)
Surface = {node,
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data='0', x=-20,y=-20},
}
end
{"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"box_height":44,"on.keychord_pressed":17,"compute_layout":75,"scale":7,"Page":76,"on.code_changed":89,"Surface":70,"parent":88,"on.draw":72,"vx":5,"Viewport":29,"on":1,"vy":8,"initialize_editor":74}
on.code_changed = function()
print('AAAAAAAAAAAAAAAAA')
local node = compute_layout(
Page,
-- --[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- ]]
0,0)
Surface = {node,
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data='0', x=-20,y=-20},
}
end
{"on":1,"on.mouse_pressed":12,"on.mouse_released":13,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":75,"Page":76,"on.code_changed":88,"scale":7,"Surface":70,"on.draw":72,"vx":5,"Viewport":29,"on.update":14,"vy":8,"parent":87}
on.code_changed = function()
print('AAAAAAAAAAAAAAAAA')
local node = compute_layout(
--Page,
-- --[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- ]]
0,0)
Surface = {node,
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data='0', x=-20,y=-20},
}
end
{"on":1,"on.mouse_pressed":12,"on.mouse_released":13,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":75,"Page":76,"on.code_changed":87,"scale":7,"Surface":70,"on.draw":72,"vx":5,"Viewport":29,"on.update":14,"vy":8,"parent":86}
on.code_changed = function()
print('AAAAAAAAAAAAAAAAA')
local node = compute_layout(
--Page,
-- [[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- ]]
0,0)
Surface = {node,
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data='0', x=-20,y=-20},
}
end
{"on":1,"on.mouse_pressed":12,"on.mouse_released":13,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":75,"Page":76,"on.code_changed":86,"scale":7,"Surface":70,"on.draw":72,"vx":5,"Viewport":29,"on.update":14,"vy":8,"parent":85}
on.code_changed = function()
print('AAAAAAAAAAAAAAAAA')
local node = compute_layout(
Page,
--[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
]]
0,0)
Surface = {node,
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data='0', x=-20,y=-20},
}
end
{"on":1,"on.mouse_pressed":12,"on.mouse_released":13,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":75,"Page":76,"on.code_changed":85,"scale":7,"Surface":70,"on.draw":72,"vx":5,"Viewport":29,"on.update":14,"vy":8,"parent":83}
on.code_changed = function()
print('AAAAAAAAAAAAAAAAA')
local node = compute_layout(
Page)
--[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
]]
0,0)
Surface = {node,
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data='0', x=-20,y=-20},
}
end
{"on":1,"on.mouse_pressed":12,"on.mouse_released":13,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":75,"Page":76,"on.code_changed":84,"scale":7,"Surface":70,"on.draw":72,"vx":5,"Viewport":29,"on.update":14,"vy":8,"parent":83}
on.code_changed = function()
print('AAAAAAAAAAAAAAAAA')
local node = compute_layout(
Page,
--[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
]]
0,0)
Surface = {node,
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data='0', x=-20,y=-20},
}
end
{"vy":8,"on.mouse_pressed":12,"on.mouse_released":13,"on":1,"on.update":14,"box_height":44,"on.keychord_pressed":17,"compute_layout":75,"Page":76,"on.code_changed":83,"Surface":70,"on.draw":72,"vx":5,"parent":81,"Viewport":29,"initialize_editor":74,"scale":7}
on.code_changed = function()
print('AAAAAAAAAAAAAAAAA')
local node = compute_layout(
Page)
--[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
]]
0,0)
Surface = {node,
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data='0', x=-20,y=-20},
}
end
{"vy":8,"on.mouse_pressed":12,"on.mouse_released":13,"on":1,"on.update":14,"box_height":44,"on.keychord_pressed":17,"compute_layout":75,"Page":76,"on.code_changed":82,"Surface":70,"on.draw":72,"vx":5,"parent":81,"Viewport":29,"initialize_editor":74,"scale":7}
on.code_changed = function()
print('AAAAAAAAAAAAAAAAA')
local node = compute_layout(
Page)
--[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
]]
0,0)
Surface = {node,
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data='0', x=-20,y=-20},
}
end
{"Viewport":29,"parent":80,"vy":8,"scale":7,"on.mouse_pressed":12,"on.mouse_released":13,"initialize_editor":74,"box_height":44,"on.keychord_pressed":17,"compute_layout":75,"Page":76,"on.code_changed":81,"Surface":70,"on":1,"on.draw":72,"on.update":14,"vx":5}
on.code_changed = function()
print('AAAAAAAAAAAAAAAAA')
local node = compute_layout(
Page)
--[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
]]
0,0)
Surface = {node,
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data='0', x=-20,y=-20},
}
end
{"Viewport":29,"vy":8,"parent":78,"on":1,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"on.keychord_pressed":17,"box_height":44,"compute_layout":75,"Page":76,"on.code_changed":80,"Surface":70,"on.draw":72,"scale":7,"initialize_editor":74,"vx":5}
on.code_changed = function()
print('AAAAAAAAAAAAAAAAA')
local node = compute_layout(
Page)
--[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
]]
0,0)
Surface = {node,
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data='0', x=-20,y=-20},
}
end
{"Viewport":29,"vy":8,"parent":78,"on":1,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"on.keychord_pressed":17,"box_height":44,"compute_layout":75,"Page":76,"on.code_changed":79,"Surface":70,"initialize_editor":74,"on.draw":72,"scale":7,"vx":5}
on.code_changed = function()
print('AAAAAAAAAAAAAAAAA')
local node = compute_layout(
Page)
--[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
0,0)
Surface = {node,
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data='0', x=-20,y=-20},
}
]]
print('AAA', #Surface)
end
{"Viewport":29,"vy":8,"parent":77,"on":1,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"on.keychord_pressed":17,"box_height":44,"compute_layout":75,"Page":76,"on.code_changed":78,"Surface":70,"initialize_editor":74,"on.draw":72,"scale":7,"vx":5}
on.code_changed = function()
print('AAAAAAAAAAAAAAAAA')
local node = compute_layout(
Page)
--[[
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
0,0)
Surface = {node,
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data='0', x=-20,y=-20},
}
]]
print('AAA', #Surface)
end
{"Viewport":29,"vy":8,"parent":76,"on":1,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"on.keychord_pressed":17,"box_height":44,"compute_layout":75,"Page":76,"on.code_changed":77,"Surface":70,"initialize_editor":74,"on.draw":72,"scale":7,"vx":5}
{"Viewport":29,"vy":8,"parent":75,"on":1,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"on.keychord_pressed":17,"box_height":44,"compute_layout":75,"Page":76,"on.code_changed":61,"Surface":70,"initialize_editor":74,"on.draw":72,"scale":7,"vx":5}
Page = {
-- page
type='cols', x=0, y=0,
width=800, data={
-- editor covering left side
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- a table on the right
{ type='rows', name='searches', margin=50, data={
{ type='text', data={''},},
{ type='cols', data={
{ type='text', data={'search:'},},
{ type='edit', name='search', bg={r=0.8,g=0.8,b=0.8}, data={''}, width=90,},
}},
{ type='text', data={'table:'},},
{ type='cols', bg={r=0.8,g=0.8,b=0.8}, data={
{ type='rows', width=90, data={
{data={'abc'},},
{data={'abc'},},
}},
{ type='rows', width=90, data={
{data={'def'},},
{data={'def'},},
}},
}},
}},
},
}
{"Viewport":29,"vy":8,"parent":74,"on":1,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"on.keychord_pressed":17,"box_height":44,"compute_layout":75,"Page":39,"on.code_changed":61,"Surface":70,"initialize_editor":74,"on.draw":72,"scale":7,"vx":5}
compute_layout = function(node, x,y)
if node.type == 'text' and node.width then
node.x = x
node.y = y
node.w = node.width
initialize_editor(node)
node.h = box_height(node)
end
return node
end
{"Viewport":29,"vy":8,"parent":73,"on":1,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"on.keychord_pressed":17,"box_height":44,"compute_layout":73,"Page":39,"on.code_changed":61,"Surface":70,"initialize_editor":74,"on.draw":72,"scale":7,"vx":5}
initialize_editor = function(obj)
if obj.w then
-- use an editor to wrap the text
local scaled_fontsize = scale(obj.fontsize or 20)
obj.editor = edit.initialize_state(vy(obj.y), vx(obj.x), vx(obj.x+obj.w), scaled_fontsize, math.floor(scaled_fontsize*1.3))
obj.editor.lines = load_array(obj.data)
Text.redraw_all(obj.editor)
end
end
{"Viewport":29,"vy":8,"parent":72,"on":1,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"on.keychord_pressed":17,"box_height":44,"compute_layout":73,"Page":39,"on.code_changed":61,"Surface":70,"initialize_editor":71,"on.draw":72,"scale":7,"vx":5}
compute_layout = function(node, x,y)
if node.type == 'text' and node.width then
node.x = x
node.y = y
node.w = node.width
initialize_editor(node)
node.h = box_height(node)
end
return node
end
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.width),scale(obj.height))
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
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.text = love.graphics.newText(Font[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}, true) -- hide cursor
end
end
end
end
{"Viewport":29,"vy":8,"parent":71,"on":1,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"on.keychord_pressed":17,"box_height":44,"compute_layout":66,"Page":39,"on.code_changed":61,"Surface":70,"initialize_editor":71,"on.draw":72,"scale":7,"vx":5}
{"Viewport":29,"vy":8,"parent":70,"on":1,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"on.keychord_pressed":17,"box_height":44,"compute_layout":66,"Page":39,"on.code_changed":61,"Surface":70,"initialize_editor":71,"on.draw":69,"scale":7,"vx":5}
initialize_editor = function(obj)
if obj.w then
-- use an editor to wrap the text
obj.editor = edit.initialize_state(vy(obj.y), vx(obj.x), vx(obj.x+obj.w), scaled_fontsize, math.floor(scaled_fontsize*1.3))
obj.editor.lines = load_array(obj.data)
Text.redraw_all(obj.editor)
end
end
{"box_height":44,"Viewport":29,"compute_layout":66,"Page":39,"vy":8,"parent":69,"on":1,"on.draw":69,"on.keychord_pressed":17,"on.code_changed":61,"Surface":70,"on.mouse_released":13,"on.mouse_pressed":12,"on.update":14,"scale":7,"vx":5}
Surface = {
-- test data
{type='rectangle', x=50,y=50, width=20,height=80, r=1,g=0,b=0},
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data='0', x=-20,y=-20},
{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}},
}
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.width),scale(obj.height))
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
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)
if obj.w then
-- use an editor to wrap the text
obj.editor = edit.initialize_state(vy(obj.y), vx(obj.x), vx(obj.x+obj.w), scaled_fontsize, math.floor(scaled_fontsize*1.3))
obj.editor.lines = load_array(obj.data)
Text.redraw_all(obj.editor)
end
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}, true) -- hide cursor
end
end
end
end
{"box_height":44,"Viewport":29,"compute_layout":66,"Page":39,"vy":8,"parent":68,"on":1,"on.draw":69,"on.keychord_pressed":17,"on.code_changed":61,"Surface":68,"on.mouse_released":13,"on.mouse_pressed":12,"on.update":14,"scale":7,"vx":5}
{"box_height":44,"Viewport":29,"compute_layout":66,"Page":39,"vy":8,"parent":67,"on":1,"on.draw":67,"on.keychord_pressed":17,"on.code_changed":61,"Surface":68,"on.mouse_released":13,"on.mouse_pressed":12,"on.update":14,"scale":7,"vx":5}
Surface = {
-- test data
{type='rectangle', x=50,y=50, width=20,height=80, r=1,g=0,b=0},
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data='0', x=-20,y=-20},
{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}},
}
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.width),scale(obj.height))
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
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)
if obj.w then
-- use an editor to wrap the text
obj.editor = edit.initialize_state(vy(obj.y), vx(obj.x), vx(obj.x+obj.w), scaled_fontsize, math.floor(scaled_fontsize*1.3))
obj.editor.lines = load_array(obj.data)
Text.redraw_all(obj.editor)
end
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}, true) -- hide cursor
end
end
end
end
{"box_height":44,"Viewport":29,"compute_layout":66,"Page":39,"vy":8,"parent":66,"on":1,"on.draw":67,"on.keychord_pressed":17,"on.code_changed":61,"Surface":42,"on.mouse_released":13,"on.mouse_pressed":12,"on.update":14,"scale":7,"vx":5}
{"box_height":44,"Viewport":29,"compute_layout":66,"Page":39,"vy":8,"parent":65,"on":1,"on.draw":62,"on.keychord_pressed":17,"on.code_changed":61,"Surface":42,"on.mouse_released":13,"on.mouse_pressed":12,"on.update":14,"scale":7,"vx":5}
compute_layout = function(node, x,y)
if node.type == 'text' and node.width then
node.x = x
node.y = y
node.w = node.width
node.h = box_height(node)
end
return node
end
{"box_height":44,"Viewport":29,"compute_layout":65,"Page":39,"vy":8,"parent":64,"on":1,"on.draw":62,"on.keychord_pressed":17,"on.code_changed":61,"Surface":42,"on.mouse_released":13,"on.mouse_pressed":12,"on.update":14,"scale":7,"vx":5}
compute_layout = function(node, x,y)
if node.type == 'text' and node.width then
node.x = x
node.y = y
node.w = node.width
node.h = box_height(node)
end
return node
end
--[[
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursor
end
]]
{"box_height":44,"Viewport":29,"compute_layout":64,"Page":39,"vy":8,"parent":63,"on":1,"on.draw":62,"on.keychord_pressed":17,"on.code_changed":61,"Surface":42,"on.mouse_released":13,"on.mouse_pressed":12,"on.update":14,"scale":7,"vx":5}
compute_layout = function(node, x,y)
if node.type == 'text' and node.width then
node.x = x
node.y = y
node.editor = edit.initialize
node.editor.top = y
node.editor.left = x
node.editor.right = x + node.w
node.w = node.width
node.h = box_height(node)
end
return node
end
--[[
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
-- use an editor to wrap the text
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
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.editor = edit.initialize_state(vy(obj.y), vx(obj.x), vx(obj.x+obj.w), scaled_fontsize, math.floor(scaled_fontsize*1.3))
obj.editor.lines = load_array(obj.data)
Text.redraw_all(obj.editor)
end
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursor
end
]]
{"box_height":44,"Viewport":29,"compute_layout":63,"Page":39,"vy":8,"parent":62,"on":1,"on.draw":62,"on.keychord_pressed":17,"on.code_changed":61,"Surface":42,"on.mouse_released":13,"on.mouse_pressed":12,"on.update":14,"scale":7,"vx":5}
compute_layout = function(node, x,y)
if node.type == 'text' and node.width then
node.x = x
node.y = y
node.editor = edit.initialize
node.editor.top = y
node.editor.left = x
node.editor.right = x + node.w
node.w = node.width
node.h = dom.height(node)
end
return node
end
--[[
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.scaled_fontsize ~= scaled_fontsize then
obj.scaled_fontsize = scaled_fontsize
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
-- use an editor to wrap the text
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
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.editor = edit.initialize_state(vy(obj.y), vx(obj.x), vx(obj.x+obj.w), scaled_fontsize, math.floor(scaled_fontsize*1.3))
obj.editor.lines = load_array(obj.data)
Text.redraw_all(obj.editor)
end
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursor
end
]]
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.width),scale(obj.height))
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.scaled_fontsize ~= scaled_fontsize then
obj.scaled_fontsize = scaled_fontsize
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
-- use an editor to wrap the text
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
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.editor = edit.initialize_state(vy(obj.y), vx(obj.x), vx(obj.x+obj.w), scaled_fontsize, math.floor(scaled_fontsize*1.3))
obj.editor.lines = load_array(obj.data)
Text.redraw_all(obj.editor)
end
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursor
end
end
end
end
{"box_height":44,"Viewport":29,"compute_layout":60,"Page":39,"vy":8,"parent":61,"on":1,"on.draw":62,"on.keychord_pressed":17,"on.code_changed":61,"Surface":42,"on.mouse_released":13,"on.mouse_pressed":12,"on.update":14,"scale":7,"vx":5}
on.code_changed = function()
print('AAAAAAAAAAAAAAAAA')
local node = compute_layout(
{
type='text',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
0,0)
Surface = {node,
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data='0', x=-20,y=-20},
}
print('AAA', #Surface)
end
{"box_height":44,"Viewport":29,"compute_layout":60,"Page":39,"vy":8,"parent":60,"on":1,"on.draw":59,"on.keychord_pressed":17,"on.code_changed":61,"Surface":42,"on.mouse_released":13,"on.mouse_pressed":12,"on.update":14,"scale":7,"vx":5}
{"box_height":44,"Viewport":29,"compute_layout":60,"Page":39,"vy":8,"parent":59,"on":1,"on.draw":59,"on.keychord_pressed":17,"on.code_changed":58,"Surface":42,"on.mouse_released":13,"on.mouse_pressed":12,"on.update":14,"scale":7,"vx":5}
compute_layout = function(node, x,y)
if node.type == 'text' and node.width then
node.x = x
node.y = y
node.editor.top = y
node.editor.left = x
node.editor.right = x + node.w
node.w = node.width
node.h = dom.height(node)
end
return node
end
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.width),scale(obj.height))
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
print('rendering', obj.data)
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.scaled_fontsize ~= scaled_fontsize then
obj.scaled_fontsize = scaled_fontsize
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
-- use an editor to wrap the text
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
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.editor = edit.initialize_state(vy(obj.y), vx(obj.x), vx(obj.x+obj.w), scaled_fontsize, math.floor(scaled_fontsize*1.3))
obj.editor.lines = load_array(obj.data)
Text.redraw_all(obj.editor)
end
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursor
end
end
end
end
{"box_height":44,"Viewport":29,"compute_layout":51,"Page":39,"vy":8,"parent":58,"on":1,"on.draw":59,"on.keychord_pressed":17,"on.code_changed":58,"Surface":42,"on.mouse_released":13,"on.mouse_pressed":12,"on.update":14,"scale":7,"vx":5}
on.code_changed = function()
print('AAAAAAAAAAAAAAAAA')
local node = compute_layout(
{
type='edit',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
0,0)
Surface = {node,
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data='0', x=-20,y=-20},
}
print('AAA', #Surface)
end
{"box_height":44,"Viewport":29,"compute_layout":51,"Page":39,"vy":8,"parent":57,"on":1,"on.draw":43,"on.keychord_pressed":17,"on.code_changed":58,"Surface":42,"on.mouse_released":13,"on.mouse_pressed":12,"on.update":14,"scale":7,"vx":5}
on.code_changed = function()
print('AAAAAAAAAAAAAAAAA')
local node = compute_layout(
{
type='edit',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
0,0)
Surface = {node}
print('AAA', #Surface)
end
{"box_height":44,"Viewport":29,"compute_layout":51,"Page":39,"vy":8,"parent":56,"on":1,"on.draw":43,"on.keychord_pressed":17,"on.code_changed":57,"Surface":42,"on.mouse_released":13,"on.mouse_pressed":12,"on.update":14,"scale":7,"vx":5}
{"scale":7,"vx":5,"Viewport":29,"on.code_changed":55,"vy":8,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"Surface":42,"on.keychord_pressed":17,"compute_layout":51,"on":1,"parent":55,"Page":39,"on.draw":43,"box_height":44}
on.code_changed = function()
print('AAAAAAAAAAAAAAAAA')
local node = compute_layout(
{
type='edit',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
0,0)
Surface = {node}
print('AAA', #Surface)
end
{"scale":7,"vx":5,"Viewport":29,"on.code_changed":55,"vy":8,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"Surface":42,"on.keychord_pressed":17,"compute_layout":51,"on":1,"on.code_change":49,"parent":54,"Page":39,"on.draw":43,"box_height":44}
on.code_changed = function()
local node = compute_layout(
{
type='edit',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
0,0)
Surface = {node}
print('AAA', #Surface)
end
{"scale":7,"vx":5,"Viewport":29,"on.code_changed":54,"vy":8,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"Surface":42,"on.keychord_pressed":17,"compute_layout":51,"on":1,"on.code_change":49,"parent":53,"Page":39,"on.draw":43,"box_height":44}
on.code_changed = function()
local node = compute_layout(
{
type='edit',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
0,0)
Surface = {node}
print('AAA')
end
{"scale":7,"vx":5,"Viewport":29,"on.code_changed":53,"vy":8,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"Surface":42,"on.keychord_pressed":17,"compute_layout":51,"on":1,"on.code_change":49,"parent":52,"Page":39,"on.draw":43,"box_height":44}
on.code_changed = function()
local node = compute_layout(
{
type='edit',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
0,0)
Surface = {node}
end
{"scale":7,"vx":5,"Viewport":29,"on.code_changed":52,"vy":8,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"Surface":42,"on.keychord_pressed":17,"compute_layout":51,"on":1,"on.code_change":49,"parent":51,"Page":39,"on.draw":43,"box_height":44}
{"scale":7,"vx":5,"Viewport":29,"on.code_changed":50,"vy":8,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"Surface":42,"on.keychord_pressed":17,"compute_layout":51,"on":1,"on.code_change":49,"parent":50,"Page":39,"on.draw":43,"box_height":44}
compute_layout = function(node, x,y)
if node.type == 'text' and node.width then
node.x = x
node.y = y
node.editor.top = y
node.editor.left = x
node.editor.right = x + node.w
node.h = dom.height(node)
end
return node
end
on.code_changed = function()
Surface = compute_layout(
{
type='edit',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
0,0)
end
{"scale":7,"vx":5,"Viewport":29,"on.code_changed":50,"vy":8,"on.mouse_pressed":12,"on.mouse_released":13,"on.update":14,"Surface":42,"on.keychord_pressed":17,"compute_layout":46,"on":1,"on.code_change":49,"parent":49,"Page":39,"on.draw":43,"box_height":44}
on.code_change = function()
print('AAA')
Surface = compute_layout(
{
type='edit',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
0,0)
end
{"compute_layout":46,"vy":8,"on.code_change":49,"on.update":14,"on":1,"scale":7,"on.mouse_pressed":12,"parent":48,"on.mouse_released":13,"Page":39,"on.draw":43,"on.keychord_pressed":17,"vx":5,"Viewport":29,"box_height":44,"Surface":42}
on.code_change = function()
Surface = compute_layout(
{
type='edit',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
0,0)
end
{"compute_layout":46,"vy":8,"on.code_change":48,"on.update":14,"on":1,"scale":7,"on.mouse_pressed":12,"parent":47,"on.mouse_released":13,"Page":39,"on.draw":43,"on.keychord_pressed":17,"vx":5,"Viewport":29,"box_height":44,"Surface":42}
on.code_change = function()
-- Surface = compute_layout(
end
{"compute_layout":46,"vy":8,"on.code_change":47,"on.update":14,"on":1,"scale":7,"on.mouse_pressed":12,"parent":46,"on.mouse_released":13,"Page":39,"on.draw":43,"on.keychord_pressed":17,"vx":5,"Viewport":29,"box_height":44,"Surface":42}
{"parent":45,"box_height":44,"on.mouse_pressed":12,"Surface":42,"on.mouse_released":13,"on.draw":43,"compute_layout":46,"vx":5,"on":1,"Viewport":29,"on.keychord_pressed":17,"Page":39,"vy":8,"scale":7,"on.update":14}
compute_layout = function(node, x,y)
if node.type == 'text' and node.width then
node.x = x
node.y = y
node.editor.top = y
node.editor.left = x
node.editor.right = x + node.w
node.h = dom.height(node)
end
end
{"parent":44,"box_height":44,"on.mouse_pressed":12,"Surface":42,"on.mouse_released":13,"on.draw":43,"compute_layout":45,"vx":5,"on":1,"Viewport":29,"on.keychord_pressed":17,"Page":39,"vy":8,"scale":7,"on.update":14}
compute_layout = function(node, x,y)
if node.data then
node.x = x
node.y = y
node.editor.top = y
node.editor.left = x
node.editor.right = x + node.w
node.h = dom.height(node)
end
end
{"parent":43,"box_height":44,"on.mouse_pressed":12,"Surface":42,"on.mouse_released":13,"on.draw":43,"vx":5,"on":1,"Viewport":29,"on.keychord_pressed":17,"Page":39,"vy":8,"scale":7,"on.update":14}
box_height = function(node)
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.compute_fragments(node.editor, i)
Text.populate_screen_line_starting_pos(node.editor, i)
y = y + node.editor.line_height*#node.editor.line_cache[i].screen_line_starting_pos
Text.clear_screen_line_cache(node.editor, i)
end
return y
end
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.width),scale(obj.height))
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.scaled_fontsize ~= scaled_fontsize then
obj.scaled_fontsize = scaled_fontsize
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)
end
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
-- use an editor to wrap the text
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
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.editor = edit.initialize_state(vy(obj.y), vx(obj.x), vx(obj.x+obj.w), scaled_fontsize, math.floor(scaled_fontsize*1.3))
obj.editor.lines = load_array(obj.data)
Text.redraw_all(obj.editor)
end
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursor
end
end
end
end
{"Viewport":29,"Page":39,"vy":8,"vx":5,"Surface":42,"on.mouse_pressed":12,"on":1,"on.mouse_released":13,"on.draw":43,"on.update":14,"scale":7,"parent":42,"on.keychord_pressed":17}
{"Viewport":29,"Page":39,"vy":8,"vx":5,"Surface":42,"on.mouse_pressed":12,"on":1,"on.mouse_released":13,"on.draw":41,"on.update":14,"scale":7,"parent":41,"on.keychord_pressed":17}
Surface = {
-- test data
{type='rectangle', x=50,y=50, width=20,height=80, r=1,g=0,b=0},
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data='0', x=-20,y=-20},
{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}},
}
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.width),scale(obj.height))
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.scaled_fontsize ~= scaled_fontsize then
obj.scaled_fontsize = scaled_fontsize
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)
end
if obj.width == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
-- use an editor to wrap the text
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
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.editor = edit.initialize_state(vy(obj.y), vx(obj.x), vx(obj.x+obj.w), scaled_fontsize, math.floor(scaled_fontsize*1.3))
obj.editor.lines = load_array(obj.data)
Text.redraw_all(obj.editor)
end
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursor
end
end
end
end
{"Viewport":29,"Page":39,"vy":8,"vx":5,"Surface":38,"on.mouse_pressed":12,"on":1,"on.mouse_released":13,"on.draw":41,"on.update":14,"scale":7,"parent":40,"on.keychord_pressed":17}
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.width),scale(obj.height))
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.scaled_fontsize ~= scaled_fontsize then
obj.scaled_fontsize = scaled_fontsize
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)
end
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
elseif obj.type == 'edit' 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
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.editor = edit.initialize_state(vy(obj.y), vx(obj.x), vx(obj.x+obj.w), scaled_fontsize, math.floor(scaled_fontsize*1.3))
obj.editor.lines = load_array(obj.data)
Text.redraw_all(obj.editor)
end
-- for now the editor is just a way to line-wrap text. Hide the cursor.
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true)
end
end
end
{"Viewport":29,"Page":39,"vy":8,"vx":5,"Surface":38,"on.mouse_pressed":12,"on":1,"on.mouse_released":13,"on.draw":40,"on.update":14,"scale":7,"parent":39,"on.keychord_pressed":17}
{"Viewport":29,"Page":39,"vy":8,"vx":5,"Surface":38,"on.mouse_pressed":12,"on":1,"on.mouse_released":13,"on.draw":35,"on.update":14,"scale":7,"parent":38,"on.keychord_pressed":17}
Page = {
-- page
type='cols', x=0, y=0,
width=800, data={
-- editor covering left side
{
type='edit',
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- a table on the right
{ type='rows', name='searches', margin=50, data={
{ type='text', data={''},},
{ type='cols', data={
{ type='text', data={'search:'},},
{ type='edit', name='search', bg={r=0.8,g=0.8,b=0.8}, data={''}, width=90,},
}},
{ type='text', data={'table:'},},
{ type='cols', bg={r=0.8,g=0.8,b=0.8}, data={
{ type='rows', width=90, data={
{data={'abc'},},
{data={'abc'},},
}},
{ type='rows', width=90, data={
{data={'def'},},
{data={'def'},},
}},
}},
}},
},
}
{"Viewport":29,"Page":19,"vy":8,"vx":5,"Surface":38,"on.mouse_pressed":12,"on":1,"on.mouse_released":13,"on.draw":35,"on.update":14,"scale":7,"parent":37,"on.keychord_pressed":17}
Surface = {
-- test data
{type='rectangle', x=50,y=50, width=20,height=80, r=1,g=0,b=0},
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data='0', x=-20,y=-20},
{type='edit', 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}},
}
{"Viewport":29,"Page":19,"vy":8,"vx":5,"Surface":37,"on.mouse_pressed":12,"on":1,"on.mouse_released":13,"on.draw":35,"on.update":14,"scale":7,"parent":36,"on.keychord_pressed":17}
Surface = {
-- test data
{type='rectangle', x=50,y=50, width=20,height=80, r=1,g=0,b=0},
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data='0', x=-20,y=-20},
{type='edit', data={'abc', 'def'}, x=100, 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}},
}
{"Viewport":29,"Page":19,"vy":8,"vx":5,"Surface":36,"on.mouse_pressed":12,"on":1,"on.mouse_released":13,"on.draw":35,"on.update":14,"scale":7,"parent":35,"on.keychord_pressed":17}
Surface = {
-- test data
{type='rectangle', x=50,y=50, width=20,height=80, r=1,g=0,b=0},
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data='0', x=-20,y=-20},
{type='edit', data={'abc', 'def'}, x=100, y=50, w=50,h=50, fg={r=0,g=0, 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}},
}
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.width),scale(obj.height))
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.scaled_fontsize ~= scaled_fontsize then
obj.scaled_fontsize = scaled_fontsize
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)
end
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
elseif obj.type == 'edit' 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
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.editor = edit.initialize_state(vy(obj.y), vx(obj.x), vx(obj.x+obj.w), scaled_fontsize, math.floor(scaled_fontsize*1.3))
obj.editor.lines = load_array(obj.data)
Text.redraw_all(obj.editor)
end
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0})
end
end
end
{"Viewport":29,"Page":19,"vy":8,"vx":5,"Surface":33,"on.mouse_pressed":12,"on":1,"on.mouse_released":13,"on.draw":35,"on.update":14,"scale":7,"parent":34,"on.keychord_pressed":17}
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.width),scale(obj.height))
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
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.scaled_fontsize ~= scaled_fontsize then
obj.scaled_fontsize = scaled_fontsize
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)
end
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'edit' 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
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.editor = edit.initialize_state(vy(obj.y), vx(obj.x), vx(obj.x+obj.w), scaled_fontsize, math.floor(scaled_fontsize*1.3))
obj.editor.lines = load_array(obj.data)
Text.redraw_all(obj.editor)
end
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0})
end
end
end
{"on.keychord_pressed":17,"Viewport":29,"scale":7,"vy":8,"Page":19,"on.draw":34,"parent":33,"on.mouse_pressed":12,"Surface":33,"on.mouse_released":13,"on":1,"on.update":14,"vx":5}
{"on.keychord_pressed":17,"Viewport":29,"scale":7,"vy":8,"Page":19,"on.draw":32,"parent":32,"on.mouse_pressed":12,"Surface":33,"on.mouse_released":13,"on":1,"on.update":14,"vx":5}
Surface = {
-- test data
{type='rectangle', x=50,y=50, width=20,height=80, r=1,g=0,b=0},
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data='0', x=-20,y=-20},
--{type='edit', data={'abc', 'def'}, x=100, y=50, w=50,h=50, fg={r=0,g=0, 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}},
}
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.width),scale(obj.height))
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()
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.scaled_fontsize ~= scaled_fontsize then
obj.scaled_fontsize = scaled_fontsize
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)
end
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'edit' 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
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.editor = edit.initialize_state(vy(obj.y), vx(obj.x), vx(obj.x+obj.w), scaled_fontsize, math.floor(scaled_fontsize*1.3))
obj.editor.lines = load_array(obj.data)
Text.redraw_all(obj.editor)
end
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0})
end
end
end
{"on.keychord_pressed":17,"Viewport":29,"scale":7,"vy":8,"Page":19,"on.draw":32,"parent":31,"on.mouse_pressed":12,"Surface":30,"on.mouse_released":13,"on":1,"on.update":14,"vx":5}
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.width),scale(obj.height))
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()
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.scaled_fontsize ~= scaled_fontsize then
obj.scaled_fontsize = scaled_fontsize
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)
end
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'edit' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.editor == nil or obj.scaled_fontsize ~= scaled_fontsize then
obj.scaled_fontsize = scaled_fontsize
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.editor = edit.initialize_state(vy(obj.y), vx(obj.x), vx(obj.x+obj.w), scaled_fontsize, math.floor(scaled_fontsize*1.3))
obj.editor.lines = load_array(obj.data)
Text.redraw_all(obj.editor)
end
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0})
end
end
end
{"on.keychord_pressed":17,"Viewport":29,"scale":7,"vy":8,"Page":19,"on.draw":31,"parent":30,"on.mouse_pressed":12,"Surface":30,"on.mouse_released":13,"on":1,"on.update":14,"vx":5}
{"on.keychord_pressed":17,"Viewport":29,"scale":7,"vy":8,"Page":19,"on.draw":27,"parent":29,"on.mouse_pressed":12,"Surface":30,"on.mouse_released":13,"on":1,"on.update":14,"vx":5}
Surface = {
-- test data
{type='rectangle', x=50,y=50, width=20,height=80, r=1,g=0,b=0},
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data='0', x=-20,y=-20},
{type='edit', data={'abc', 'def'}, x=100, y=50, w=50,h=50, fg={r=0,g=0, 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}},
}
{"on.keychord_pressed":17,"Viewport":29,"scale":7,"vy":8,"Page":19,"on.draw":27,"parent":28,"on.mouse_pressed":12,"Surface":28,"on.mouse_released":13,"on":1,"on.update":14,"vx":5}
Viewport = {x=-50, y=-50, w=800,h=600, zoom=1.5}
{"on.keychord_pressed":17,"Viewport":6,"scale":7,"vy":8,"Page":19,"on.draw":27,"parent":27,"on.mouse_pressed":12,"Surface":28,"on.mouse_released":13,"on":1,"on.update":14,"vx":5}
Surface = {
-- test data
{type='rectangle', x=50,y=50, width=20,height=80, r=1,g=0,b=0},
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data='0', x=-20,y=-20},
{type='edit', data={'abc', 'def'}, x=100, y=50, w=50,h=50, fg={r=0,g=0, b=0.5}},
{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}},
}
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.width),scale(obj.height))
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()
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.scaled_fontsize ~= scaled_fontsize then
obj.scaled_fontsize = scaled_fontsize
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)
end
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'edit' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.editor == nil or obj.scaled_fontsize ~= scaled_fontsize then
obj.scaled_fontsize = scaled_fontsize
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.editor = edit.initialize_state(obj.y, obj.x, obj.x+obj.w, scaled_fontsize, math.floor(scaled_fontsize*1.3))
obj.editor.lines = load_array(obj.data)
Text.redraw_all(obj.editor)
end
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0})
end
end
end
{"on.keychord_pressed":17,"Viewport":6,"scale":7,"vy":8,"Page":19,"on.draw":27,"parent":26,"on.mouse_pressed":12,"Surface":20,"on.mouse_released":13,"on":1,"on.update":14,"vx":5}
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.width),scale(obj.height))
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()
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.scaled_fontsize ~= scaled_fontsize then
obj.scaled_fontsize = scaled_fontsize
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)
end
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'edit' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.editor == nil or obj.scaled_fontsize ~= scaled_fontsize then
obj.scaled_fontsize = scaled_fontsize
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
print(edit, edit.initialize)
obj.editor = edit.initialize(obj.y, obj.x, obj.x+obj.w, scaled_fontsize, math.floor(scaled_fontsize*1.3))
obj.editor.lines = load_array(obj.data)
Text.redraw_all(obj.editor)
end
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0})
end
end
end
{"on.keychord_pressed":17,"Viewport":6,"scale":7,"vy":8,"Page":19,"on.draw":26,"parent":25,"on.mouse_pressed":12,"Surface":20,"on.mouse_released":13,"on":1,"on.update":14,"vx":5}
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.width),scale(obj.height))
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()
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.scaled_fontsize ~= scaled_fontsize then
obj.scaled_fontsize = scaled_fontsize
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)
end
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'edit' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.editor == nil or obj.scaled_fontsize ~= scaled_fontsize then
obj.scaled_fontsize = scaled_fontsize
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
print(edit)
obj.editor = edit.initialize(obj.y, obj.x, obj.x+obj.w, scaled_fontsize, math.floor(scaled_fontsize*1.3))
obj.editor.lines = load_array(obj.data)
Text.redraw_all(obj.editor)
end
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0})
end
end
end
{"on.keychord_pressed":17,"Viewport":6,"scale":7,"vy":8,"Page":19,"on.draw":25,"parent":24,"on.mouse_pressed":12,"Surface":20,"on.mouse_released":13,"on":1,"on.update":14,"vx":5}
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.width),scale(obj.height))
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()
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.scaled_fontsize ~= scaled_fontsize then
obj.scaled_fontsize = scaled_fontsize
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)
end
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'edit' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.editor == nil or obj.scaled_fontsize ~= scaled_fontsize then
obj.scaled_fontsize = scaled_fontsize
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.editor = edit.initialize(obj.y, obj.x, obj.x+obj.w, scaled_fontsize, math.floor(scaled_fontsize*1.3))
obj.editor.lines = load_array(obj.data)
Text.redraw_all(obj.editor)
end
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0})
end
end
end
{"on.keychord_pressed":17,"Viewport":6,"scale":7,"vy":8,"Page":19,"on.draw":24,"parent":23,"on.mouse_pressed":12,"Surface":20,"on.mouse_released":13,"on":1,"on.update":14,"vx":5}
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.width),scale(obj.height))
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()
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.scaled_fontsize ~= scaled_fontsize then
obj.scaled_fontsize = scaled_fontsize
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)
end
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'edit' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.scaled_fontsize ~= scaled_fontsize then
obj.scaled_fontsize = scaled_fontsize
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.editor = edit.initialize(obj.y, obj.x, obj.x+obj.w, scaled_fontsize, math.floor(scaled_fontsize*1.3))
obj.editor.lines = load_array(obj.data)
Text.redraw_all(obj.editor)
end
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0})
end
end
end
{"on.keychord_pressed":17,"Viewport":6,"scale":7,"vy":8,"Page":19,"on.draw":23,"parent":22,"on.mouse_pressed":12,"Surface":20,"on.mouse_released":13,"on":1,"on.update":14,"vx":5}
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.width),scale(obj.height))
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()
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.scaled_fontsize ~= scaled_fontsize then
obj.scaled_fontsize = scaled_fontsize
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)
end
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
end
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'edit' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.scaled_fontsize ~= scaled_fontsize then
obj.scaled_fontsize = scaled_fontsize
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.editor = edit.initialize(obj.y, obj.x, obj.x+obj.w, scaled_fontsize, math.floor(scaled_fontsize*1.3))
obj.editor.lines = load_array(obj.data)
end
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0})
end
end
end
{"on.keychord_pressed":17,"Viewport":6,"scale":7,"vy":8,"Page":19,"on.draw":22,"parent":21,"on.mouse_pressed":12,"Surface":20,"on.mouse_released":13,"on":1,"on.update":14,"vx":5}
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.width),scale(obj.height))
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()
elseif obj.type == 'text' then
local scaled_fontsize = scale(obj.fontsize or 20)
if obj.scaled_fontsize ~= scaled_fontsize then
obj.scaled_fontsize = scaled_fontsize
if Font == nil then Font = {} end
if Font[scaled_fontsize] == nil then
Font[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)
end
obj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)
end
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
end
love.graphics.line(unpack(obj.zdata))
end
end
end
{"on.keychord_pressed":17,"Viewport":6,"scale":7,"vy":8,"Page":19,"on.draw":21,"parent":20,"on.mouse_pressed":12,"Surface":20,"on.mouse_released":13,"on":1,"on.update":14,"vx":5}
{"on.keychord_pressed":17,"Viewport":6,"scale":7,"vy":8,"Page":19,"on.draw":11,"parent":19,"on.mouse_pressed":12,"Surface":20,"on.mouse_released":13,"on":1,"on.update":14,"vx":5}
Surface = {
-- test data
{type='rectangle', x=50,y=50, width=20,height=80, r=1,g=0,b=0},
{type='line', data={0,0, 0,600}},
{type='line', data={0,0, 800,0}},
{type='text', data='0', x=-20,y=-20},
{type='edit', data={'abc', 'def'}, x=100, y=50, w=50,h=50,},
{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}},
}
{"on.keychord_pressed":17,"Viewport":6,"scale":7,"vy":8,"Page":19,"on.draw":11,"parent":18,"on.mouse_pressed":12,"Surface":3,"on.mouse_released":13,"on":1,"on.update":14,"vx":5}
Page = {
-- page
x=0, y=0,
width=800, cols={
-- editor covering left side
{
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
width=400, bg={r=1,g=1,b=0}
},
-- a table on the right
{ name='searches', margin=50, rows={
{ data={''},},
{ cols={
{ data={'search:'},},
{ name='search', bg={r=0.8,g=0.8,b=0.8}, data={''}, width=90,},
}},
{ data={'table:'},},
{ bg={r=0.8,g=0.8,b=0.8}, cols={
{ width=90, rows={
{data={'abc'},},
{data={'abc'},},
}},
{ width=90, rows={
{data={'def'},},
{data={'def'},},
}},
}},
}},
},
}
{"on.keychord_pressed":17,"Viewport":6,"scale":7,"vy":8,"Page":18,"on.draw":11,"parent":17,"on.mouse_pressed":12,"Surface":3,"on.mouse_released":13,"on":1,"on.update":14,"vx":5}
Page = {
-- page
x=0, y=0,
w=800, cols={
-- editor covering left side
{
name='editor',
doc='prose goes here, on the left half of the window',
margin=Margin_left,
data={"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",},
w=400, bg={r=1,g=1,b=0}
},
-- a table on the right
{ name='searches', margin=50, rows={
{ data={''}, w=90,},
{ cols={
{ data={'search:'}, w=90,},
{ name='search', bg={r=0.8,g=0.8,b=0.8}, data={''}, w=90,},
}},
{ data={''}, w=90,},
{ data={'table:'}, w=90,},
{ bg={r=0.8,g=0.8,b=0.8}, rows={
{ cols={
{data={'abc'}, w=90,},
{data={'def'}, w=90,},
}},
{ cols={
{data={'abc'}, w=90,},
{data={'def'}, w=90,},
}},
}},
}},
},
}