an.stage.mirror_states#
Mirror states (an#819): the drawing art uses when it is drawn mirrored.
A carried item mirrors with its carrier (the hold layer composes the hand’s
transform, mirror included), which is right for the handle and wrong for
lettering: a “BEST DAD EVER!” mug carried by a character turned to face right
reads backwards. Art says which drawing to use when it is drawn mirrored, per
key of a swap set, in its store document’s metadata:
metadata:
mirror_states: {best_dad: best_dad_mirror}
lettering: true
and the stage swaps to it wherever the drawing’s net x scale on the set is
negative (its own, every parent’s: held, placed, fallen, or mirrored by hand),
so lettering always reads. The mirror_states compile pass (after the solve
and the topple, before the camera) samples the compiled document on the
render’s grid (an.frame_clock.camera_grid()) and writes one stepped swap
channel per drawing that is ever mirrored with a mapped key; a shot where none
is leaves the document byte for byte as it was. The lettering check warns
about art declaring lettering: true drawn mirrored with a drawing that has
no mirror state.
A key maps to a key of the SAME swap set (its mirror drawing is one of the
set’s states). The mirror is read before the camera, as the light check
reads a shaded side.
>>> mirror_states_of({"metadata": {"mirror_states": {"best_dad": "best_dad_mirror"}}})
{'best_dad': 'best_dad_mirror'}
>>> mirror_states_of({"metadata": {}}), mirror_states_of(None)
({}, {})
>>> is_mirrored((-1.0, 0.0, 0.0, 1.0, 0.0, 0.0)), is_mirrored((-1.0, 0.0, 0.0, -1.0, 0.0, 0.0))
(True, False)
Module Attributes
The art-metadata key naming each swap-set key's mirror drawing. |
|
The art-metadata key saying the art carries lettering (it must not read mirrored). |
|
Where the art's declarations live in its store document. |
|
after |
|
last at the time it runs, so its channel wins over the authored swaps it already accounts for. |
Functions
|
The pairs of |
|
The |
|
Whether the art says it carries lettering ( |
|
Each drawing of |
|
Whether an affine |
The |
|
|
|
|
|
|
The |
Classes
|
What one drawing of an entity shows at one instant. |
Exceptions
Art declares |
|
A drawing with a mirror state that the stage cannot swap (said, not raised). |
- an.stage.mirror_states.ART_METADATA_KEY: str = 'metadata'#
Where the art’s declarations live in its store document.
- class an.stage.mirror_states.DrawingState(t, path, swap_set, key, mirrored, ambiguous=False)[source]#
Bases:
objectWhat one drawing of an entity shows at one instant.
- an.stage.mirror_states.LETTERING_KEY: str = 'lettering'#
The art-metadata key saying the art carries lettering (it must not read mirrored).
- an.stage.mirror_states.MIRROR_STATES_KEY: str = 'mirror_states'#
The art-metadata key naming each swap-set key’s mirror drawing.
- an.stage.mirror_states.MIRROR_STATES_ORDER: int = 540#
after
solve(525) andtopple(535), which mirror what they carry or tip, before the camera passes (550+).- Type:
The compile pass’s order
- an.stage.mirror_states.MIRROR_TRACK: str = '__mirror__'#
last at the time it runs, so its channel wins over the authored swaps it already accounts for.
- Type:
The track the pass’s channels are placed on
- exception an.stage.mirror_states.MirrorStatesError[source]#
Bases:
ValueErrorArt declares
mirror_statesthat do not read.
- exception an.stage.mirror_states.MirrorStatesWarning[source]#
Bases:
UserWarningA drawing with a mirror state that the stage cannot swap (said, not raised).
- an.stage.mirror_states.applicable_pairs(states, keys)[source]#
The pairs of
statesone swap set can show: both the key and its mirror key are among the set’skeys(a set projected onto a slot holds only the keys that slot’s drawings resolve, so another slot may hold one and not the other).>>> applicable_pairs({"plain": "flipped", "x": "y"}, {"plain", "flipped", "x"}) {'plain': 'flipped'}
- an.stage.mirror_states.art_metadata(document)[source]#
The
metadataof an art store document ({}when it has none).
- an.stage.mirror_states.declares_lettering(document)[source]#
Whether the art says it carries lettering (
metadata.lettering: true).- Return type:
- an.stage.mirror_states.drawing_states(doc, entity_id, times, *, swap_sets_only=True)[source]#
Each drawing of
entity_idin the compiled (or assembled) documentdocat each oftimes: the swap set and key in force (the timeline’s, else the drawing it is built with) and whether it is drawn mirrored on the set (before the camera).swap_sets_only=Falseincludes the drawings with no swap set (their set and key areNone).- Return type:
- an.stage.mirror_states.is_mirrored(matrix)[source]#
Whether an affine
(a, b, c, d, x, y)flips handedness (its net x scale is negative, whatever the rotation): its determinant is negative.- Return type:
- an.stage.mirror_states.mirror_channel_targets(doc)[source]#
The
(node path, swap set)pairs themirror_statespass wrote a channel for in the compileddoc.
- an.stage.mirror_states.mirror_channels(doc, entity_id, states, times, *, shot_id='')[source]#
{(node path, swap set): [(t, key), ...]}: for each drawing ofentity_idthat is ever mirrored showing a key with a mirror state its set can show (applicable_pairs()), its key at each change oftimes, the mirror key wherever it is drawn mirrored. Empty when nothing needs to change. A mirror key no swap set of the entity holds raises: the declaration names a drawing that does not exist.
- an.stage.mirror_states.mirror_states_of(document)[source]#
{key: its mirror key}the art declares ({}for none); a declaration that is not a mapping of names to names raises.
- an.stage.mirror_states.mirror_states_pass(state)[source]#
The
mirror_statescompile pass (orderMIRROR_STATES_ORDER): see the module docstring. A no-op for a shot whose entities’ art declares no mirror state.- Return type: