raygeo.sketch.entities.text_box
TextBox
A text box framed by origin, width and height points.
array_copy
array_copy: bool
Whether the entity was created as part of an array copy.
bold
bold: bool
Whether the text is bold.
constrained
constrained: bool
Whether the entity is fully constrained, as computed by the solver.
construction
construction: bool
Whether the entity is construction geometry.
construction_line_ids
construction_line_ids: list[int]
content
content: str
fill_color
fill_color: Optional[tuple[float, float, float, float]]
Fill color as (r, g, b, a), or None.
font_config
font_config: text.FontConfig
The font configuration as a FontConfig object.
font_family
font_family: str
The font family name.
font_size
font_size: float
The font size in points.
height_id
height_id: int
Height point id.
id
id: types.EntityID
Unique entity id.
invisible
invisible: bool
Whether the entity is excluded from toolpath output.
italic
italic: bool
Whether the text is italic.
origin_id
origin_id: int
Origin point id.
type
type: str
The entity type name (attribute alias).
width_id
width_id: int
Width point id.
append_to_geometry()
append_to_geometry(
geo: geo.Geometry,
registry: protocols.Registry,
forward: bool = True,
) -> None
Appends the entity's outline to the geometry.
| Parameter | Type | Description |
|---|---|---|
geo | geo.Geometry | |
registry | protocols.Registry | |
forward | bool = True | |
| Returns | None |
characteristic_length()
characteristic_length(registry: protocols.Registry) -> float
The characteristic length used by equal-length constraints.
| Parameter | Type | Description |
|---|---|---|
registry | protocols.Registry | |
| Returns | float |
characteristic_length_pairs()
characteristic_length_pairs() -> list[list[int]]
The defining-point pairs of the characteristic length.
| Parameter | Type | Description |
|---|---|---|
| Returns | list[list[int]] |
clear_helper_references()
clear_helper_references() -> None
Drops this entity's references to its helper entities.
| Parameter | Type | Description |
|---|---|---|
| Returns | None |
contains_point()
contains_point(registry: protocols.Registry, x: float, y: float) -> bool
Whether the model-space point lies inside the entity.
| Parameter | Type | Description |
|---|---|---|
registry | protocols.Registry | |
x | float | |
y | float | |
| Returns | bool |
create_fill_geometry()
create_fill_geometry(registry: protocols.Registry) -> Optional[geo.Geometry]
The fill geometry of the entity, if it supports fills.
| Parameter | Type | Description |
|---|---|---|
registry | protocols.Registry | |
| Returns | Optional[geo.Geometry] |
enclosed_signed_area()
enclosed_signed_area(registry: protocols.Registry) -> float
The signed area enclosed by the entity, if defined.
| Parameter | Type | Description |
|---|---|---|
registry | protocols.Registry | |
| Returns | float |
from_dict()
from_dict(data: dict) -> TextBox
Builds an entity from its reference dictionary shape.
| Parameter | Type | Description |
|---|---|---|
data | dict | |
| Returns | TextBox |
geometry_signature()
geometry_signature(registry: protocols.Registry) -> tuple
Returns the geometry signature used for change detection.
| Parameter | Type | Description |
|---|---|---|
registry | protocols.Registry | |
| Returns | tuple |
get_all_frame_point_ids()
get_all_frame_point_ids(registry: protocols.Registry) -> list[int]
All four frame corner point ids.
| Parameter | Type | Description |
|---|---|---|
registry | protocols.Registry | |
| Returns | list[int] |
get_drag_anchor_points()
get_drag_anchor_points(point_id: int) -> list[int]
Point ids that act as drag anchors for the given point.
| Parameter | Type | Description |
|---|---|---|
point_id | int | |
| Returns | list[int] |
get_endpoint_ids()
get_endpoint_ids() -> list[int]
The entity ids of the curve endpoints.
| Parameter | Type | Description |
|---|---|---|
| Returns | list[int] |
get_font_metrics()
get_font_metrics() -> tuple[float, float, float]
Font metrics (ascent, descent, height) for the configured font.
| Parameter | Type | Description |
|---|---|---|
| Returns | tuple[float, float, float] |
get_fourth_corner_id()
get_fourth_corner_id(registry: protocols.Registry) -> Optional[int]
The text content. The ids of the frame construction lines. The fourth frame corner point id, if resolvable.
| Parameter | Type | Description |
|---|---|---|
registry | protocols.Registry | |
| Returns | Optional[int] |
get_frame_polygon()
get_frame_polygon(
registry: protocols.Registry,
) -> Optional[list[tuple[float, float]]]
The four-corner frame polygon in world coordinates.
| Parameter | Type | Description |
|---|---|---|
registry | protocols.Registry | |
| Returns | Optional[list[tuple[float, float]]] |
get_helper_ids()
get_helper_ids() -> list[int]
Auxiliary/child entity ids belonging to this compound entity.
| Parameter | Type | Description |
|---|---|---|
| Returns | list[int] |
get_ignorable_unconstrained_points()
get_ignorable_unconstrained_points() -> list[int]
Point ids that can remain unconstrained when this entity is constrained.
| Parameter | Type | Description |
|---|---|---|
| Returns | list[int] |
get_junction_point_ids()
get_junction_point_ids() -> list[int]
Point ids acting as junction candidates for chaining.
| Parameter | Type | Description |
|---|---|---|
| Returns | list[int] |
get_natural_size()
get_natural_size(content: Optional[str]) -> tuple[float, float]
Natural (width, height) of the text content.
| Parameter | Type | Description |
|---|---|---|
content | Optional[str] | |
| Returns | tuple[float, float] |
get_point_ids()
get_point_ids() -> list[int]
The point ids the entity is defined by.
| Parameter | Type | Description |
|---|---|---|
| Returns | list[int] |
get_rigidly_connected_points()
get_rigidly_connected_points(point_id: int) -> list[int]
Point ids that move rigidly with the given point.
| Parameter | Type | Description |
|---|---|---|
point_id | int | |
| Returns | list[int] |
get_state()
get_state() -> Optional[dict]
Solver-relevant discrete state for undo/redo snapshots.
| Parameter | Type | Description |
|---|---|---|
| Returns | Optional[dict] |
hit_test()
hit_test(
mx: float,
my: float,
threshold: float,
registry: protocols.Registry,
) -> bool
Whether the entity is hit at model coordinates (mx, my).
| Parameter | Type | Description |
|---|---|---|
mx | float | |
my | float | |
threshold | float | |
registry | protocols.Registry | |
| Returns | bool |
intersects_rect()
intersects_rect(
rect: tuple[float, float, float, float],
registry: protocols.Registry,
) -> bool
Whether the entity intersects the given rect.
| Parameter | Type | Description |
|---|---|---|
rect | tuple[float, float, float, float] | |
registry | protocols.Registry | |
| Returns | bool |
is_closed_loop()
is_closed_loop() -> bool
Whether the entity forms a closed loop.
| Parameter | Type | Description |
|---|---|---|
| Returns | bool |
is_contained_by()
is_contained_by(
rect: tuple[float, float, float, float],
registry: protocols.Registry,
) -> bool
Whether the entity is fully contained by the given rect.
| Parameter | Type | Description |
|---|---|---|
rect | tuple[float, float, float, float] | |
registry | protocols.Registry | |
| Returns | bool |
is_edge_entity()
is_edge_entity() -> bool
Whether the entity participates in edge/chaining adjacency for loop detection (line, arc, bezier).
| Parameter | Type | Description |
|---|---|---|
| Returns | bool |
is_radius_entity()
is_radius_entity() -> bool
Whether the entity has a radius (arc, circle).
| Parameter | Type | Description |
|---|---|---|
| Returns | bool |
restore_base_flags()
restore_base_flags(data: dict) -> None
Restores base flags serialized by to_dict() but not accepted as constructor arguments.
| Parameter | Type | Description |
|---|---|---|
data | dict | |
| Returns | None |
set_fill_color()
set_fill_color(color: Optional[Sequence[float]]) -> bool
Sets the fill color; returns whether the entity supports fills.
| Parameter | Type | Description |
|---|---|---|
color | Optional[Sequence[float]] | |
| Returns | bool |
set_state()
set_state(state: dict) -> None
Restores solver-relevant discrete state from a snapshot.
| Parameter | Type | Description |
|---|---|---|
state | dict | |
| Returns | None |
signed_distance_to()
signed_distance_to(
px: float,
py: float,
registry: protocols.Registry,
) -> Optional[float]
Signed distance from the model-space point, if defined.
| Parameter | Type | Description |
|---|---|---|
px | float | |
py | float | |
registry | protocols.Registry | |
| Returns | Optional[float] |
supports_fill()
supports_fill() -> bool
Whether this entity can receive a fill color.
| Parameter | Type | Description |
|---|---|---|
| Returns | bool |
supports_point_on_curve()
supports_point_on_curve() -> bool
Whether a point can be constrained onto this entity's curve.
| Parameter | Type | Description |
|---|---|---|
| Returns | bool |
tangent_at()
tangent_at(registry: protocols.Registry, point_id: int) -> tuple[float, float]
Tangent direction at the point nearest the model-space point.
| Parameter | Type | Description |
|---|---|---|
registry | protocols.Registry | |
point_id | int | |
| Returns | tuple[float, float] |
to_dict()
to_dict() -> dict
Serializes the entity to the reference dictionary shape.
| Parameter | Type | Description |
|---|---|---|
| Returns | dict |
to_geometry()
to_geometry(
registry: protocols.Registry,
resolved_content: Optional[str] = None,
) -> geo.Geometry
Returns the entity's toolpath geometry in model coordinates.
| Parameter | Type | Description |
|---|---|---|
registry | protocols.Registry | |
resolved_content | Optional[str] = None | |
| Returns | geo.Geometry |
to_polygon_vertices()
to_polygon_vertices(
registry: protocols.Registry,
forward: bool = True,
) -> list[tuple[float, float]]
Returns the entity's outline as polygon vertices.
| Parameter | Type | Description |
|---|---|---|
registry | protocols.Registry | |
forward | bool = True | |
| Returns | list[tuple[float, float]] |
to_polyline()
to_polyline(
registry: protocols.Registry,
tolerance: float = 0.1,
) -> list[tuple[float, float]]
Returns the entity's centerline as polyline vertices.
| Parameter | Type | Description |
|---|---|---|
registry | protocols.Registry | |
tolerance | float = 0.1 | |
| Returns | list[tuple[float, float]] |
type_name()
type_name() -> str
The entity type name.
| Parameter | Type | Description |
|---|---|---|
| Returns | str |
update_constrained_status()
update_constrained_status(
registry: protocols.Registry,
constraints: Any,
) -> None
Updates the constrained flag from defining-point status and constraints that dimension this entity's radius or length.
| Parameter | Type | Description |
|---|---|---|
registry | protocols.Registry | |
constraints | Any | |
| Returns | None |
write_back()
write_back() -> None
Persists in-place edits back to the owning registry, if any.
| Parameter | Type | Description |
|---|---|---|
| Returns | None |