Bases: Token
Wrapper for load rotation token.
LR Command: Rotation Graphics State Parameter
The LR
command is utilized to configure the rotation graphics state parameter.
Functionality:
- This command specifies the rotation angle to be applied when crafting objects.
- The aperture is rotated centered on its origin, which might either coincide with
or differ from its geometric center.
Usage and Persistence:
- The LR
command can be invoked numerous times throughout a file.
- Once defined, the object rotation retains its configuration unless overridden by
an ensuing LR
command.
- Rotation is strictly determined by the exact value mentioned in the command and
doesn't integrate with any prior rotation values.
The LR command was introduced in revision 2016.12.
SPEC: 2023.03
SECTION: 4.9.4
Source code in src/pygerber/gerberx3/tokenizer/tokens/lr_load_rotation.py
| class LoadRotation(Token):
"""Wrapper for load rotation token.
### LR Command: Rotation Graphics State Parameter
The `LR` command is utilized to configure the rotation graphics state parameter.
Functionality:
- This command specifies the rotation angle to be applied when crafting objects.
- The aperture is rotated centered on its origin, which might either coincide with
or differ from its geometric center.
Usage and Persistence:
- The `LR` command can be invoked numerous times throughout a file.
- Once defined, the object rotation retains its configuration unless overridden by
an ensuing `LR` command.
- Rotation is strictly determined by the exact value mentioned in the command and
doesn't integrate with any prior rotation values.
The LR command was introduced in revision 2016.12.
SPEC: `2023.03` SECTION: `4.9.4`
"""
rotation: Decimal
@classmethod
def from_tokens(cls, **tokens: Any) -> Self:
"""Initialize token object."""
rotation = Decimal(tokens["rotation"])
return cls(rotation=rotation)
def update_drawing_state(
self,
state: State,
_backend: Backend,
) -> Tuple[State, Iterable[DrawCommand]]:
"""Set drawing polarity."""
return (
state.model_copy(
update={
"rotation": self.rotation,
},
),
(),
)
def __str__(self) -> str:
return f"LR{self.rotation}*"
|
from_tokens
classmethod
from_tokens(**tokens: Any) -> Self
Initialize token object.
Source code in src/pygerber/gerberx3/tokenizer/tokens/lr_load_rotation.py
| @classmethod
def from_tokens(cls, **tokens: Any) -> Self:
"""Initialize token object."""
rotation = Decimal(tokens["rotation"])
return cls(rotation=rotation)
|
update_drawing_state
update_drawing_state(
state: State, _backend: Backend
) -> Tuple[State, Iterable[DrawCommand]]
Set drawing polarity.
Source code in src/pygerber/gerberx3/tokenizer/tokens/lr_load_rotation.py
| def update_drawing_state(
self,
state: State,
_backend: Backend,
) -> Tuple[State, Iterable[DrawCommand]]:
"""Set drawing polarity."""
return (
state.model_copy(
update={
"rotation": self.rotation,
},
),
(),
)
|