class
Diorite::TelemetryGraph
- Diorite::TelemetryGraph
- Reference
- Object
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.crConstructors
-
.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
TelemetryGraphwith the given configuration parameters.
Instance Method Summary
-
#add_sample(value : Number) : Void
Appends a new scalar sample value to the primary history ring buffer.
-
#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.
-
#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.
-
#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.
-
#clear : Void
Clears all collected sample history and thresholds from the graph.
-
#color : Godot::Color
Primary line and border outline color.
-
#latest_value : Float32
Returns the most recently appended value on the primary series, or
0.0if empty. -
#max_samples : Int32
Maximum historical sample capacity before older values are evicted.
-
#max_val : Float32
Expected upper value bound for normalization.
-
#min_val : Float32
Expected lower value bound for normalization.
-
#rect : Godot::Rect2
2D screen coordinate bounding rectangle for the graph box.
-
#samples : Array(Float32)
Array storing current active history samples in chronological order for the default series.
-
#series : Hash(String, TelemetrySeries)
Named series dictionary for multi-metric overlay graphs.
-
#thresholds : Array(TelemetryThreshold)
List of horizontal threshold guidelines.
-
#title : String
Title or metric name displayed above the graph.
Constructor Detail
Creates a new TelemetryGraph with the given configuration parameters.
Instance Method Detail
Appends a new scalar sample value to the primary history ring buffer.
Automatically discards the oldest sample if the buffer has reached #max_samples.
Appends a new scalar sample to a named series, creating the series if it doesn't already exist.
Adds a horizontal threshold line across the graph.
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.
Returns the most recently appended value on the primary series, or 0.0 if empty.
Array storing current active history samples in chronological order for the default series.
Named series dictionary for multi-metric overlay graphs.