Transform
lerax.render.Transform
Bases: eqx.Module
Affine mapping from world coords to screen pixels.
Has a constant scale for all axis to avoid distortion.
Attributes:
| Name | Type | Description |
|---|---|---|
width |
Int[Array, '']
|
Width of the screen in pixels. |
height |
Int[Array, '']
|
Height of the screen in pixels. |
scale |
Float[Array, '']
|
Scale factor from world units to pixels. |
offset |
Float[Array, 2]
|
Offset to add after scaling. |
y_up |
bool
|
If True, the y-axis points up in world space. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
Int[ArrayLike, '']
|
Width of the screen in pixels. |
required |
height
|
Int[ArrayLike, '']
|
Height of the screen in pixels. |
required |
scale
|
Float[ArrayLike, '']
|
Scale factor from world units to pixels. |
required |
offset
|
Float[ArrayLike, 2]
|
Offset to add after scaling. |
required |
y_up
|
bool
|
If True, the y-axis points up in world space. |
True
|
__init__
__init__(
width: Int[ArrayLike, ""],
height: Int[ArrayLike, ""],
scale: Float[ArrayLike, ""],
offset: Float[ArrayLike, 2],
y_up: bool = True,
)
world_to_px
Return pixel coordinates corresponding to a point in world space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
Float[ArrayLike, 2]
|
A point in world space. |
required |
Returns:
| Type | Description |
|---|---|
Int[Array, 2]
|
The corresponding pixel coordinates. |
scale_length
Scale a length in world space to pixel space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
length
|
Float[ArrayLike, '']
|
A length in world space. |
required |
Returns:
| Type | Description |
|---|---|
Float[Array, '']
|
The corresponding length in pixel space. |