simvx.graphics.render2d.clip_scope¶
The clip + transform scope table (design §2.5).
Today, clip/transform nesting is implicit in walk recursion plus push/pop stacks. Once items live in one flat sorted list the recursion is gone, so the nesting must be encoded. This module is that encoding (the model, §2.5 – not yet wired to a real walk):
Each
push_clip/pop_clip(and the synthesised per-child Control wrap, §2.5) opens/closes a :class:ClipScope. A scope’s effective scissor is the intersection of its own rect with its parent’s effective scissor, computed once at open time and stored with a parent pointer.Every Item records the :class:
ClipScopeIdactive at emission. After sort, the scissor is read straight off the item’s scope – no draw-time clip stack.A scope also carries a
transformid so the Control walk’s implicit per-child translate (§2.5) is reproduced as a scope entry rather than baked.
The hard invariant (§2.5): clipping is a filter, never an ordering input. A scope id travels with its item through the sort; banding never moves an item across a clip boundary. So the table only needs to reproduce, for any item, the exact effective scissor + transform its recursive push/pop would have produced.
Module Contents¶
Classes¶
One entry in the :class: |
|
Builds + stores nested clip/transform scopes for a flat item list (§2.5). |
Data¶
API¶
- simvx.graphics.render2d.clip_scope.__all__¶
[‘ROOT_CLIP_SCOPE’, ‘ClipScope’, ‘ClipScopeTable’]
- simvx.graphics.render2d.clip_scope.Rect¶
None
- simvx.graphics.render2d.clip_scope.ROOT_CLIP_SCOPE¶
0
- class simvx.graphics.render2d.clip_scope.ClipScope[source]¶
Bases:
typing.NamedTupleOne entry in the :class:
ClipScopeTable(design §2.5).scissoris the effective rect (already intersected up the parent chain), so a batch sets the scissor straight fromscissorwith no walk.Nonemeans unbounded.transformis an index into the per-item transform column (-1 = inherit parent / identity), reproducing the Control per-child translate that the walk synthesises.- parent: int¶
None
- scissor: simvx.graphics.render2d.clip_scope.Rect | None¶
None
- transform: int¶
None
- class simvx.graphics.render2d.clip_scope.ClipScopeTable[source]¶
Builds + stores nested clip/transform scopes for a flat item list (§2.5).
Usage models the collection pass: maintain an open-scope cursor, and
- Meth:
push/ :meth:poparound clipped subtrees (or call :meth:opendirectly with an explicit parent). Items record :attr:currentat emission. After collection the table is a flat array indexed byClipScopeId; the effective scissor + transform are read with O(1) :meth:scissor/- Meth:
get.
The root scope (id :data:
ROOT_CLIP_SCOPE) is always present, unclipped, identity transform.Initialization
- __slots__¶
(‘_scopes’, ‘_stack’)
- open(parent: int, clip: simvx.graphics.render2d.clip_scope.Rect | None = None, transform: int = -1) int[source]¶
Create a child scope under
parentand return its id.The new scope’s effective scissor is the intersection of
clipwithparent’s effective scissor (§2.5), so nesting is resolved once at open time. Does not change :attr:current– use :meth:pushfor the stack-style collection cursor.
- push(clip: simvx.graphics.render2d.clip_scope.Rect | None = None, transform: int = -1) int[source]¶
Open a child scope under :attr:
current, make it current, return id.
- pop() int[source]¶
Close the current scope, restoring its parent as current; returns the scope that was just closed (it remains stored in the table).
- get(scope_id: int) simvx.graphics.render2d.clip_scope.ClipScope[source]¶
Return the :class:
ClipScoperecord forscope_id.
- scissor(scope_id: int) simvx.graphics.render2d.clip_scope.Rect | None[source]¶
Return the effective (intersected) scissor for
scope_id(§2.5).