class Diorite::TelemetryGraph

Overview

High-performance circular buffer and geometry builder for 2D real-time telemetry sparkline graphs.

Retains a fixed window of historical samples and transforms them into 2D line primitives and background border outlines inside a designated canvas viewport rectangle.

Supports single-series or multi-series telemetry with horizontal threshold limit indicators.

graph = TelemetryGraph.new("Frametime", Rect2.new(10, 10, 200, 60), min_val: 0.0, max_val: 33.3)
graph.add_sample(16.6)
graph.add_threshold(16.66_f32, Color.new(1.0, 0.2, 0.2, 0.8), "60 FPS")
graph.add_series_sample("Physics", 8.3, Color.new(0.2, 0.6, 1.0))

Defined in:

diorite/core/telemetry_graph.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(title : String, rect : Godot::Rect2 = Godot::Rect2.new(20.0_f32, 20.0_f32, 160.0_f32, 50.0_f32), min_val : Float32 = 0.0_f32, max_val : Float32 = 100.0_f32, color : Godot::Color = Godot::Color.new(0.2_f32, 0.9_f32, 0.3_f32, 1.0_f32), max_samples : Int32 = 60) #

Creates a new TelemetryGraph with the given configuration parameters.


[View source]

Instance Method Detail

def add_sample(value : Number) : Void #

Appends a new scalar sample value to the primary history ring buffer.

Automatically discards the oldest sample if the buffer has reached #max_samples.


[View source]
def add_series_sample(series_name : String, value : Number, series_color : Godot::Color | Nil = nil) : Void #

Appends a new scalar sample to a named series, creating the series if it doesn't already exist.


[View source]
def add_threshold(value : Number, color : Godot::Color = Godot::Color.new(1.0_f32, 0.3_f32, 0.3_f32, 0.8_f32), label : String = "") : Void #

Adds a horizontal threshold line across the graph.


[View source]
def build_geometry(lines_out : Array(Godot::Vector2), colors_out : Array(Godot::Color)) : Void #

Builds line segments and background boundary outlines for rendering on the 2D canvas.

Appends vertices directly to lines_out and corresponding vertex colors to colors_out.


[View source]
def clear : Void #

Clears all collected sample history and thresholds from the graph.


[View source]
def color : Godot::Color #

Primary line and border outline color.


[View source]
def latest_value : Float32 #

Returns the most recently appended value on the primary series, or 0.0 if empty.


[View source]
def max_samples : Int32 #

Maximum historical sample capacity before older values are evicted.


[View source]
def max_val : Float32 #

Expected upper value bound for normalization.


[View source]
def min_val : Float32 #

Expected lower value bound for normalization.


[View source]
def rect : Godot::Rect2 #

2D screen coordinate bounding rectangle for the graph box.


[View source]
def samples : Array(Float32) #

Array storing current active history samples in chronological order for the default series.


[View source]
def series : Hash(String, TelemetrySeries) #

Named series dictionary for multi-metric overlay graphs.


[View source]
def thresholds : Array(TelemetryThreshold) #

List of horizontal threshold guidelines.


[View source]
def title : String #

Title or metric name displayed above the graph.


[View source]