-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasicpaintmode.lua
82 lines (55 loc) · 1.67 KB
/
basicpaintmode.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
--draws a line from last blit x last blit y to current coords
function basicBlitBrushLineRemember(x,y)
print("basicBlitBrushLineRemember line x,y "..x.." "..y)
local blits=calculateTraj(lastblitx,lastblity,x,y)
love.graphics.setCanvas(cvs)
if eraseMode== true then
love.graphics.setBlendMode('replace')
--following is ok for square brush
-- love.graphics.setShader(eraserShader)
--alternative method
--TODO should we not set color to 1.0,1.0,1.0, 0 ?
-- dark alpha artifacting
love.graphics.setColor(0.0,0.0,0.0,0.0)
end
--DBG should not be a shader here
-- for basic ( looks a cut n paste mistake )
-- if brushShader~=nil then
-- print('brsh shader')
-- love.graphics.setShader(brushShader)
-- end
for i,b in ipairs(blits) do
if eraseMode== true then
--TODO why different x y ? might explain jumpiness
-- TODO events are actually recorded for top left of brush, refactor to do
love.graphics.circle('fill',x+brshradius,y+brshradius,eraserRadius)
else
love.graphics.draw(mybrush,b.xbl,b.ybl)
end
end
-- if brushShader~=nil then
-- love.graphics.setShader()
-- end
if eraseMode== true then
love.graphics.setColor(1.0,1.0,1.0,1.0)
love.graphics.setBlendMode('alpha')
end
-- love.graphics.setShader()
love.graphics.setCanvas()
lastblitx=x
lastblity=y
dirtycvs=true
end
--function isHardPaintEnabled()
-- if blitBrushLineRemember==basicBlitBrushLineRemember then
-- return true
-- else
-- return false
-- end
--end
initBasicPaintMode=function()
blitBrushLineRemember=basicBlitBrushLineRemember
backBufferRender=false
penUpPaintModeCb=nil
basicPaintUnderMode=false
end