Visual Mapper
The visual-mapper crate compiles YAML mapping rules into GPU-ready visual parameters. Fields from live data drive color, size, opacity, and transforms.
MappingRule
| Field | Type | Description |
| field | String | Source data field name |
| target | VisualTarget | Color | Scale | Opacity | Rotation |
| gradient | Vec<GradientStop> | Color stops for interpolation |
| range | [f64; 2] | Input data range (min, max) |
| output_range | [f64; 2] | Mapped output range |
| transform | Transform | Linear | Log | Clamp | Step |
ConditionalRule
| Field | Type | Description |
| condition.field | String | Field to evaluate |
| condition.op | Op | Gt | Lt | Eq | Between | In |
| condition.value | Value | Threshold or set of values |
| apply.color | Option<Color> | Override color on match |
| apply.scale | Option<f64> | Override scale on match |
| apply.opacity | Option<f64> | Override opacity on match |
YAML Example (HVAC)
rules:
- field: temperature
target: Color
gradient:
- { at: 0.0, color: "#3b82f6" } # cool blue
- { at: 0.5, color: "#eab308" } # warm yellow
- { at: 1.0, color: "#ef4444" } # hot red
range: [15.0, 40.0]
transform: Linear
- field: fan_speed
target: Scale
range: [0, 100]
output_range: [0.5, 2.0]
transform: Log
conditionals:
- condition: { field: status, op: Eq, value: "ALARM" }
apply: { color: "#ef4444", scale: 1.5, opacity: 1.0 }
defaults:
color: "#6b7280"
scale: 1.0
opacity: 0.8
Compilation Pipeline
YAML → Deserialize → Validate → Compile → CompiledRuleSet
|
GPU uniform buffer
YAML Configuration
yaml MappingRule
auto-generated
| Field | Type | Default | Description |
| field* | String | — | Telemetry field name to evaluate. |
| target* | String | — | Visual target: `"color"`, `"scale"`, `"opacity"`, or `"trail_color"`. |
| gradient | Vec<String> | [] | Hex colour stops for gradient interpolation. |
| range | [f64; 2] | — | Input value range `[min, max]` for normalization. |
| output_range | [f64; 2] | — | Output range `[min, max]` for scale/opacity targets. |
| transform | String | — | Transform function: `"log"`, `"sqrt"`, or `None`. |
yaml ConditionalRule
auto-generated
| Field | Type | Default | Description |
| condition* | Condition | — | The condition to evaluate. |
| apply* | ConditionalApply | — | The visual overrides to apply when the condition is true. |
yaml VisualDefaults
auto-generated
| Field | Type | Default | Description |
| color | String | #22CC55 | Default colour (hex string). |
| scale | f64 | 1.0 | Default scale factor. |
| opacity | f64 | 1.0 | Default opacity. |
| trail_color | String | — | Optional trail colour (hex string). |
Example YAML
rules:
- field: temperature
target: color
gradient: ["#3b82f6", "#eab308", "#ef4444"]
range: [15.0, 40.0]
- field: fan_speed
target: scale
range: [0, 100]
output_range: [0.5, 2.0]
transform: log
conditionals:
- condition:
field: status
op: eq
value: "ALARM"
apply:
color: "#ef4444"
scale: 1.5
opacity: 1.0
defaults:
color: "#22CC55"
scale: 1.0
opacity: 0.8
trail_color: "#22CC5580"