Neural Sketch

Fill Between

Visually fill the area between diagram elements using Neural Sketch.

Introduction

The \nskFillBetween command allows you to visually fill the area between two elements—such as blocks or coordinates—in your Neural Sketch diagrams. It is particularly useful for emphasizing relationships, highlighting regions, or simply enhancing visual clarity.


Usage

\nskFillBetween[
  from=<source>,
  to=<target>,
  fill=<color>,
  draw=<border-color>,
  opacity=<opacity>,
  edge=<straight|curved>,
  orientation=<vertical|horizontal>,
  corner-offset=<dimension>
]

Parameter Overview

ParameterDescriptionDefault
fromID of the first block or coordinaterequired
toID of the second block or coordinaterequired
fillFill color between elementstransparent
drawBorder color of the filled areanone
opacityOpacity of the filled area (01)1
edgeDetermines if edges are straight or curvedstraight
orientationDirection of filling: vertical or horizontalvertical
corner-offsetOffset to adjust the corner alignment (straight edge)0mm

Examples

Straight vs. Curved Edges

Here’s an illustrative example showcasing both straight and curved fills:

% Straight Edges
\nskContainer[
  text-north=Straight,
  border-type=dashed,
  fill=nskMainAccent!20,
  border-color=nskMainAccent
]{
  \nskBlock[id=ablock, text-center={hello}, width=2cm, height=1cm]
  \nskBlock[id=bblock, text-center={hello}, pos={below=.8cm of ablock}]
 
  \nskFillBetween[
    from=ablock, to=bblock,
    fill=blue!20, draw=blue!50, opacity=0.4,
    edge=straight, orientation=vertical
  ]
}
Fill Between Examples

Advanced Example

This advanced use case demonstrates multiple fills, annotations, and coordinate-based fills:

\begin{nskFigure}
  % Main Block
  \nskBlock[id=ba, width=8cm, height=1cm, border-radius=1mm]
  \nskMarkPath[path-width=8cm, skip-first=true, skip-last=true, step=10mm]{(ba.south west)--(ba.south east)}{
    \draw[black] (0,0)--(0,1cm);
  }
 
  % Coordinates for Measures
  \foreach \i in {0,...,8}{
    \nskCoord[id=rat\i, pos={left=0mm of ba.north west}, shift-x=(10mm*\i), shift-y=4mm]
    \nskCoord[id=ra\i, pos={left=0mm of ba.south west}, shift-x=(10mm*\i)]
  }
 
  % Sub-blocks
  \nskBlock[id=rb00, fill=none, width=3cm, height=1cm, pos={above right=-1.3mm and 0mm of ra0}, border-color=none]
  \nskBlock[id=rb01, fill=none, width=3cm, height=1cm, pos={above right=-1.3mm and 0mm of ra5}, border-color=none]
 
  % Lower Block
  \nskBlock[id=bb, width=2cm, height=1cm, pos={below=3cm of ba}, border-radius=1mm]
 
  \nskBlock[id=rb10, fill=none, width=1cm, height=1cm, pos={above right=0cm of bb.south west}, border-color=none]
  \nskBlock[id=rb11, fill=none, width=1cm, height=1cm, pos={above right=0cm and 1cm of bb.south west}, border-color=none]
 
  % Measure Lines
  \nskConnect[from=rat0, to=rat3, arrow-style={Bar-Bar, thick, shorten >=-4pt, shorten <=2pt}]
  \nskConnect[from=rat3, to=rat5, color=nskStrongBlue, arrow-style={Bar-Bar, thick, shorten >=-4pt, shorten <=2pt}]
  \nskConnect[from=rat5, to=rat8, arrow-style={Bar-Bar, thick, shorten >=-4pt, shorten <=2pt}]
 
  % Fill Areas
  \nskFillBetween[from=ba, to=bb, edge=curved, orientation=vertical]
  \nskFillBetween[from=rb00, to=rb10, edge=curved, orientation=vertical]
  \nskFillBetween[from=rb01, to=rb11, edge=curved, orientation=vertical]
 
  % Annotations
  \nskAnnotate[
    pos={right=2cm of ba}, connect-to=ba.east,
    title={Key Observations},
    text={This region represents important metrics.},
    connect-opts={arrow-style={dotted, thick}}
  ]
 
  \nskAnnotate[
    pos={right=5cm of rb11}, connect-to=rb11.east,
    title={Further Analysis},
    text={Highlighting key interactions.},
    connect-opts={arrow-style={dotted, thick}}
  ]
\end{nskFigure}
Advanced Fill Between Example

Best Practices

  • Use fills judiciously to avoid visual clutter.
  • Prefer subtle colors and moderate opacity for readability.
  • Pair fills with annotations to clarify meaning.

Reference

PropTypeDefault
corner-offset?dimension{}
draw?token listnskStrongBlue!50
edge?choicestraight
fill?token listnskStrongBlue!20
from?token list{}
opacity?number0.4
orientation?choicevertical
to?token list{}

Key Takeaway

The \nskFillBetween command provides an effective method to visually emphasize regions and relationships between diagram elements, enhancing both clarity and aesthetics with customizable fills, edges, and orientation controls.

On this page