an.stage.shadow#
Contact shadows: an ellipse where a supported member meets its surface (an#519 rank 16, catalogue D2).
A member that says shadow: contact (its entity’s overrides.shadow, or
metadata.shadow in its store document, next to shaded_side and
contacts; the entity’s own wins) gets, for each of its supports (a
declared support joint, or the stance it is taken to have on the shot’s
floor, an.stage.support.supports_at()), one flattened ellipse on the
surface spanning its contacts, painted just under it (and under what rides
just behind it; in a world that reorders it by depth, its shadow rides its
paint keys, shadow_paint_keys()). It is a compile-pass product (a
synthetic node <entity>__shadow, like the stage’s __band containers),
never authored:
where: the foot of the normal from its held contacts (those within the support tolerance of the surface) onto the surface, the midpoint of the outermost two when there are several, and the ellipse spans them; with none held, under the lowest contact. Along the surface, never below or above it: a member that rises leaves its shadow on the floor.
tilt: the surface’s direction (a shadow on a tilted crate lies along it; the world’s floor under a rolled camera,
an.base.GROUND_OVERRIDE).the light: offset along the surface away from the scene’s light (
meta.light, catalogue D1), by its lean along the surface (light_lean()); straight under the contact with no light.presence: full while the support is joined and its lowest contact within the support tolerance (or sunk: the
supportcheck reports that); fading and shrinking as the member rises beyond it, goneCONTACT_SHADOW_FADEof its height above; gone while the support isunjoined, while the member is not seen, and times the member’s own alpha.
size: fractions of the member’s height and width as the shot opens, scaled by its node’s scale since (a member the world brings nearer grows, and so does its shadow).
Every size is a named fraction (CONTACT_SHADOW_WIDTH, …). A shot
where no member asks for a shadow is not touched (byte-identical), and a
shadow that does not move is a static node with no channel.
shadow: cast (a skewed silhouette along the light) is not built: it is
refused by name (CastShadowNotBuiltError).
>>> light_lean((-1.0, -1.0)) # from the upper left: cast to the right
0.7071067811865475
>>> light_lean((0.0, -1.0)), light_lean((1.0, 0.0), elevation=60.0)
(0.0, -0.5000000000000001)
Module Attributes
the entity's |
|
A flattened ellipse per support, spanning its contacts (built). |
|
A skewed silhouette along the light (catalogue D2's second form; not built). |
|
an entity's override that switches off its art's. |
|
The synthetic node's name after the entity id ( |
|
The ellipse's least width, as a fraction of the member's height ... |
|
just wider than what stands on it, so it shows on both sides of a box or a cup. |
|
What the ellipse adds to the span of its held contacts (both feet), as a fraction of the member's height: it reaches past the outermost. |
|
a floor seen at a glance. |
|
the floor shows through it). |
|
How far it is cast along the surface, away from the light, per unit of the light's lean along it ( |
|
How far above the support tolerance (a fraction of the member's height) the shadow has faded to nothing: a hop keeps a fading one, a float loses it. |
|
How much it shrinks by the time it has faded (a fraction of its size). |
|
Its colour. |
Functions
|
The shadow |
|
How far a shadow falls along a surface of unit direction |
|
The contact shadow of one |
|
The synthetic node of |
|
|
|
The paint keys ( |
|
The |
Classes
|
A contact shadow at one instant, on the stage: its centre, its tilt (radians), its width (px, before |
Exceptions
A |
|
|
- an.stage.shadow.CAST_SHADOW: str = 'cast'#
A skewed silhouette along the light (catalogue D2’s second form; not built).
- an.stage.shadow.CONTACT_SHADOW: str = 'contact'#
A flattened ellipse per support, spanning its contacts (built).
- an.stage.shadow.CONTACT_SHADOW_FADE: float = 0.15#
How far above the support tolerance (a fraction of the member’s height) the shadow has faded to nothing: a hop keeps a fading one, a float loses it.
- an.stage.shadow.CONTACT_SHADOW_FLATTEN: float = 0.2#
a floor seen at a glance.
- Type:
The ellipse’s height as a fraction of its least width
- an.stage.shadow.CONTACT_SHADOW_MARGIN: float = 0.15#
What the ellipse adds to the span of its held contacts (both feet), as a fraction of the member’s height: it reaches past the outermost.
- an.stage.shadow.CONTACT_SHADOW_OFFSET: float = 0.15#
How far it is cast along the surface, away from the light, per unit of the light’s lean along it (
light_lean()), as a fraction of the member’s height.
- an.stage.shadow.CONTACT_SHADOW_OPACITY: float = 0.35#
the floor shows through it).
- Type:
Its alpha at full strength (a black ellipse
- an.stage.shadow.CONTACT_SHADOW_SHRINK: float = 0.5#
How much it shrinks by the time it has faded (a fraction of its size).
- an.stage.shadow.CONTACT_SHADOW_SPREAD: float = 1.1#
just wider than what stands on it, so it shows on both sides of a box or a cup.
- Type:
… or of its drawn width as the shot opens, whichever is wider
- an.stage.shadow.CONTACT_SHADOW_WIDTH: float = 0.4#
The ellipse’s least width, as a fraction of the member’s height …
- exception an.stage.shadow.CastShadowNotBuiltError[source]#
Bases:
ShadowErrorshadow: cast(a skewed silhouette along the light, catalogue D2) is not built yet.
- an.stage.shadow.NO_SHADOW: str = 'none'#
an entity’s override that switches off its art’s.
- Type:
No shadow
- an.stage.shadow.SHADOW_INFIX: str = '__shadow'#
The synthetic node’s name after the entity id (
__is reserved for the stage’s own nodes, so no authored id can take it); a member with several supports gets<id>__shadow_<k>for the second on.
- an.stage.shadow.SHADOW_KEY: str = 'shadow'#
the entity’s
overrides(a core override key,an.base.SHADOW_OVERRIDE) or its store document’smetadata.- Type:
The declaration’s key
- exception an.stage.shadow.ShadowError[source]#
Bases:
CutoutCompileErrorA
shadowdeclaration the stage cannot draw.
- class an.stage.shadow.ShadowPose(x, y, rotation, width, alpha, shrink=1.0)[source]#
Bases:
objectA contact shadow at one instant, on the stage: its centre, its tilt (radians), its width (px, before
shrink), its alpha, and how much it has shrunk as its member rose (1: not at all).
- an.stage.shadow.contact_shadow_pass(state)[source]#
The
contact_shadowscompile pass (catalogue D2): a shadow node under each supported member that asks for one, one per support (spanning its contacts), keyed every frame of the shot’s grid where it moves. A no-op (byte-identical) when no member asks.- Return type:
- an.stage.shadow.contact_shadow_pose(state, *, height, light=None, elevation=None, tolerance=None, least=None, width=0.4, margin=0.15, offset=0.15, fade=0.15, shrink=0.5, opacity=0.35)[source]#
The contact shadow of one
an.stage.support.SupportState, its memberheightpx tall now;Nonewhen it measured no contact (off a bounded surface’s ends).tolerancedefaults to the support’s (an.stage.support.support_tolerance()ofheight),least(the narrowest the ellipse is, px) towidthofheight.>>> from an.stage.support import ContactState, SupportState >>> floor = ((0.0, 100.0), (1.0, 0.0)) >>> def at(*feet, joined=True): ... cs = tuple(ContactState(f"c{i}", "cup", p, 100.0 - p[1]) for i, p in enumerate(feet)) ... return SupportState("cup", None, "", 0, 0.0, floor, "ground", cs, joined, 50.0, "metadata") >>> p = contact_shadow_pose(at((10.0, 100.0)), height=50.0) >>> (p.x, p.y, p.width, p.alpha, p.shrink) (10.0, 100.0, 20.0, 0.35, 1.0) >>> contact_shadow_pose(at((10.0, 100.0)), height=50.0, light=(-1.0, 0.0)).x # cast right 17.5 >>> contact_shadow_pose(at((0.0, 100.0), (40.0, 100.0)), height=50.0).width # both feet 47.5 >>> contact_shadow_pose(at((10.0, 100.0), joined=False), height=50.0).alpha 0.0 >>> contact_shadow_pose(at((10.0, 90.0)), height=50.0).alpha # risen 10 px: faded 0.0
- Return type:
- an.stage.shadow.light_lean(light, *, elevation=None, along=(1.0, 0.0))[source]#
How far a shadow falls along a surface of unit direction
along, away from a light that comes FROMlighton screen (x right, y down;an.ir.schema.SceneLight.vector), per unit of the offset: the component of the direction away from the light along the surface, or, when the light’selevation(degrees above the ground) is said, its cosine on that side.0with no light or one straight above.>>> light_lean((1.0, -1.0)) # from the upper right: cast to the left -0.7071067811865475 >>> light_lean((-1.0, -1.0), elevation=90.0) < 1e-12, light_lean(None) (True, 0.0) >>> round(light_lean((-1.0, 0.0), along=(0.0, -1.0)), 12) # a wall's surface 0.0
- Return type:
- an.stage.shadow.shadow_node_name(entity, k=0)[source]#
The synthetic node of
entity’sk-th support’s shadow.>>> shadow_node_name("cup"), shadow_node_name("cup", 1) ('cup__shadow', 'cup__shadow_1')
- Return type:
- an.stage.shadow.shadow_of(entity, desc=None)[source]#
The shadow
entityasks for: itsoverrides.shadow, else its store document’s (desc)metadata.shadow;Nonefor none (none,falseor unset).castand an unknown value are refused by name.>>> from types import SimpleNamespace as NS >>> shadow_of(NS(id="cup", overrides={"shadow": "contact"})) 'contact' >>> shadow_of(NS(id="cup", overrides={"shadow": "none"}), {"metadata": {"shadow": "contact"}}) is None True >>> shadow_of(NS(id="cup", overrides=None), {"metadata": {"shadow": "contact"}}) 'contact' >>> shadow_of(NS(id="cup", overrides={"shadow": "cast"})) Traceback (most recent call last): ... an.stage.shadow.CastShadowNotBuiltError: ...
- an.stage.shadow.shadow_owner(name)[source]#
(entity, k)of the shadow nodename(shadow_node_name()),Nonefor any other node.>>> shadow_owner("cup__shadow"), shadow_owner("cup__shadow_2"), shadow_owner("cup") (('cup', 0), ('cup', 2), None) >>> shadow_owner("cup__shadow_x"), shadow_owner("__shadow") (None, None)
- an.stage.shadow.shadow_paint_keys(names, keys)[source]#
The paint keys (
an.base.PAINT_KEYS_OVERRIDE) of the shadow nodes amongnames, the children of one container, whose member has keys inkeys: each rides its member just behind it at every time (an.base.rider_key(),an.base.RIDER_BEHIND), behind the member’s other riders on that side too (theirnis never negative), as_place()builds it, so a world that reorders its member by depth moves its shadow with it (an#634).>>> keys = {"a": [(0.0, [1, 5, 0]), (1.0, [1, 3, 0])], "b": [(0.0, [1, 4, 0])]} >>> shadow_paint_keys(["a__shadow", "a", "b__shadow_1", "b"], keys)["a__shadow"] [(0.0, [1, 5, 0, -1, -1]), (1.0, [1, 3, 0, -1, -1])] >>> shadow_paint_keys(["c__shadow", "c"], keys) {}