openpine_vm/visuals/
line.rs

1use openpine_compiler::instructions::Color;
2use openpine_macros::Enum;
3use serde::{Deserialize, Serialize};
4
5use crate::visuals::{Extend, XLocation};
6
7/// Line rendering style.
8#[derive(Enum, Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
9#[openpine(rename_all = "snake")]
10pub enum LineStyle {
11    /// Solid stroke.
12    #[default]
13    Solid,
14    /// Dotted stroke.
15    Dotted,
16    /// Dashed stroke.
17    Dashed,
18    /// Stroke with a left arrow.
19    ArrowLeft,
20    /// Stroke with a right arrow.
21    ArrowRight,
22    /// Stroke with arrows on both ends.
23    ArrowBoth,
24}
25
26/// A line visual primitive.
27#[derive(Debug, Clone, Serialize, Deserialize)]
28pub struct Line {
29    /// First X coordinate.
30    pub x1: i64,
31    /// First Y coordinate.
32    pub y1: f64,
33    /// Second X coordinate.
34    pub x2: i64,
35    /// Second Y coordinate.
36    pub y2: f64,
37    /// X axis reference.
38    pub xloc: XLocation,
39    /// Extend behavior.
40    pub extend: Extend,
41    /// Optional stroke color.
42    pub color: Option<Color>,
43    /// Stroke style.
44    pub style: LineStyle,
45    /// Stroke width.
46    pub width: i32,
47    /// Whether to force overlay rendering.
48    pub force_overlay: bool,
49}