5QTU3ODSGFLRWALAUDR27QYRB6UVDZD3Y3UJMZXISEFA7TRDI6BAC
render_node_and_descendants = function(id, y, xlo, xhi, grandparent_surface_node)
-- draw a parent 'id' and its children
-- also draw an edge from grandparent to parent if provided
-- position the root between xlo and xhi to be closer to children with fewer tracks
local parent = Nodes[id]
if parent.children == nil then
parent.surface_node = add_node(xlo, y, parent.content, parent.id, grandparent_surface_node)
return
end
local parent_xlo
if #parent.children <= 1 then
parent_xlo = xlo
else
local total_boundaries = 0
local curr_boundary = xlo
for child_idx = 1,#parent.children-1 do
local child_id = parent.children[child_idx]
local child = Nodes[child_id]
curr_boundary = curr_boundary + 620 * child.ntracks
total_boundaries = total_boundaries + curr_boundary
end
local parent_x = total_boundaries / (#parent.children-1)
parent_xlo = parent_x - 620/2
end
parent.surface_node = add_node(parent_xlo, y, parent.content, parent.id, grandparent_surface_node)
local parent_height = box_height(parent.surface_node)
local curr_boundary = xlo
for _,child_id in ipairs(parent.children) do
local child = Nodes[child_id]
render_node_and_descendants(child_id, y + parent_height + 50, curr_boundary, curr_boundary + 620*child.ntracks, parent.surface_node)
curr_boundary = curr_boundary + 620*child.ntracks
end
end
{"render_node_and_descendants":633,"compute_layout":619,"schema1_of_y":366,"render_thread_to_surface":626,"y_of_schema1":364,"dehtml":456,"Surface":588,"line_height":365,"on.draw":632,"load_from_iterator":463,"box_height":345,"on":1,"Viewport":303,"vx":5,"update_editor_box":430,"on.keychord_press":631,"Input_filename":436,"on.mouse_press":618,"add_thick_line":400,"on.mouse_release":586,"on.initialize":446,"on.text_input":587,"on.code_change":578,"fw_app":"mastodon-luaML","compute_ntracks":598,"Cursor_node":172,"fw_parent":632,"add_edge":575,"Nodes":593,"split_lines":469,"A":582,"to_text":180,"vy":8,"copy_shape":396,"scale":7,"add_node":590,"ntracks":600,"B":379,"initialize_editor":338,"on.update":368,"to_node":611,"font":353}
on.draw = function()
love.graphics.setColor(1,0,0)
for _,obj in ipairs(Surface) do
love.graphics.setColor(obj.r or 0, obj.g or 0, obj.b or 0)
if obj.type == 'rectangle' then
if obj.text_node and obj.text_node == Cursor_node.surface_node then
love.graphics.setColor(0.7, 0.7, 0, 0.4)
end
love.graphics.rectangle(obj.drawmode or 'fill', vx(obj.x),vy(obj.y), scale(obj.w),scale(obj.h))
elseif obj.type == 'line' then
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'circle' then
love.graphics.circle(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radius))
elseif obj.type == 'arc' then
love.graphics.arc(obj.drawmode or 'line', obj.arctype or 'open', vx(obj.x), vy(obj.y), scale(obj.radius), obj.angle1, obj.angle2, obj.segments)
elseif obj.type == 'ellipse' then
love.graphics.ellipse(obj.drawmode or 'fill', vx(obj.x), vy(obj.y), scale(obj.radiusx), scale(obj.radiusy))
elseif obj.type == 'bezier' then
love.graphics.line(unpack(obj.zdata))
elseif obj.type == 'text' then
if obj.w == nil then
love.graphics.draw(obj.text, vx(obj.x), vy(obj.y))
else
edit.draw(obj.editor, obj.fg or {r=0,g=0,b=0}, not obj.show_cursor)
end
end
end
end
{"render_node_and_descendants":614,"compute_layout":619,"schema1_of_y":366,"render_thread_to_surface":626,"y_of_schema1":364,"dehtml":456,"Surface":588,"line_height":365,"on.draw":632,"load_from_iterator":463,"box_height":345,"on":1,"Viewport":303,"vx":5,"update_editor_box":430,"on.keychord_press":631,"Input_filename":436,"on.mouse_press":618,"add_thick_line":400,"on.mouse_release":586,"on.initialize":446,"on.text_input":587,"on.code_change":578,"fw_app":"mastodon-luaML","compute_ntracks":598,"Cursor_node":172,"fw_parent":631,"add_edge":575,"Nodes":593,"split_lines":469,"A":582,"to_text":180,"vy":8,"copy_shape":396,"scale":7,"add_node":590,"ntracks":600,"B":379,"initialize_editor":338,"on.update":368,"to_node":611,"font":353}