add functions to add and remove pixels from layer-tree
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
structure Grid =
|
||||
struct
|
||||
type square = {r: int, g: int, b: int, a: int}
|
||||
type pixel = {r: int, g: int, b: int, a: int}
|
||||
|
||||
type t = square vector vector
|
||||
type t = pixel vector vector
|
||||
|
||||
val emptyPixel = {r = 0, g = 0, b = 0, a = 0}
|
||||
|
||||
fun isBlank ({a, ...}: square) = a = 0
|
||||
fun isBlank ({a, ...}: pixel) = a = 0
|
||||
|
||||
fun changeGridSize maxSide grid =
|
||||
Vector.tabulate (maxSide, fn i =>
|
||||
@@ -20,4 +20,16 @@ struct
|
||||
end
|
||||
else
|
||||
Vector.tabulate (maxSide, fn _ => emptyPixel))
|
||||
|
||||
fun updateGrid (grid, newX, newY, pixel) =
|
||||
let
|
||||
val yAxis = Vector.sub (grid, newX)
|
||||
val yAxis = Vector.update (yAxis, newY, pixel)
|
||||
in
|
||||
Vector.update (grid, newX, yAxis)
|
||||
end
|
||||
|
||||
fun makeEmpty maxSide =
|
||||
Vector.tabulate (maxSide, fn _ =>
|
||||
Vector.tabulate (maxSide, fn _ => emptyPixel))
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user