nsk@Container
Comprehensive reference for the `\nskContainer` command in Neural Sketch.
Overview
The \nskContainer
macro is a powerful primitive in Neural Sketch, enabling styled grouping of diagram elements with automatic bounding box computation, background styling, padding, rotation, scaling, and precise relative positioning. Containers ensure diagram components stay visually and structurally coherent, particularly in complex diagrams or hierarchical visualizations.
nsk@Container
(s) are built on top of nsk@Group
Basic Usage
A minimal container encapsulating diagram components:
Advanced Example
An advanced use-case showcasing rotations, padding, and relative positioning:
Available Keys
Identity
id
(string
, optional): Assign a unique identifier for referencing or positioning.
Styling
border-type
(string
, default=solid
): Specifies border style (solid
,dashed
,none
).
border-color
(color
, default=nskLighterGray
): Container border color.
fill
(color
, default=nskLightestGray
): Background fill color.
padding
(dimension
, default=0.5cm
): Padding around grouped content.
Transformations
rotate
(number
, default=0
): Rotation angle of the container (degrees).
scale
(number
, default=1
): Uniform scaling of container content.
shift-x
,shift-y
(number
, default=0
): Horizontal and vertical displacement.
Positioning
pos
(coordinate
, default={}
): Precise positioning relative to another node. Automatically computes internal spacing based on padding.
Container positioning (pos
) intelligently accounts for padding, ensuring content maintains comfortable margins.
Advanced Group Options
group-opts
(token list
, optional): Pass additional group options to nsk@Group for advanced customization.
Internal Mechanics
Internally, \nskContainer
:
- Computes bounding boxes around enclosed elements automatically.
- Supports nested transformations (scale, rotate, translate) seamlessly.
- Supports any-shape padding and clipping.
- Supports multi-layering.
Practical Use Cases
Grouped Visualizations
Use containers to visually encapsulate related blocks, enhancing readability:
Reference Table
Prop | Type | Default |
---|---|---|
id? | string |
|
border-type? | string | solid |
border-color? | color | nskLighterGray |
fill? | color | nskLightestGray |
padding? | dimension | 0.5cm |
rotate? | number | 0 |
scale? | number | 1 |
shift-x? | number | 0 |
shift-y? | number | 0 |
pos? | coordinate | {} |
group-opts? | token list | {} |