mirror of
https://github.com/LDDestroier/CC/
synced 2025-01-07 07:50:26 +00:00
Started working on fill tool
it's been too long
This commit is contained in:
parent
8ccf463615
commit
779fcbabcc
70
pain.lua
70
pain.lua
@ -1,10 +1,12 @@
|
|||||||
--[[
|
--[[
|
||||||
PAIN image editor for ComputerCraft
|
PAIN image editor for ComputerCraft
|
||||||
Get it with
|
Get it with
|
||||||
wget https://raw.githubusercontent.com/LDDestroier/CC/master/pain.lua
|
wget https://raw.githubusercontent.com/LDDestroier/CC/beta/pain.lua
|
||||||
std ld pain pain
|
std ld pain pain
|
||||||
|
|
||||||
This is a stable release. You fool!
|
This is a beta release. You fool!
|
||||||
|
To do:
|
||||||
|
+ a god damned fill function
|
||||||
--]]
|
--]]
|
||||||
local askToSerialize = false
|
local askToSerialize = false
|
||||||
local defaultSaveFormat = 4 -- will change if importing image, or making new file with extension in name
|
local defaultSaveFormat = 4 -- will change if importing image, or making new file with extension in name
|
||||||
@ -135,7 +137,7 @@ local explode = function(div,str)
|
|||||||
return arr
|
return arr
|
||||||
end
|
end
|
||||||
|
|
||||||
local function cutString(max_line_length, str) -- from stack overflow
|
local cutString = function(max_line_length, str) -- from stack overflow
|
||||||
local lines = {}
|
local lines = {}
|
||||||
local line
|
local line
|
||||||
str:gsub('(%s*)(%S+)',
|
str:gsub('(%s*)(%S+)',
|
||||||
@ -642,58 +644,22 @@ local getOnscreenCoords = function(tbl,_x,_y)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local fillTool = function(info,cx,cy,color,layer) -- takes a frame, not the whole paintEncoded
|
local fillTool = function(frame,cx,cy,dot) -- takes a frame, not the whole paintEncoded
|
||||||
local x,y
|
local maxX, maxY = 0, 0
|
||||||
|
local minX, minY = 0, 0
|
||||||
local output = {}
|
local output = {}
|
||||||
for a = 1, #info do
|
for a = 1, #frame do
|
||||||
if (info[a].x == cx) and (info[a].y == cy) then
|
maxX = math.max(maxX, frame[a].x)
|
||||||
x = cx
|
maxY = math.max(maxY, frame[a].y)
|
||||||
y = cy
|
mixX = math.min(maxX, frame[a].x)
|
||||||
replaceColor = info[a].b
|
minY = math.min(maxY, frame[a].y)
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if not x and y then
|
local touched = {}
|
||||||
return
|
local check = {dot.x, dot.y}
|
||||||
end
|
while true do
|
||||||
if color == replaceColor then
|
for a = 1, #check do
|
||||||
return
|
--do finish please...
|
||||||
end
|
|
||||||
table.insert(output,{
|
|
||||||
["x"] = x,
|
|
||||||
["y"] = y,
|
|
||||||
["b"] = color,
|
|
||||||
["t"] = color,
|
|
||||||
["c"] = " ",
|
|
||||||
["m"] = paint.m
|
|
||||||
})
|
|
||||||
local loops = 0
|
|
||||||
local tAffectedPoints = {
|
|
||||||
[1] = {
|
|
||||||
x = x+tTerm.scroll.x,
|
|
||||||
z = z+tTerm.scroll.z
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while #tAffectedPoints > 0 do
|
|
||||||
if loops%200 == 0 then
|
|
||||||
sleep(0.05)
|
|
||||||
end
|
end
|
||||||
for i=-1,1,2 do
|
|
||||||
local x = tAffectedPoints[1]["x"]+i
|
|
||||||
local z = tAffectedPoints[1]["z"]
|
|
||||||
if tBlueprint[layer][x][z] == replaceColor and x >= tTerm.viewable.sX and x <= tTerm.viewable.eX and z >= tTerm.viewable.sZ and z <= tTerm.viewable.eZ then
|
|
||||||
drawPoint(x,z,color,layer,true,true)
|
|
||||||
table.insert(tAffectedPoints,{["x"] = x,["z"] = z})
|
|
||||||
end
|
|
||||||
x = tAffectedPoints[1]["x"]
|
|
||||||
z = tAffectedPoints[1]["z"]+i
|
|
||||||
if tBlueprint[layer][x][z] == replaceColor and x >= tTerm.viewable.sX and x <= tTerm.viewable.eX and z >= tTerm.viewable.sZ and z <= tTerm.viewable.eZ then
|
|
||||||
drawPoint(x,z,color,layer,true,true)
|
|
||||||
table.insert(tAffectedPoints,{["x"] = x,["z"] = z})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
table.remove(tAffectedPoints,1)
|
|
||||||
loops = loops+1
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user