-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpalette.lua
executable file
·70 lines (49 loc) · 1.54 KB
/
palette.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
legacyPalettePic= loadfilter('palette.png')
function paletteModeDraw()
love.graphics.setCanvas(ui)
love.graphics.clear()
love.graphics.draw(legacyPalettePic.pic,0,0,0,zxpal,zypal)
love.graphics.setCanvas()
love.graphics.clear(0.,0.,0.,1.0)
love.graphics.setColor(1.0,1.0,1.0,1.0)
love.graphics.draw(ui,0,0,0,scrsx,scrsy)
end
function paletteModeUpdate()
if npress==true and npx<rwpal and npy<rhpal then
--pick color
r,g,b,a=legacyPalettePic.data:getPixel(npx/zxpal,npy/zypal)
addMsg('color '.. math.floor( r*255) ..' '.. math.floor(g*255) ..' '.. b*255)
addMsg('quit palette')
-- mybrush=love.graphics.newImage(roundBrushWithAlpha(8,r*255,g*255,b*255))
-- mybrush=love.graphics.newImage(roundBrushWithGradient(brshradius,r,g,b))
mybrush=love.graphics.newImage(currentBrushFunc(brshradius,r,g,b))
mybrush:setFilter('nearest','nearest')
paintcolor.r=r
paintcolor.g=g
paintcolor.b=b
npress=false
toPaintMode()
return
end
end
function paletteModeKey(key, code, isrepeat)
end
function toPaletteMode()
saveCanvasToFrame(currentIdx)
keyFunc = paletteModeKey
drawFunc=paletteModeDraw
updateFunc=paletteModeUpdate
--let's calculate scale factor to ui canvas ( to interprete clicks properly )
local pw=legacyPalettePic.data:getWidth()
local ph=legacyPalettePic.data:getHeight()
zxpal= uiw/pw
zypal= uih/ph
if zxpal<zypal then
zypal=zxpal
else
zxpal=zypal
end
rwpal=pw*zxpal
rhpal=ph*zypal
addMsg("pal ui zoom ".. zxpal)
end