-
Notifications
You must be signed in to change notification settings - Fork 0
/
storyboard.lua~
executable file
·203 lines (144 loc) · 4.59 KB
/
storyboard.lua~
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
-- we store range for range operations
-- set time code for range
-- copy range
rangeBeginIdx=nil
rangeEndIdx=nil
brshLineWidth=128
brshMaxRad=128
local widgets={}
local clockQuad = {x=64, y=64, w=64, h=64}
cursorQuad = {x=0, y=0, w=64, h=64}
playQuad={x=0, y=4*64, w=64, h=64}
paletteQuad={x=64, y=6*64, w=64, h=64}
pickerQuad={x=0, y=15*64, w=64, h=64}
local brushQuad={x=0, y=16*64, w=64, h=64}
local zoomQuad={x=128, y=0, w=64, h=64}
local deleteQuad={x=0, y=11*64, w=64, h=64}
local bgQuad={x=2*64, y=2*64, w=64, h=64}
local rangeBeginQuad={x=0*64, y=12*64, w=64, h=64}
local rangeEndQuad={x=0*64, y=13*64, w=64, h=64}
local pasteRangeQuad={x=0*64, y=14*64, w=64, h=64}
function pasteRange()
if cb==nil or ce==nil then
print(' nil marker, not possible ')
return
end
if ce<=cb then
print(' end marker before begin marker, not possible ')
return
end
--todo paste range from current idx
end
function toggleBg()
print ('toggle frame '..currentIdx..'as bg')
if frames[currentIdx].bg==true then
frames[currentIdx].bg=nil
else
frames[currentIdx].bg=true
end
maintainBgRanges()
end
function deleteCurrentFrame()
print('deletingFrame '..currentIdx)
if maxframe<4 then
print('not enough frames to delete')
return
end
toDel=frames[currentIdx]
toDel.data:release()
toDel.pic:release()
table.remove(frames,currentIdx)
maxframe=maxframe-1
if currentIdx>maxframe then
currentIdx=maxframe
end
maintainBgRanges()
initCanvases(currentIdx)
end
function setRangeBegin()
print('setRangeBegin '..currentIdx)
rangeBeginIdx=currentIdx
end
function setRangeEnd()
print('setRangeEnd '..currentIdx)
rangeEndIdx=currentIdx
end
local wPlay=createpicbutton(uiw-64*buttonZoom,0,buttonsPic,toPlayback,playQuad)
local wPalette =createpicbutton(uiw-64*buttonZoom,64*buttonZoom,buttonsPic,toPaletteMode,paletteQuad)
local wPicker =createpicbutton(uiw-64*buttonZoom,128*buttonZoom,buttonsPic,toPickMode,pickerQuad)
local wTC =createpicbutton(uiw-64*buttonZoom,192*buttonZoom,buttonsPic,toTimeCode,clockQuad)
local wBS =createpicbutton(uiw-64*buttonZoom,256*buttonZoom,buttonsPic,toBrushScreen,brushQuad)
local wZP =createpicbutton(uiw-128*buttonZoom,0*buttonZoom,buttonsPic,toZoomPos,zoomQuad)
local wDF =createpicbutton(uiw-192*buttonZoom,0*buttonZoom,buttonsPic,deleteCurrentFrame,deleteQuad)
local wBG =createpicbutton(uiw-256*buttonZoom,0*buttonZoom,buttonsPic,toggleBg,bgQuad)
local wRB =createpicbutton(uiw-320*buttonZoom,0*buttonZoom,buttonsPic,setRangeBegin,rangeBeginQuad)
local wRE =createpicbutton(uiw-384*buttonZoom,0*buttonZoom,buttonsPic,setRangeEnd,rangeEndQuad)
local wPR =createpicbutton(uiw-384*buttonZoom,uih-64*buttonZoom,buttonsPic,pasteRange,pasteRangeQuad)
table.insert(widgets,wPlay)
table.insert(widgets,wPalette)
table.insert(widgets,wPicker)
table.insert(widgets,wTC)
table.insert(widgets,wBS)
table.insert(widgets,wZP)
table.insert(widgets,wDF)
table.insert(widgets,wBG)
table.insert(widgets,wRB)
table.insert(widgets,wRE)
table.insert(widgets,wPR)
function toSettings()
drawFunc=drawSettings
updateFunc=updateSettings
end
local function rendertouicanvas()
love.graphics.setCanvas(ui)
love.graphics.clear(1.0,1.0,1.0,0.0)
love.graphics.setColor(1.0,.0,.0,1.0)
love.graphics.line(brshLineWidth,0,brshLineWidth,uih)
love.graphics.print('setting',400,0)
love.graphics.setColor(1.0,1.0,1.0,1.0)
if eraseMode==false then
love.graphics.draw(mybrush)
else
--outline of eraser
love.graphics.setColor(0.0,0.0,0.0,1.0)
love.graphics.circle('line',eraserRadius,eraserRadius,eraserRadius)
love.graphics.setColor(1.0,1.0,1.0,1.0)
end
renderWidgets(widgets)
msgToCvs()
love.graphics.setCanvas()
end
function drawSettings()
-- love.graphics.draw(buttonsPic)
rendertouicanvas()
--this is the background image of our paint
love.graphics.clear(1.,1.,1.,1.0)
love.graphics.setColor(1.0,1.0,1.0,1.0)
love.graphics.draw(ui,0,0,0,scrsx,scrsy)
end
function updateSettings()
if npress==true then
if npx<brshLineWidth then
potradius=math.floor(npy/uih * brshMaxRad)
if potradius>1 then
if eraseMode==true then
eraserRadius=potradius
print('eraserRadius '..potradius)
else
brshradius=potradius
mybrush=love.graphics.newImage(roundBrushWithAlpha( brshradius,paintcolor.r,paintcolor.g,paintcolor.b))
mybrush:setFilter('nearest','nearest')
end
else
print('brsh less than 1 impossible')
end
npress=false
else
consumeClick(widgets)
--if newpress still not consumed
if npress==true then
toPaintMode()
end
end
end
end