-- 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 px(x) return Drawing.pixels(x, width)+left end local function py(y) return Drawing.pixels(y, width)+top end if shape.mode == 'freehand' then local prev = nil for _,point in ipairs(shape.points) do if prev then love.graphics.line(px(prev.x),py(prev.y), px(point.x),py(point.y)) end prev = point end elseif shape.mode == 'line' or shape.mode == 'manhattan' then local p1 = drawing.points[shape.p1] local p2 = drawing.points[shape.p2] love.graphics.line(px(p1.x),py(p1.y), px(p2.x),py(p2.y)) elseif shape.mode == 'polygon' or shape.mode == 'rectangle' or shape.mode == 'square' then local prev = nil for _,point in ipairs(shape.vertices) do local curr = drawing.points[point] if prev then love.graphics.line(px(prev.x),py(prev.y), px(curr.x),py(curr.y)) end prev = curr end -- close the loop local curr = drawing.points[shape.vertices[1]] love.graphics.line(px(prev.x),py(prev.y), px(curr.x),py(curr.y)) elseif shape.mode
# dwm version
VERSION = 4.2
# Customize below to fit your system
# paths
PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man
X11INC = /usr/X11R6/include
X11LIB = /usr/X11R6/lib
# includes and libs
INCS = -I. -I/usr/include -I${X11INC}
LIBS = -L/usr/lib -lc -L${X11LIB} -lX11
# flags
CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\"
LDFLAGS = -s ${LIBS}
#CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
#LDFLAGS = -g ${LIBS}
# Solaris
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
#LDFLAGS = ${LIBS}
#CFLAGS += -xtarget=ultra
# compiler and linker
CC = cc