-- primitives for editing drawings Drawing = {} require 'drawing_tests' -- All drawings span 100% of some conceptual 'page width' and divide it up -- into 256 parts. function Drawing.draw(State, line_index, y) local line = State.lines[line_index] local line_cache = State.line_cache[line_index] line_cache.starty = y local pmx,pmy = App.mouse_x(), App.mouse_y() if pmx < State.right and pmy > line_cache.starty and pmy < line_cache.starty+Drawing.pixels(line.h, State.width) then App.color(Icon_color) love.graphics.rectangle('line', State.left,line_cache.starty, State.width,Drawing.pixels(line.h, State.width)) if icon[State.current_drawing_mode] then icon[State.current_drawing_mode](State.right-22, line_cache.starty+4) else icon[State.previous_drawing_mode](State.right-22, line_cache.starty+4) end if App.mouse_down(1) and love.keyboard.isDown('h') then draw_help_with_mouse_pressed(State, line_index) return end end if line.show_help then draw_help_without_mouse_pressed(State, line_index) return end local mx = Drawing.coord(pmx-State.left, State.width) local my = Drawing.coord(pmy-line_cache.starty, State.width) for _,shape in ipairs(line.shapes) do assert(shape) if geom.on_shape(mx,my, line, shape) then App.color(Focus_stroke_color) else App.color(Stroke_color) end Drawing.draw_shape(line, shape, line_cache.starty, State.left,State.right) end local function px(x) return Drawing.pixels(x, State.width)+State.left end local function py(y) return Drawing.pixels(y, State.width)+line_cache.starty end for i,p in ipairs(line.points) do if p.deleted == nil then if Drawing.near(p, mx,my, State.width) then App.color(Focus_stroke_color) love.graphics.circle('line', px(p.x),py(p.y), Same_point_distance) else App.color(Stroke_color) love.graphics.circle('fill', px(p.x),py(p.y), 2) end if p.name then -- TODO: clip local x,y = px(p.x)+5, py(p.y)+5 love.graphics.print(p.name, x,y) if State.current_drawing_mode == 'name' and i == line.pending.target_point then -- create a faint red box for the name App.color(Current_name_background_color) local name_text -- TODO: avoid computing name width on every repaint if p.name == '' then name_text = State.em else name_text = App.newText(love.graphics.getFont(), p.name) end love.graphics.rectangle('fill', x,y, App.width(name_text), State.line_height) end end end end App.color(Current_stroke_color) Drawing.draw_pending_shape(line, line_cache.starty, State.left,State.right) end function Drawing.draw_shape(drawing, shape, top, left,right) local width = right-left local function
getwtxt
*.log
local/
*.db/