Newer
Older
-- type envelope_1d_t [n] = {
-- west: [n]u8,
-- east: [n]u8
-- }
-- type envelope_2d_t [n][m][ty][tx] = {
-- north_west: [ty][tx]u8,
-- north: [ty][m]u8,
-- north_east: [ty][tx]u8,
-- west: [n][tx]u8,
-- east: [n][tx]u8,
-- south_west: [ty][tx]u8,
-- south: [ty][m]u8,
-- south_east: [ty][tx]u8
-- }
entry get_envelope_1d [n] (xs: [n]u8) (thickness: i64) : ([]u8, []u8) =
let west = xs[0:thickness] :> [thickness]u8
let east = xs[n - thickness:] :> [thickness]u8
-- entry get_envelope_1d [n] (xs: [n]u8) (thickness: i64) : envelope_1d_t [thickness] =
-- let west = xs[0:thickness] :> [thickness]u8
-- let east = xs[n - thickness:] :> [thickness]u8
-- in {west, east}
entry get_envelope_2d [n][m] (matrix: [n][m]u8) (thickness_y: i64) (thickness_x: i64): ([][]u8, [][]u8, [][]u8, [][]u8, [][]u8, [][]u8, [][]u8, [][]u8) =
let north = matrix[0:thickness_y] :> [thickness_y][m]u8
let north_west = matrix[0:thickness_y,0:thickness_x] :> [thickness_y][thickness_x]u8
let north_east = matrix[0:thickness_y,m - thickness_x:m] :> [thickness_y][thickness_x]u8
let south = matrix[n - thickness_y:] :> [thickness_y][m]u8
let south_east = matrix[n - thickness_y:n,m - thickness_x:m] :> [thickness_y][thickness_x]u8
let south_west = matrix[n - thickness_y:n,0:thickness_x] :> [thickness_y][thickness_x]u8
let east = matrix[:,m - (thickness_x):] :> [n][thickness_x]u8
let west = matrix[:,0:thickness_x] :> [n][thickness_x]u8
in (north_west, north, north_east, west, east, south_west, south, south_east)
-- entry get_envelope_2d [n][m] (matrix: [n][m]u8) (thickness_y: i64) (thickness_x: i64): envelope_2d_t [n][m][thickness_y][thickness_x] =
-- let north = matrix[0:thickness_y] :> [thickness_y][m]u8
--
-- let north_west = matrix[0:thickness_y,0:thickness_x] :> [thickness_y][thickness_x]u8
-- let north_east = matrix[0:thickness_y,m - thickness_x:m] :> [thickness_y][thickness_x]u8
--
-- let south = matrix[n - thickness_y:] :> [thickness_y][m]u8
--
-- let south_east = matrix[n - thickness_y:n,m - thickness_x:m] :> [thickness_y][thickness_x]u8
-- let south_west = matrix[n - thickness_y:n,0:thickness_x] :> [thickness_y][thickness_x]u8
--
-- let east = matrix[:,m - (thickness_x):] :> [n][thickness_x]u8
-- let west = matrix[:,0:thickness_x] :> [n][thickness_x]u8
--
-- in {north_west, north, north_east, west, east, south_west, south, south_east}