local p={}local M=require(script.Parent.CanvasDraw)function p.Flat(p,M,t)local D={}for t=0,t-1,1 do for R=0,M-1,1 do local f=(t*M)*4+R*4 D[f+1]=p D[f+2]=p D[f+3]=p D[f+4]=p end end return D end function p.Custom2(p,M,t,D)local R={}for M=0,M,1 do R[M]={}for t=0,t,1 do R[M][t]={}if D==nil then R[M][t]=p else for D=0,D,1 do R[M][t][D]=p end end end end return R end function p.CDrawToNumpy(p)local t=p.ImageResolution local D={}for R=0,t.X-1,1 do local f={}for t=0,t.Y-1,1 do local D=M.GetPixelFromImageXY(p,R+1,t+1)f[t]={math.floor(D.R*255),math.floor(D.G*255);math.floor(D.B*255)}end D[R]=f end return D,{t.X;t.Y}end function p.ColorImage(p,M)local t={}for D=0,M[1]-1,1 do local R={}for M=0,M[2]-1,1 do R[M]=p end t[D]=R end return t end return p

local Numpy = {}
local CanvasDraw = require(script.Parent.CanvasDraw)

function Numpy.Flat(val, width, height)
	local temp = {}
	for y = 0, height-1 do
		for x = 0, width-1 do
			local baseIndex = y * width * 4 + x * 4
			temp[baseIndex + 1] = val  -- Red channel
			temp[baseIndex + 2] = val  -- Green channel
			temp[baseIndex + 3] = val  -- Blue channel
			temp[baseIndex + 4] = val  -- Alpha channel
		end
	end
	return temp
end


function Numpy.Custom2(val, dim1, dim2, dim3)
	local result = {}
	for i = 0, dim1 do
		result[i] = {}
		for j = 0, dim2 do
			result[i][j] = {}
			if dim3 == nil then
				result[i][j] = val
			else
				for k = 0, dim3 do
					result[i][j][k] = val
				end
			end
		end
	end
	return result
end

function Numpy.CDrawToNumpy(data)
	local Resolution = data.ImageResolution

	local FinalTbl = {}

	for x=0, Resolution.X-1 do
		local temp = {}
		for y=0, Resolution.Y-1 do
			local PixelColor = CanvasDraw.GetPixelFromImageXY(data, x+1, y+1)
			temp[y] = {math.floor(PixelColor.R*255), math.floor(PixelColor.G*255), math.floor(PixelColor.B*255)}
		end
		FinalTbl[x] = temp
	end

	return FinalTbl, {Resolution.X, Resolution.Y}
end

function Numpy.ColorImage(Color, Resolution)
	local FinalTbl = {}
	
	for x=0, Resolution[1]-1 do
		local temp = {}
		for y=0, Resolution[2]-1 do
			temp[y] = Color
		end
		FinalTbl[x] = temp
	end

	return FinalTbl
end

return Numpy
