1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
function draw_help_without_mouse_pressed(drawing)
love.graphics.setColor(0,0.5,0)
local y = drawing.y+10
love.graphics.print("Things you can do:", Margin_left+30,y)
y = y + Line_height
love.graphics.print("* Press the mouse button to start drawing a "..current_shape(), Margin_left+30,y)
y = y + Line_height
love.graphics.print("* Hover on a point and press 'ctrl+u' to pick it up and start moving it,", Margin_left+30,y)
y = y + Line_height
love.graphics.print("then press the mouse button to drop it", Margin_left+30+bullet_indent(),y)
y = y + Line_height
love.graphics.print("* Hover on a point and press 'ctrl+n', type a name, then press 'enter'", Margin_left+30,y)
y = y + Line_height
love.graphics.print("* Hover on a point or shape and press 'ctrl+d' to delete it", Margin_left+30,y)
y = y + Line_height
if Current_drawing_mode ~= 'freehand' then
love.graphics.print("* Press 'ctrl+p' to switch to drawing freehand strokes", Margin_left+30,y)
y = y + Line_height
end
if Current_drawing_mode ~= 'line' then
love.graphics.print("* Press 'ctrl+l' to switch to drawing lines", Margin_left+30,y)
y = y + Line_height
end
if Current_drawing_mode ~= 'manhattan' then
love.graphics.print("* Press 'ctrl+m' to switch to drawing horizontal/vertical lines", Margin_left+30,y)
y = y + Line_height
end
if Current_drawing_mode ~= 'circle' then
love.graphics.print("* Press 'ctrl+o' to switch to drawing circles/arcs", Margin_left+30,y)
y = y + Line_height
end
if Current_drawing_mode ~= 'polygon' then
love.graphics.print("* Press 'ctrl+g' to switch to drawing polygons", Margin_left+30,y)
y = y + Line_height
end
if Current_drawing_mode ~= 'rectangle' then
love.graphics.print("* Press 'ctrl+r' to switch to drawing rectangles", Margin_left+30,y)
y = y + Line_height
end
if Current_drawing_mode ~= 'square' then
love.graphics.print("* Press 'ctrl+s' to switch to drawing squares", Margin_left+30,y)
y = y + Line_height
end
love.graphics.print("* Press 'ctrl+=' or 'ctrl+-' to zoom in or out, ctrl+0 to reset zoom", Margin_left+30,y)
y = y + Line_height
love.graphics.print("Press 'esc' now to hide this message", Margin_left+30,y)
y = y + Line_height
love.graphics.setColor(0,0.5,0, 0.1)
love.graphics.rectangle('fill', Margin_left,drawing.y, App.screen.width, math.max(Drawing.pixels(drawing.h),y-drawing.y))
end
function draw_help_with_mouse_pressed(drawing)
love.graphics.setColor(0,0.5,0)
local y = drawing.y+10
love.graphics.print("You're currently drawing a "..current_shape(drawing.pending), Margin_left+30,y)
y = y + Line_height
love.graphics.print('Things you can do now:', Margin_left+30,y)
y = y + Line_height
if Current_drawing_mode == 'freehand' then
love.graphics.print('* Release the mouse button to finish drawing the stroke', Margin_left+30,y)
y = y + Line_height
elseif Current_drawing_mode == 'line' or Current_drawing_mode == 'manhattan' then
love.graphics.print('* Release the mouse button to finish drawing the line', Margin_left+30,y)
y = y + Line_height
elseif Current_drawing_mode == 'circle' then
if drawing.pending.mode == 'circle' then
love.graphics.print('* Release the mouse button to finish drawing the circle', Margin_left+30,y)
y = y + Line_height
love.graphics.print("* Press 'a' to draw just an arc of a circle", Margin_left+30,y)
else
love.graphics.print('* Release the mouse button to finish drawing the arc', Margin_left+30,y)
end
y = y + Line_height
elseif Current_drawing_mode == 'polygon' then
love.graphics.print('* Release the mouse button to finish drawing the polygon', Margin_left+30,y)
y = y + Line_height
love.graphics.print("* Press 'p' to add a vertex to the polygon", Margin_left+30,y)
y = y + Line_height
elseif Current_drawing_mode == 'rectangle' then
if #drawing.pending.vertices < 2 then
love.graphics.print("* Press 'p' to add a vertex to the rectangle", Margin_left+30,y)
y = y + Line_height
else
love.graphics.print('* Release the mouse button to finish drawing the rectangle', Margin_left+30,y)
y = y + Line_height
love.graphics.print("* Press 'p' to replace the second vertex of the rectangle", Margin_left+30,y)
y = y + Line_height
end
elseif Current_drawing_mode == 'square' then
if #drawing.pending.vertices < 2 then
love.graphics.print("* Press 'p' to add a vertex to the square", Margin_left+30,y)
y = y + Line_height
else
love.graphics.print('* Release the mouse button to finish drawing the square', Margin_left+30,y)
y = y + Line_height
love.graphics.print("* Press 'p' to replace the second vertex of the square", Margin_left+30,y)
y = y + Line_height
end
end
love.graphics.print("* Press 'esc' then release the mouse button to cancel the current shape", Margin_left+30,y)
y = y + Line_height
y = y + Line_height
if Current_drawing_mode ~= 'line' then
love.graphics.print("* Press 'l' to switch to drawing lines", Margin_left+30,y)
y = y + Line_height
end
if Current_drawing_mode ~= 'manhattan' then
love.graphics.print("* Press 'm' to switch to drawing horizontal/vertical lines", Margin_left+30,y)
y = y + Line_height
end
if Current_drawing_mode ~= 'circle' then
love.graphics.print("* Press 'o' to switch to drawing circles/arcs", Margin_left+30,y)
y = y + Line_height
end
if Current_drawing_mode ~= 'polygon' then
love.graphics.print("* Press 'g' to switch to drawing polygons", Margin_left+30,y)
y = y + Line_height
end
if Current_drawing_mode ~= 'rectangle' then
love.graphics.print("* Press 'r' to switch to drawing rectangles", Margin_left+30,y)
y = y + Line_height
end
if Current_drawing_mode ~= 'square' then
love.graphics.print("* Press 's' to switch to drawing squares", Margin_left+30,y)
y = y + Line_height
end
love.graphics.setColor(0,0.5,0, 0.1)
love.graphics.rectangle('fill', Margin_left,drawing.y, App.screen.width, math.max(Drawing.pixels(drawing.h),y-drawing.y))
end
function current_shape(shape)
if Current_drawing_mode == 'freehand' then
return 'freehand stroke'
elseif Current_drawing_mode == 'line' then
return 'straight line'
elseif Current_drawing_mode == 'manhattan' then
return 'horizontal/vertical line'
elseif Current_drawing_mode == 'circle' and shape and shape.start_angle then
return 'arc'
else
return Current_drawing_mode
end
end
_bullet_indent = nil
function bullet_indent()
if _bullet_indent == nil then
local text = love.graphics.newText(love.graphics.getFont(), '* ')
_bullet_indent = text:getWidth()
end
return _bullet_indent
end
|