-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path#brushscreen.lua#
executable file
·120 lines (82 loc) · 2.56 KB
/
#brushscreen.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
local exitQuad = {x=64, y=17*64, w=64, h=64}
local function exitBS()
print('exit bs ')
toPaintMode()
end
local currentSel = createbrushbox(100,100,200,200)
--we stamp selection on current canvas/current frame
local stampSelection = function()
--TODO the cvs needs to be loaded with the relevant frame, then the frame needs to be saved
initCanvases(currentIdx)
--doesn t work, go and see code from paste button?
love.graphics.setCanvas(cvs)
--lets create a quad
local toBlit=love.graphics.newQuad(
brushSelection.x,
brushSelection.y,
brushSelection.w,
brushSelection.h,
frames[copySrc].pic:getDimensions()
)
love.graphics.draw(frames[copySrc].pic,currentSel.x-offsetcvs.x,currentSel.y-offsetcvs.y)
love.graphics.setCanvas()
--save result to frame
saveCanvasToFrame(currentIdx)
--we need to reset the texture in case we pasted on itself ( we changed frame referenced in brushbox )
bbsettexture(currentSel,frames[copySrc].pic)
end
local wExitBS = createpicbutton(0,0,buttonsPic,exitBS,exitQuad)
local wToBSS = createpicbutton(uiw-64,uih-64,buttonsPic,toBrushSourceSelection,exitQuad)
local wStamp = createpicbutton(uiw-64,0,buttonsPic,stampSelection,exitQuad)
local widgets={}
table.insert(widgets,wExitBS)
table.insert(widgets,wToBSS)
table.insert(widgets,currentSel )
table.insert(widgets,wStamp)
local function rendertouicanvas()
love.graphics.setCanvas(ui)
love.graphics.clear(1.0,1.0,1.0,0.0)
-- let's render the picture we will render the paste on
love.graphics.draw(frames[currentIdx].pic,offsetcvs.x,offsetcvs.y)
renderWidgets(widgets)
msgToCvs()
--love.graphics.print()
love.graphics.setCanvas()
end
local function brushScreenDraw()
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
local function brushScreenUpdate()
if npress==true then
print('bs click')
addMsg('bs click')
consumed=consumeClick(widgets)
print('consumed '..tostring(consumed))
if consumed==true
then
return
end
npress=false
end
end
function toBrushScreen()
if copySrc==nil then
print('no src frame')
return
end
currentSel.x=brushSelection.x
print(currentSel.x )
currentSel.y=brushSelection.y
print(currentSel.y )
currentSel.w=brushSelection.w
print(currentSel.w )
currentSel.h=brushSelection.h
print(currentSel.h )
bbsettexture(currentSel,frames[copySrc].pic)
drawFunc=brushScreenDraw
updateFunc=brushScreenUpdate
end