Path
Module: terminaltexteffects.engine.motion
Represents a path consisting of multiple waypoints for motion.
Attributes:
| Name | Type | Description |
|---|---|---|
path_id |
str
|
The unique identifier for the path. |
speed |
float
|
Path speed; must be greater than 0. |
ease |
EasingFunction | None
|
Easing function applied across path traversal. |
layer |
int | None
|
Character layer to apply when the path is activated. If None, the layer is unchanged. |
hold_time |
int
|
Number of frames to remain at the end of the path before completion. |
loop |
bool
|
Whether the path should restart after completion. |
segments |
list[Segment]
|
Ordered segments traversed by the path. |
waypoints |
list[Waypoint]
|
Ordered waypoints in the path. |
waypoint_lookup |
dict[str, Waypoint]
|
Waypoints indexed by |
total_distance |
float
|
Total travel distance across all segments, including the origin segment when active. |
current_step |
int
|
Current traversal step count. |
max_steps |
int
|
Total number of traversal steps, derived from |
hold_time_remaining |
int
|
Remaining hold frames once the path reaches its end. |
last_distance_reached |
float
|
Most recent eased or linear distance traveled along the active path. |
origin_segment |
Segment | None
|
Temporary segment from the current coordinate to the first waypoint, set on activation. |
Methods:
| Name | Description |
|---|---|
new_waypoint |
Creates a new Waypoint and appends adds it to the Path. |
query_waypoint |
Returns the waypoint with the given waypoint_id. |
step |
Progresses to the next step along the path and returns the coordinate at that step. |
Source code in terminaltexteffects/engine/motion.py
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 338 339 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 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 | |
__eq__(other)
Check if two Path objects are equal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
object
|
object to compare |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the two Path objects are equal, False otherwise. |
Source code in terminaltexteffects/engine/motion.py
__hash__()
__post_init__()
Initialize the Path object and calculates the total distance and maximum steps.
Source code in terminaltexteffects/engine/motion.py
new_waypoint(coord, *, bezier_control=None, waypoint_id='')
Create a new Waypoint and appends adds it to the Path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
waypoint_id
|
str
|
Unique identifier for the waypoint. Used to query for the waypoint. |
''
|
coord
|
Coord | Vec3 | SpatialNode
|
Position in the moving node's parent's frame. A |
required |
bezier_control
|
tuple[Coord | Vec3 | SpatialNode, ...] | Coord | Vec3 | SpatialNode | None
|
Optional bezier control point(s) for the segment ending at this waypoint. A single point is normalized to a one-item tuple. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Waypoint |
Waypoint[PointT]
|
The new waypoint. |
Source code in terminaltexteffects/engine/motion.py
query_waypoint(waypoint_id)
Return the waypoint with the given waypoint_id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
waypoint_id
|
str
|
waypoint_id |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Waypoint |
Waypoint
|
The waypoint with the given waypoint_id. |
Source code in terminaltexteffects/engine/motion.py
step(event_handler)
Progresses to the next step along the path and returns the position at that step.
This method is called by the Motion.move() method. It calculates the next position based on the current step, total distance, bezier control points, and the easing function if provided. It also handles the triggering of segment enter and exit events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_handler
|
EventHandler
|
The EventHandler for the character. |
required |
Returns:
| Type | Description |
|---|---|
Vec3
|
g3.Vec3: The next position on the path, in the character's parent's frame. |
Source code in terminaltexteffects/engine/motion.py
walk(columns=0, rows=0, *, waypoint_id='')
Add a waypoint that many cells straight ahead of the previous one, wherever that ends.
On a closed surface the walk goes straight on over every fold and round as many laps as it takes:
walk(columns=70) on a cube 40 columns around goes round once and 30 columns more, and walk(rows=24) from
the middle of the front goes up, over the lid in line, and down the back. On a plane it's the point that
many columns and rows on. The previous waypoint is the one before this, or where the mover is when the path
is activated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
columns
|
float
|
Columns to walk; negative goes left. |
0
|
rows
|
float
|
Rows to walk; negative goes down. |
0
|
waypoint_id
|
str
|
Unique identifier for the waypoint. Used to query for the waypoint. |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
Waypoint |
Waypoint[Vec3]
|
The new waypoint. Its |