We can't edit any text yet.
YUQ4YINAT5YTK3CAY4VK3HSYQ4D63FXLLPMC4R3DUFHIZIUQO7WQC on.draw = function()for _,obj in ipairs(Surface) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeobj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)initialize_editor(obj)endif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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 textnode.x = xnode.y = y-- render background if necessarylocal node_to_renderif node.bg thennode_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 contentsif node.width thennode.w = node.widthelselocal scaled_fontsize = scale(node.fontsize or 20)node.w = 0for _,s in ipairs(node.data) dolocal text = love.graphics.newText(font(node, scaled_fontsize), node.data)local width = text:getWidth()if node.w < width then node.w = width endendendinitialize_editor(node)node.h = box_height(node)table.insert(nodes_to_render, node)if node_to_render thennode_to_render.w = node.wnode_to_render.h = node.hendelseif node.type == 'rows' thennode.x = xnode.y = ylocal node_to_renderif node.bg thennode_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 bottomlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendsubx,suby = compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = hif node_to_render thennode_to_render.w = wnode_to_render.h = hendelseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal node_to_renderif node.bg thennode_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)endlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendsubx,suby = compute_layout(child, subx,y, nodes_to_render)w = w + child.wif h < child.h thenh = child.hendendnode.w = wnode.h = hif node_to_render thennode_to_render.w = wnode_to_render.h = hendendreturn x+node.w,y+node.hend
{"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 textnode.x = xnode.y = y-- render background if necessarylocal node_to_renderif node.bg thennode_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 contentsif node.width thennode.w = node.widthelselocal scaled_fontsize = scale(node.fontsize or 20)node.w = 0for _,s in ipairs(node.data) dolocal text = love.graphics.newText(font(node, scaled_fontsize), node.data)local width = text:getWidth()if node.w < width then node.w = width endendendinitialize_editor(node)node.h = box_height(node)table.insert(nodes_to_render, node)if node_to_render thennode_to_render.w = node.wnode_to_render.h = node.hendelseif node.type == 'rows' thennode.x = xnode.y = ylocal node_to_renderif node.bg thennode_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 bottomlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendsubx,suby = compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = hif node_to_render thennode_to_render.w = wnode_to_render.h = hendelseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal node_to_renderif node.bg thennode_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)endlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendsubx,suby = compute_layout(child, subx,y, nodes_to_render)w = w + child.wif h < child.h thenh = child.hendendnode.w = wnode.h = hif node_to_render thennode_to_render.w = wnode_to_render.h = hendendreturn x+node.w,y+node.hend
on.draw = function()for _,obj in ipairs(Surface) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenprint('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' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeobj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)initialize_editor(obj)endif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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' thenlocal node_to_renderif node.bg thennode_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 textnode.x = xnode.y = yif node.width thennode.w = node.widthelselocal scaled_fontsize = scale(node.fontsize or 20)node.w = 0for _,s in ipairs(node.data) dolocal text = love.graphics.newText(font(node, scaled_fontsize), node.data)local width = text:getWidth()if node.w < width then node.w = width endendendinitialize_editor(node)node.h = box_height(node)table.insert(nodes_to_render, node)if node_to_render thennode_to_render.w = node.wnode_to_render.h = node.hendelseif node.type == 'rows' thennode.x = xnode.y = ylocal node_to_renderif node.bg thennode_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 bottomlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendsubx,suby = compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = hif node_to_render thennode_to_render.w = wnode_to_render.h = hendelseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal node_to_renderif node.bg thennode_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)endlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendsubx,suby = compute_layout(child, subx,y, nodes_to_render)w = w + child.wif h < child.h thenh = child.hendendnode.w = wnode.h = hif node_to_render thennode_to_render.w = wnode_to_render.h = hendendreturn x+node.w,y+node.hend
{"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 textnode.x = xnode.y = yif node.width thennode.w = node.widthelselocal scaled_fontsize = scale(node.fontsize or 20)node.w = 0for _,s in ipairs(node.data) dolocal text = love.graphics.newText(font(node, scaled_fontsize), node.data)local width = text:getWidth()if node.w < width then node.w = width endendendinitialize_editor(node)node.h = box_height(node)table.insert(nodes_to_render, node)elseif node.type == 'rows' thennode.x = xnode.y = ylocal node_to_renderif node.bg thennode_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 bottomlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendsubx,suby = compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = hif node_to_render thennode_to_render.w = wnode_to_render.h = hendelseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal node_to_renderif node.bg thennode_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)endlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendsubx,suby = compute_layout(child, subx,y, nodes_to_render)w = w + child.wif h < child.h thenh = child.hendendnode.w = wnode.h = hif node_to_render thennode_to_render.w = wnode_to_render.h = hendendreturn x+node.w,y+node.hend
{"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 textnode.x = xnode.y = yif node.width thennode.w = node.widthelselocal scaled_fontsize = scale(node.fontsize or 20)node.w = 0for _,s in ipairs(node.data) dolocal text = love.graphics.newText(font(node, scaled_fontsize), node.data)local width = text:getWidth()if node.w < width then node.w = width endendendinitialize_editor(node)node.h = box_height(node)table.insert(nodes_to_render, node)elseif node.type == 'rows' thennode.x = xnode.y = y-- lay out children top to bottomlocal node_to_renderif node.bg thennode_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)endlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendsubx,suby = compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = hif node_to_render thennode_to_render.w = wnode_to_render.h = hendelseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendsubx,suby = compute_layout(child, subx,y, nodes_to_render)w = w + child.wif h < child.h thenh = child.hendendnode.w = wnode.h = hif node.bg thentable.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})endendreturn x+node.w,y+node.hend
{"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 textnode.x = xnode.y = yif node.width thennode.w = node.widthelselocal scaled_fontsize = scale(node.fontsize or 20)node.w = 0for _,s in ipairs(node.data) dolocal text = love.graphics.newText(font(node, scaled_fontsize), node.data)local width = text:getWidth()if node.w < width then node.w = width endendendinitialize_editor(node)node.h = box_height(node)table.insert(nodes_to_render, node)elseif node.type == 'rows' thennode.x = xnode.y = y-- lay out children top to bottomlocal node_to_renderif node.bg thennode_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)endlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendsubx,suby = compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = hif node_to_render thennode_to_render.w = wnode_to_render.h = hendelseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendsubx,suby = compute_layout(child, subx,y, nodes_to_render)w = w + child.wif h < child.h thenh = child.hendendnode.w = wnode.h = hif node.bg thentable.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})endendreturn x+node.w,y+node.hend
on.draw = function()for _,obj in ipairs(Surface) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenprint('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' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeobj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)initialize_editor(obj)endif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenprint('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' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeobj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)initialize_editor(obj)endif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseprint('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 cursorendendendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeobj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)initialize_editor(obj)endif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseprint('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 cursorendendendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeobj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)initialize_editor(obj)endif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseprint('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 cursorendendendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeobj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)initialize_editor(obj)endif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseprint('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 cursorendendendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeobj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)initialize_editor(obj)endprint('draw text', obj.data[1], obj.editor.lines[1].data, obj.w)if obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeobj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)initialize_editor(obj)endif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeobj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)initialize_editor(obj)endprint('draw text', obj.data, obj.data[1], obj.w, obj.fg)if obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeobj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)initialize_editor(obj)endprint('draw text', obj.data, obj.data[1], obj.w)if obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeobj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)initialize_editor(obj)endif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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 dotable.remove(Surface)endcompute_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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeprint('updating editor', obj.data[1])obj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)initialize_editor(obj)endif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeobj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)initialize_editor(obj)endif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenprint('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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeobj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)initialize_editor(obj)endedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenprint('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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeobj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)initialize_editor(obj)endedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenprint('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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeobj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)initialize_editor(obj)endassert(obj.w)edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendend
{"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 dotable.remove(Surface)endcompute_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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenprint('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 thenprint('initializing editor')obj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeinitialize_editor(obj)print('updating editor', obj.editor)endprint('editor', obj.editor)edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenprint('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 thenprint('initializing editor')obj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeinitialize_editor(obj)print('updating editor', obj.editor)endprint('editor', obj.editor)edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenprint('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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeinitialize_editor(obj)print('updating editor', obj.editor)endedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendend
{"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 textnode.x = xnode.y = yif node.width thennode.w = node.widthelselocal scaled_fontsize = scale(node.fontsize or 20)node.w = 0for _,s in ipairs(node.data) dolocal text = love.graphics.newText(font(node, scaled_fontsize), node.data)local width = text:getWidth()if node.w < width then node.w = width endendendinitialize_editor(node)print('node editor', node.editor)node.h = box_height(node)table.insert(nodes_to_render, node)elseif node.type == 'rows' thennode.x = xnode.y = y-- lay out children top to bottomlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendsubx,suby = compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = hif node.bg thentable.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})endelseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendsubx,suby = compute_layout(child, subx,y, nodes_to_render)w = w + child.wif h < child.h thenh = child.hendendnode.w = wnode.h = hif node.bg thentable.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})endendreturn x+node.w,y+node.hend
on.code_changed = function()print('on.code_changed')while #Surface > 3 dotable.remove(Surface)endcompute_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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenprint('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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeinitialize_editor(obj)print('updating editor', obj.editor)endedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendend
{"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 textnode.x = xnode.y = yif node.width thennode.w = node.widthelselocal scaled_fontsize = scale(node.fontsize or 20)node.w = 0for _,s in ipairs(node.data) dolocal text = love.graphics.newText(font(node, scaled_fontsize), node.data)local width = text:getWidth()if node.w < width then node.w = width endendendinitialize_editor(node)print('node editor', node.editor)node.h = box_height(node)table.insert(nodes_to_render, node)elseif node.type == 'rows' thennode.x = xnode.y = y-- lay out children top to bottomlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendsubx,suby = compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = hif node.bg thentable.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})endelseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendsubx,suby = compute_layout(child, subx,y, nodes_to_render)w = w + child.wif h < child.h thenh = child.hendendnode.w = wnode.h = hif node.bg thentable.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})endendreturn x+node.w,y+node.hend
{"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 textnode.x = xnode.y = yif node.width thennode.w = node.widthelselocal scaled_fontsize = scale(node.fontsize or 20)node.w = 0for _,s in ipairs(node.data) dolocal text = love.graphics.newText(font(node, scaled_fontsize), node.data)local width = text:getWidth()if node.w < width then node.w = width endendendinitialize_editor(node)print(node.editor)node.h = box_height(node)table.insert(nodes_to_render, node)elseif node.type == 'rows' thennode.x = xnode.y = y-- lay out children top to bottomlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendsubx,suby = compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = hif node.bg thentable.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})endelseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendsubx,suby = compute_layout(child, subx,y, nodes_to_render)w = w + child.wif h < child.h thenh = child.hendendnode.w = wnode.h = hif node.bg thentable.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})endendreturn x+node.w,y+node.hend
on.draw = function()for _,obj in ipairs(Surface) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenprint('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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeobj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)initialize_editor(obj)endedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenprint('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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeobj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)initialize_editor(obj)endif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenprint('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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeobj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)initialize_editor(obj)endif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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 textnode.x = xnode.y = yif node.width thennode.w = node.widthelselocal scaled_fontsize = scale(node.fontsize or 20)node.w = 0for _,s in ipairs(node.data) dolocal text = love.graphics.newText(font(node, scaled_fontsize), node.data)local width = text:getWidth()if node.w < width then node.w = width endendendinitialize_editor(node)node.h = box_height(node)table.insert(nodes_to_render, node)elseif node.type == 'rows' thennode.x = xnode.y = y-- lay out children top to bottomlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendsubx,suby = compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = hif node.bg thentable.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})endelseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendsubx,suby = compute_layout(child, subx,y, nodes_to_render)w = w + child.wif h < child.h thenh = child.hendendnode.w = wnode.h = hif node.bg thentable.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})endendreturn x+node.w,y+node.hend
{"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 textnode.x = xnode.y = yif node.width thennode.w = node.widthelselocal 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()endinitialize_editor(node)node.h = box_height(node)table.insert(nodes_to_render, node)elseif node.type == 'rows' thennode.x = xnode.y = y-- lay out children top to bottomlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendsubx,suby = compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = hif node.bg thentable.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})endelseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendsubx,suby = compute_layout(child, subx,y, nodes_to_render)w = w + child.wif h < child.h thenh = child.hendendnode.w = wnode.h = hif node.bg thentable.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})endendreturn x+node.w,y+node.hend
{"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 textnode.x = xnode.y = yif node.width thennode.w = node.widthelselocal 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()endinitialize_editor(node)node.h = box_height(node)table.insert(nodes_to_render, node)elseif node.type == 'rows' thennode.x = xnode.y = y-- lay out children top to bottomlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendsubx,suby = compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = hif node.bg thentable.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})endelseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendsubx,suby = compute_layout(child, subx,y, nodes_to_render)w = w + child.wif h < child.h thenh = child.hendendnode.w = wnode.h = hif node.bg thentable.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})endendreturn x+node.w,y+node.hend
on.draw = function()for _,obj in ipairs(Surface) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeobj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)initialize_editor(obj)endif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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) doprint(obj.type, obj.data)love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeobj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)initialize_editor(obj)endif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeobj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)initialize_editor(obj)endif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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 textnode.x = xnode.y = yif node.width thennode.w = node.widthelselocal scaled_fontsize = scale(node.fontsize or 20)node.text = love.graphics.newText(font(node, scaled_fontsize), node.data)node.w = node.text:getWidth()endinitialize_editor(node)node.h = box_height(node)table.insert(nodes_to_render, node)elseif node.type == 'rows' thennode.x = xnode.y = y-- lay out children top to bottomlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendsubx,suby = compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = hif node.bg thentable.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})endelseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendsubx,suby = compute_layout(child, subx,y, nodes_to_render)w = w + child.wif h < child.h thenh = child.hendendnode.w = wnode.h = hif node.bg thentable.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})endendreturn x+node.w,y+node.hend
{"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 textnode.x = xnode.y = yif node.width thennode.w = node.widthelselocal scaled_fontsize = scale(node.fontsize or 20)node.text = love.graphics.newText(font(node, scaled_fontsize), node.data)node.w = node.text:getWidth()endinitialize_editor(node)node.h = box_height(node)table.insert(nodes_to_render, node)elseif node.type == 'rows' thennode.x = xnode.y = y-- lay out children top to bottomlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendsubx,suby = compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = helseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendsubx,suby = compute_layout(child, subx,y, nodes_to_render)w = w + child.wif h < child.h thenh = child.hendendnode.w = wnode.h = hendreturn x+node.w,y+node.hend
on.draw = function()for _,obj in ipairs(Surface) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.width),scale(obj.height))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeobj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)initialize_editor(obj)endif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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 textnode.x = xnode.y = yif node.width thennode.w = node.widthelselocal scaled_fontsize = scale(node.fontsize or 20)node.text = love.graphics.newText(font(node, scaled_fontsize), node.data)node.w = node.text:getWidth()endinitialize_editor(node)node.h = box_height(node)elseif node.type == 'rows' thennode.x = xnode.y = y-- lay out children top to bottomlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendsubx,suby = compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = helseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendsubx,suby = compute_layout(child, subx,y, nodes_to_render)w = w + child.wif h < child.h thenh = child.hendendnode.w = wnode.h = hendreturn x+node.w,y+node.hend
{"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 = {-- pagetype='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 = {-- pagetype='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 dotable.remove(Surface)endcompute_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 dotable.remove(Surface)endcompute_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 textnode.x = xnode.y = yif node.width thennode.w = node.widthelselocal scaled_fontsize = scale(node.fontsize or 20)node.text = love.graphics.newText(font(node, scaled_fontsize), node.data)node.w = node.text:getWidth()endinitialize_editor(node)node.h = box_height(node)elseif node.type == 'rows' thennode.x = xnode.y = y-- lay out children top to bottomlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendsubx,suby = compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = helseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendsubx,suby = compute_layout(child, subx,y, nodes_to_render)w = w + child.wif h < child.h thenh = child.hendendnode.w = wnode.h = hendreturn x+node.w,y+node.hend
{"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 textnode.x = xnode.y = yif node.width thennode.w = node.widthelselocal scaled_fontsize = scale(node.fontsize or 20)node.text = love.graphics.newText(font(node, scaled_fontsize), node.data)node.w = node.text:getWidth()endinitialize_editor(node)node.h = box_height(node)elseif node.type == 'rows' thennode.x = xnode.y = y-- lay out children top to bottomlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendsubx,suby = compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = helseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendsubx,suby = compute_layout(child, subx,y, nodes_to_render)w = w + child.wif h < child.h thenh = child.hendendnode.w = wnode.h = hendreturn x+node.w,y+node.hend
on.draw = function()for i,obj in ipairs(Surface) doprint(i, obj.type)love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.width),scale(obj.height))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeobj.text = love.graphics.newText(font(obj, scaled_fontsize), obj.data)initialize_editor(obj)endif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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 = {} endif Font[fontsize] == nil thenFont[fontsize] = love.graphics.newFont(fontsize)endreturn Font[fontsize]end
on.code_changed = function()while #Surface > 3 dotable.remove(Surface)endcompute_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 textnode.x = xnode.y = ynode.w = node.widthinitialize_editor(node)node.h = box_height(node)elseif node.type == 'rows' thennode.x = xnode.y = y-- lay out children top to bottomlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendsubx,suby = compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = helseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendsubx,suby = compute_layout(child, subx,y, nodes_to_render)w = w + child.wif h < child.h thenh = child.hendendnode.w = wnode.h = hendreturn x+node.w,y+node.hend
{"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 textnode.x = xnode.y = ynode.w = node.widthinitialize_editor(node)node.h = box_height(node)elseif node.type == 'rows' thennode.x = xnode.y = y-- lay out children top to bottomlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendsubx,suby = compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = helseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendsubx,suby = compute_layout(child, subx,y, nodes_to_render)w = w + child.wif h < child.h thenh = child.hendendnode.w = wnode.h = hendreturn x+node.w,y+node.hend
{"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 textnode.x = xnode.y = ynode.w = node.widthinitialize_editor(node)node.h = box_height(node)elseif node.type == 'rows' thennode.x = xnode.y = y-- lay out children top to bottomlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendsubx,suby = compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = helseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendsubx,suby = compute_layout(child, subx,y, nodes_to_render)w = w + child.wif h < child.h thenh = child.hendendnode.w = wnode.h = hendreturn x+node.w,y+node.hend
{"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 textnode.x = xnode.y = ynode.w = node.widthinitialize_editor(node)node.h = box_height(node)elseif node.type == 'rows' thennode.x = xnode.y = y-- lay out children top to bottomlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendsubx,suby = compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = helseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendsubx,suby = compute_layout(child, subx,y, nodes_to_render)w = w + child.wif h < child.h thenh = child.hendendnode.w = wnode.h = hendreturn x+node.w,y+node.hend
on.code_changed = function()while #Surface > 3 dotable.remove(Surface)endcompute_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 dotable.remove(Surface)endcompute_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 dotable.remove(Surface)endcompute_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 textnode.x = xnode.y = ynode.w = node.widthinitialize_editor(node)node.h = box_height(node)elseif node.type == 'rows' thennode.x = xnode.y = y-- lay out children top to bottomlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendsubx,suby = dom.compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = helseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendsubx,suby = dom.compute_layout(child, subx,y, nodes_to_render)w = w + child.wif h < child.h thenh = child.hendendnode.w = wnode.h = hendreturn x+node.w,y+node.hend
on.code_changed = function()while #Surface > 3 dotable.remove(Surface)endlocal 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 textnode.x = xnode.y = ynode.w = node.widthinitialize_editor(node)node.h = box_height(node)elseif node.type == 'rows' thennode.x = xnode.y = y-- lay out children top to bottomlocal subx,suby = x,ylocal w,h = 0,0local subnodesfor _,child in ipairs(node.data) doif child.margin thensuby = suby+child.marginh = h+child.marginendsubx,suby = dom.compute_layout(child, x,suby, nodes_to_render)if w < child.w thenw = child.wendh = h+child.hendnode.w = wnode.h = helseif node.type == 'cols' thennode.x = xnode.y = y-- lay out children left to rightlocal subx,suby = x,ylocal w,h = 0,0for _,child in ipairs(node.data) doif child.margin thensubx = subx+child.marginw = w+child.marginendsubx,suby = dom.compute_layout(child, subx,y, nodes_to_render)w = w + child.wif h < child.h thenh = child.hendendnode.w = wnode.h = hendreturn x+node.w,y+node.hend
on.draw = function()for i,obj in ipairs(Surface) doprint(i, obj.type)love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.width),scale(obj.height))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenprint(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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)initialize_editor(obj)endif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.width),scale(obj.height))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenprint(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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)initialize_editor(obj)endif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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 = {-- pagetype='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 thennode.x = xnode.y = ynode.w = node.widthinitialize_editor(node)node.h = box_height(node)endreturn nodeend
{"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 textlocal 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)endend
{"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 thennode.x = xnode.y = ynode.w = node.widthinitialize_editor(node)node.h = box_height(node)endreturn nodeend
on.draw = function()for _,obj in ipairs(Surface) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.width),scale(obj.height))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)initialize_editor(obj)endif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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 textobj.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)endend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.width),scale(obj.height))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)if obj.w then-- use an editor to wrap the textobj.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)endendif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.width),scale(obj.height))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)if obj.w then-- use an editor to wrap the textobj.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)endendif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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 thennode.x = xnode.y = ynode.w = node.widthnode.h = box_height(node)endreturn nodeend
{"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 thennode.x = xnode.y = ynode.w = node.widthnode.h = box_height(node)endreturn nodeend--[[edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorend]]
{"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 thennode.x = xnode.y = ynode.editor = edit.initializenode.editor.top = ynode.editor.left = xnode.editor.right = x + node.wnode.w = node.widthnode.h = box_height(node)endreturn nodeend--[[if obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))else-- use an editor to wrap the textlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.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)endedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorend]]
{"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 thennode.x = xnode.y = ynode.editor = edit.initializenode.editor.top = ynode.editor.left = xnode.editor.right = x + node.wnode.w = node.widthnode.h = dom.height(node)endreturn nodeend--[[local scaled_fontsize = scale(obj.fontsize or 20)if obj.scaled_fontsize ~= scaled_fontsize thenobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)endif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))else-- use an editor to wrap the textlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.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)endedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorend]]
on.draw = function()for _,obj in ipairs(Surface) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.width),scale(obj.height))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal scaled_fontsize = scale(obj.fontsize or 20)if obj.scaled_fontsize ~= scaled_fontsize thenobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)endif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))else-- use an editor to wrap the textlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.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)endedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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 thennode.x = xnode.y = ynode.editor.top = ynode.editor.left = xnode.editor.right = x + node.wnode.w = node.widthnode.h = dom.height(node)endreturn nodeend
on.draw = function()for _,obj in ipairs(Surface) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.width),scale(obj.height))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenprint('rendering', obj.data)local scaled_fontsize = scale(obj.fontsize or 20)if obj.scaled_fontsize ~= scaled_fontsize thenobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)endif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))else-- use an editor to wrap the textlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.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)endedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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 thennode.x = xnode.y = ynode.editor.top = ynode.editor.left = xnode.editor.right = x + node.wnode.h = dom.height(node)endreturn nodeend
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 thennode.x = xnode.y = ynode.editor.top = ynode.editor.left = xnode.editor.right = x + node.wnode.h = dom.height(node)endend
{"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 thennode.x = xnode.y = ynode.editor.top = ynode.editor.left = xnode.editor.right = x + node.wnode.h = dom.height(node)endend
{"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 = 0for i=1,#node.editor.lines dolocal line = node.editor.lines[i]if node.editor.line_cache[i] == nil thennode.editor.line_cache[i] = {}endnode.editor.line_cache[i].fragments = nilnode.editor.line_cache[i].screen_line_starting_pos = nilText.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_posText.clear_screen_line_cache(node.editor, i)endreturn yend
on.draw = function()for _,obj in ipairs(Surface) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.width),scale(obj.height))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal scaled_fontsize = scale(obj.fontsize or 20)if obj.scaled_fontsize ~= scaled_fontsize thenobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)endif obj.w == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))else-- use an editor to wrap the textlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.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)endedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.width),scale(obj.height))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal scaled_fontsize = scale(obj.fontsize or 20)if obj.scaled_fontsize ~= scaled_fontsize thenobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)endif obj.width == nil thenlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))else-- use an editor to wrap the textlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.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)endedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, true) -- hide cursorendendendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.width),scale(obj.height))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal scaled_fontsize = scale(obj.fontsize or 20)if obj.scaled_fontsize ~= scaled_fontsize thenobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)endlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseif obj.type == 'edit' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.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)endendend
{"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 = {-- pagetype='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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.width),scale(obj.height))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'text' thenlocal scaled_fontsize = scale(obj.fontsize or 20)if obj.scaled_fontsize ~= scaled_fontsize thenobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)endlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))elseif obj.type == 'edit' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.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)endedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0})endendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.width),scale(obj.height))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()endelseif obj.type == 'text' thenlocal scaled_fontsize = scale(obj.fontsize or 20)if obj.scaled_fontsize ~= scaled_fontsize thenobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)endlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))love.graphics.line(unpack(obj.zdata))elseif obj.type == 'edit' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.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)endedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0})endendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.width),scale(obj.height))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()elseif obj.type == 'text' thenlocal scaled_fontsize = scale(obj.fontsize or 20)if obj.scaled_fontsize ~= scaled_fontsize thenobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)endlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'edit' thenlocal 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 thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.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)endedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0})endendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.width),scale(obj.height))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()elseif obj.type == 'text' thenlocal scaled_fontsize = scale(obj.fontsize or 20)if obj.scaled_fontsize ~= scaled_fontsize thenobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)endlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'edit' thenlocal scaled_fontsize = scale(obj.fontsize or 20)if obj.editor == nil or obj.scaled_fontsize ~= scaled_fontsize thenobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.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)endedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0})endendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.width),scale(obj.height))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()elseif obj.type == 'text' thenlocal scaled_fontsize = scale(obj.fontsize or 20)if obj.scaled_fontsize ~= scaled_fontsize thenobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)endlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'edit' thenlocal scaled_fontsize = scale(obj.fontsize or 20)if obj.editor == nil or obj.scaled_fontsize ~= scaled_fontsize thenobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.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)endedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0})endendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.width),scale(obj.height))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()elseif obj.type == 'text' thenlocal scaled_fontsize = scale(obj.fontsize or 20)if obj.scaled_fontsize ~= scaled_fontsize thenobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)endlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'edit' thenlocal scaled_fontsize = scale(obj.fontsize or 20)if obj.editor == nil or obj.scaled_fontsize ~= scaled_fontsize thenobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endprint(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)endedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0})endendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.width),scale(obj.height))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()elseif obj.type == 'text' thenlocal scaled_fontsize = scale(obj.fontsize or 20)if obj.scaled_fontsize ~= scaled_fontsize thenobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)endlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'edit' thenlocal scaled_fontsize = scale(obj.fontsize or 20)if obj.editor == nil or obj.scaled_fontsize ~= scaled_fontsize thenobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endprint(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)endedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0})endendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.width),scale(obj.height))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()elseif obj.type == 'text' thenlocal scaled_fontsize = scale(obj.fontsize or 20)if obj.scaled_fontsize ~= scaled_fontsize thenobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)endlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'edit' thenlocal scaled_fontsize = scale(obj.fontsize or 20)if obj.editor == nil or obj.scaled_fontsize ~= scaled_fontsize thenobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.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)endedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0})endendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.width),scale(obj.height))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()elseif obj.type == 'text' thenlocal scaled_fontsize = scale(obj.fontsize or 20)if obj.scaled_fontsize ~= scaled_fontsize thenobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)endlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'edit' thenlocal scaled_fontsize = scale(obj.fontsize or 20)if obj.scaled_fontsize ~= scaled_fontsize thenobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.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)endedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0})endendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.width),scale(obj.height))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()elseif obj.type == 'text' thenlocal scaled_fontsize = scale(obj.fontsize or 20)if obj.scaled_fontsize ~= scaled_fontsize thenobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)endlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))endlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'edit' thenlocal scaled_fontsize = scale(obj.fontsize or 20)if obj.scaled_fontsize ~= scaled_fontsize thenobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.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)endedit.draw(obj.editor, obj.fg or {r=0,g=0,b=0})endendend
{"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) dolove.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)if obj.type == 'rectangle' thenlove.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.width),scale(obj.height))elseif obj.type == 'line' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yobj.zdata = {}for i=1,#obj.data,2 dotable.insert(obj.zdata, vx(obj.data[i]))table.insert(obj.zdata, vy(obj.data[i+1]))endendlove.graphics.line(unpack(obj.zdata))elseif obj.type == 'circle' thenlove.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))elseif obj.type == 'arc' thenlove.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' thenlove.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))elseif obj.type == 'bezier' thenif obj.saved_zoom ~= Viewport.zoom or obj.saved_x ~= Viewport.x or obj.saved_y ~= Viewport.y thenobj.saved_zoom = Viewport.zoomobj.saved_x = Viewport.xobj.saved_y = Viewport.yzdata = {}for i=1,#obj.data,2 dotable.insert(zdata, vx(obj.data[i]))table.insert(zdata, vy(obj.data[i+1]))endobj.zdata = love.math.newBezierCurve(zdata):render()elseif obj.type == 'text' thenlocal scaled_fontsize = scale(obj.fontsize or 20)if obj.scaled_fontsize ~= scaled_fontsize thenobj.scaled_fontsize = scaled_fontsizeif Font == nil then Font = {} endif Font[scaled_fontsize] == nil thenFont[scaled_fontsize] = love.graphics.newFont(scaled_fontsize)endobj.text = love.graphics.newText(Font[scaled_fontsize], obj.data)endlove.graphics.draw(obj.text, vx(obj.x), vy(obj.y))endlove.graphics.line(unpack(obj.zdata))endendend
{"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 = {-- pagex=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 = {-- pagex=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,},}},}},}},},}