add grid module, and change some functions in layer-tree.sml to use it instead of having grid-logic in there

This commit is contained in:
2025-08-09 08:43:51 +01:00
parent 6cd2b85d8b
commit e634bb25d7
4 changed files with 28 additions and 25 deletions

23
fcore/grid.sml Normal file
View File

@@ -0,0 +1,23 @@
structure Grid =
struct
type square = {r: int, g: int, b: int, a: int}
type t = square vector vector
val emptyPixel = {r = 0, g = 0, b = 0, a = 0}
fun isBlank ({a, ...}: square) = a = 0
fun changeGridSize maxSide grid =
Vector.tabulate (maxSide, fn i =>
if i < Vector.length grid then
let
val yAxis = Vector.sub (grid, i)
in
Vector.tabulate (maxSide, fn ii =>
if ii < Vector.length yAxis then Vector.sub (yAxis, ii)
else emptyPixel)
end
else
Vector.tabulate (maxSide, fn _ => emptyPixel))
end