location
GridType = TypeVar('GridType')
module-attribute
LocationTuple = tuple[XLoc, YLoc]
module-attribute
PointList = list[Point]
module-attribute
ValLocTuple = tuple[XLoc, YLoc, GridType]
module-attribute
XLoc = NewType('XLoc', int)
module-attribute
YLoc = NewType('YLoc', int)
module-attribute
ChangedPoint
Bases: Point
Represents a value changing from old_val
to val
at a given (x, y) location.
Source code in roc/location.py
93 94 95 96 97 98 99 100 101 |
|
__init_(x, y, val, old_val)
Source code in roc/location.py
96 97 98 |
|
__repr__()
Source code in roc/location.py
100 101 |
|
DebugGrid
Source code in roc/location.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
|
__array_finalize__(obj)
Source code in roc/location.py
219 220 221 |
|
__new__(grid)
Source code in roc/location.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
|
__str__()
Source code in roc/location.py
291 292 293 294 295 296 297 298 299 300 |
|
blue_to_red_hue(val)
classmethod
Converts a floating point value to a point in a red-to-blue gradient, where high values are red and lower values are blue. Good for representing values in a range as a heat map for easy visualization of higher values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
val
|
float
|
The value to convert. |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The hue in the red-to-blue gradient. |
Source code in roc/location.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
|
five_color_hue(val)
classmethod
Converts a value to a hue along a red-orange-yellow-green-blue spectrum. Higher values are red, lower values are blue. Good for visually differentiating a range of values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
val
|
float
|
The value to convert. |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The hue in the red-orange-yellow-green-blue gradient. |
Source code in roc/location.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
|
get_back_rgb(x, y)
Source code in roc/location.py
284 285 286 287 288 289 |
|
get_front_rgb(x, y)
Source code in roc/location.py
277 278 279 280 281 282 |
|
set_style(x, y, *, style=None, **kwargs)
Source code in roc/location.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
|
Grid
Bases: NDArray[Any]
, Generic[GridType]
Source code in roc/location.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
height
property
width
property
__iter__()
Source code in roc/location.py
122 123 124 |
|
__new__(input_array)
Source code in roc/location.py
113 114 115 116 |
|
get_val(x, y)
Source code in roc/location.py
133 134 135 |
|
set_val(x, y, v)
Source code in roc/location.py
137 138 |
|
GridStyle
dataclass
A stylized point on a text grid, where the text can be printed in any foreground or background color or style. Colors can be set using hue, saturation, and brightness (HSV) so that independent variables can control what color, how saturated the color is, and how bright the color is. This gives at least six debugging degrees of freedom for each point in the grid (in addition to value and style).
Source code in roc/location.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
|
back_brightness
instance-attribute
back_hue
instance-attribute
back_saturation
instance-attribute
front_brightness
instance-attribute
front_hue
instance-attribute
front_saturation
instance-attribute
style
instance-attribute
val
instance-attribute
__init__(front_hue, front_saturation, front_brightness, back_hue, back_saturation, back_brightness, style, val)
IntGrid
Bases: Grid[int]
Source code in roc/location.py
151 152 153 154 155 156 157 158 |
|
get_point(x, y)
Source code in roc/location.py
152 153 |
|
points()
Iterate over all the points in the grid
Source code in roc/location.py
155 156 157 158 |
|
Point
Represents a int value at a 2D location (x, y)
Source code in roc/location.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
val = val
instance-attribute
x = x
instance-attribute
y = y
instance-attribute
__eq__(p)
Source code in roc/location.py
29 30 31 32 |
|
__hash__()
Source code in roc/location.py
23 24 |
|
__init__(x, y, val)
Source code in roc/location.py
18 19 20 21 |
|
__repr__()
Source code in roc/location.py
26 27 |
|
from_valloc(t)
staticmethod
Converts a value / location tuple (value, x, y) to a Point.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t
|
ValLocTuple[int]
|
The tuple to convert |
required |
Returns:
Name | Type | Description |
---|---|---|
Point |
Point
|
The new point that was created |
Source code in roc/location.py
34 35 36 37 38 39 40 41 42 43 44 45 |
|
isadjacent(*, x1=None, y1=None, x2=None, y2=None, p1=None, p2=None)
staticmethod
isadjacent(
*, x1: XLoc, y1: YLoc, x2: XLoc, y2: YLoc
) -> bool
isadjacent(*, p1: Point, x2: XLoc, y2: YLoc) -> bool
isadjacent(*, p1: Point, p2: Point) -> bool
Source code in roc/location.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
PointCollection
A collection of abitrary points
Source code in roc/location.py
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
|
points
property
size
property
__init__(point_list)
Source code in roc/location.py
343 344 345 346 |
|
add(p)
Adds a new point to the collection
Source code in roc/location.py
348 349 350 351 |
|
contains(p)
Verifies if a point is already in the collection or not
Source code in roc/location.py
353 354 355 356 |
|
do_hash(p)
Returns the hash value of a point. Mostly for internal use.
Source code in roc/location.py
358 359 360 |
|
TextGrid
Bases: IntGrid
Source code in roc/location.py
161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
__str__()
Source code in roc/location.py
162 163 164 165 166 167 168 169 170 171 172 173 |
|
TypedPointCollection
Bases: PointCollection
A collection of points that all have the same type
Source code in roc/location.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 |
|
type = type
instance-attribute
__init__(type, point_list)
Source code in roc/location.py
374 375 376 |
|
__repr__()
Source code in roc/location.py
378 379 |
|
add(p)
Add a new point to the collection and enforce that it is the same type as the collection
Source code in roc/location.py
384 385 386 387 388 389 390 391 392 393 |
|
do_hash(p)
Source code in roc/location.py
381 382 |
|