You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-8Lines changed: 12 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# TileMaps
2
2
3
-
`TileMaps` is a package that makes it simple to create 2D tile maps in Julia. It is designed to be lightweight and fast, and have minimal dependencies.
3
+
`TileMaps` is a package that makes it simple to create 2D tile maps (and higher dimensional equivalents) in Julia. It is designed to be lightweight and fast, and have minimal dependencies.
4
4
5
5
**Note:** This package does not export any names. The examples below that demonstrate the use of this package assume that it has been loaded via `import TileMaps as TM`.
6
6
@@ -24,7 +24,9 @@ struct ObjectIndexableArray{T, N, A, O} <: AbstractArray{T, N}
24
24
end
25
25
```
26
26
27
-
We'll refer to an instance of `ObjectIndexableArray` as `object_indexable_array`. An `object_indexable_array` simply wraps an `array` and allows us to index its first dimension using a [singleton](https://docs.julialang.org/en/v1/manual/types/#man-singleton-types) object or an array of singleton objects (in addition to all the other ways of indexing `array`).
27
+
An instance of `ObjectIndexableArray`, referred to as `object_indexable_array` here, simply wraps an `array` (whose type is captured by the type parameter `A` above) and allows us to index its first dimension using a [singleton](https://docs.julialang.org/en/v1/manual/types/#man-singleton-types) object or an array of singleton objects (in addition to all the other ways of indexing the wrapped `array`). Information about the objects is stored in the type parameter `O` above which is essentially the type of tuple of objects along the `num_objects` dimension. Note that `size(object_indexable_array, 1)` should be equal to the number of elements in the type parameter `O`.
28
+
29
+
`size(object_indexable_array, 1)` should be equal to the number of elements in the type parameter `O`.
28
30
29
31
### Objects
30
32
@@ -51,13 +53,15 @@ julia> struct MyObject <: TM.AbstractObject end
51
53
julia>
52
54
```
53
55
54
-
### TileMap
56
+
For an `object_indexable_array`, you can get the type of tuple of objects in it using `TM.get_objects_type(object_indexable_array)`, or you can get the tuple of objects itself, using `TM.get_objects(object_indexable_array)`.
We'll refer to an instance of `TileMap` as `tile_map`. A`tile_map` wraps an `array` of size `(num_objects, height, width)`, which encodes information about the presence or absence of objects across the tiles. Each tile can contain multiple objects, which is captured by a multi-hot encoding along the first dimension (`num_objects` dimension) of the `array`.
64
+
An instance of `TileMap`, referred to as`tile_map`here, wraps an `array` of type `BitArray{3}` and is of size `(num_objects, height, width)`, which encodes information about the presence or absence of objects across the tiles using Boolean values. Each tile can contain multiple objects, which is captured by a multi-hot encoding along the first dimension (`num_objects` dimension) of the `array`.
61
65
62
66
### Constructing a `TileMap`
63
67
@@ -73,11 +77,11 @@ You can instantiate a `TileMap` using the following constructor that are provide
73
77
74
78
1. Create a `tile_map` using a tuple of objects and an existing `array`:
Copy file name to clipboardExpand all lines: src/object_indexable_array.jl
+9-2Lines changed: 9 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,10 @@
1
+
"""
2
+
3
+
ObjectIndexableArray{T, N, A, O} <: AbstractArray{T, N}
4
+
5
+
An instance of `ObjectIndexableArray`, referred to as `object_indexable_array` here, simply wraps an `array` (whose type is captured by the type parameter `A` above) and allows us to index its first dimension using a [singleton](https://docs.julialang.org/en/v1/manual/types/#man-singleton-types) object or an array of singleton objects (in addition to all the other ways of indexing the wrapped `array`). Information about the objects is stored in the type parameter `O` above which is essentially the type of tuple of objects along the `num_objects` dimension. Note that `size(object_indexable_array, 1)` should be equal to the number of elements in the type parameter `O`.
6
+
7
+
"""
1
8
struct ObjectIndexableArray{T, N, A, O} <:AbstractArray{T, N}
2
9
array::A
3
10
end
@@ -11,7 +18,7 @@ Base.size(object_indexable_array::ObjectIndexableArray, args...; kwargs...) = Ba
An instance of `TileMap`, referred to as `tile_map` here, wraps an `array` of type `BitArray{3}` and is of size `(num_objects, height, width)`, which encodes information about the presence or absence of objects across the tiles using Boolean values. Each tile can contain multiple objects, which is captured by a multi-hot encoding along the first dimension (`num_objects` dimension) of the `array`.
0 commit comments