ascii_context Derived Type

type, public, extends(plot_context) :: ascii_context


Components

Type Visibility Attributes Name Initial
integer, public :: width
integer, public :: height
real(kind=wp), public :: x_min
real(kind=wp), public :: x_max
real(kind=wp), public :: y_min
real(kind=wp), public :: y_max
real(kind=wp), public :: view_azim = -1.0471975511965976_wp
real(kind=wp), public :: view_elev = 0.5235987755982988_wp
real(kind=wp), public :: view_dist = 10.0_wp
logical, public :: has_rendered_arrows = .false.
logical, public :: uses_vector_arrows = .false.
logical, public :: has_triangular_arrows = .false.
character(len=1), public, allocatable :: canvas(:,:)
type(plot_margins_t), public :: margins
type(plot_area_t), public :: plot_area
character(len=:), public, allocatable :: title_text
character(len=:), public, allocatable :: xlabel_text
character(len=:), public, allocatable :: ylabel_text
logical, public :: title_set = .false.
type(text_element_t), public, allocatable :: text_elements(:)
integer, public :: num_text_elements = 0
type(text_element_t), public, allocatable :: arrow_elements(:)
integer, public :: num_arrow_elements = 0
real(kind=wp), public :: current_r
real(kind=wp), public :: current_g
real(kind=wp), public :: current_b
logical, public :: stream_mode = .false.
integer, public :: plot_width = 80
integer, public :: plot_height = 24
character(len=96), public, allocatable :: legend_lines(:)
integer, public :: num_legend_lines = 0
logical, public :: capturing_legend = .false.
real(kind=wp), public :: stored_y_min = 0.0_wp
real(kind=wp), public :: stored_y_max = 0.0_wp
logical, public :: has_stored_y_range = .false.
character(len=16), public :: last_xscale = 'linear'
character(len=16), public :: last_yscale = 'linear'
real(kind=wp), public :: last_symlog_threshold = 1.0_wp

Optional custom x-tick positions/labels forwarded by the render engine so the ASCII axis honours set_xticks (issue #1714).

real(kind=wp), public, allocatable :: custom_xtick_positions(:)
character(len=64), public, allocatable :: custom_xtick_labels(:)

Text charset: 'ascii' (default, pure-ASCII bytes), 'unicode' (box-drawing frame plus Unicode markers/arrows, #2060), or 'braille' (2x4 subpixel line/marker data via braille while axes and labels stay text, #2061). 'auto' resolves from the environment.

character(len=16), public :: text_charset = 'ascii'

Text color mode: 'never' (default, no escapes), 'ansi16', 'ansi256', 'truecolor', or 'auto' (resolved from the environment at output time). canvas_color records the packed RGB of each plotted data cell so ANSI SGR spans can be emitted at output assembly (#2062).

character(len=16), public :: text_color_mode = 'never'
integer, public, allocatable :: canvas_color(:,:)
type(braille_canvas_t), public, allocatable :: braille

Type-Bound Procedures

procedure, public :: line => ascii_draw_line

  • private subroutine ascii_draw_line(this, x1, y1, x2, y2)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    real(kind=wp), intent(in) :: x1
    real(kind=wp), intent(in) :: y1
    real(kind=wp), intent(in) :: x2
    real(kind=wp), intent(in) :: y2

procedure, public :: color => ascii_set_color

  • private subroutine ascii_set_color(this, r, g, b)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    real(kind=wp), intent(in) :: r
    real(kind=wp), intent(in) :: g
    real(kind=wp), intent(in) :: b

procedure, public :: text => ascii_draw_text

  • private subroutine ascii_draw_text(this, x, y, text)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    real(kind=wp), intent(in) :: x
    real(kind=wp), intent(in) :: y
    character(len=*), intent(in) :: text

procedure, public :: clear_text_background => ascii_clear_text_background

  • private subroutine ascii_clear_text_background(this, x, y, width)

    Blank a horizontal run of canvas cells so a text overlay (legend block) reads against clear background instead of the plotted curves and axis lines underneath it.

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    real(kind=wp), intent(in) :: x
    real(kind=wp), intent(in) :: y
    integer, intent(in) :: width

procedure, public :: draw_text_overlay => ascii_draw_text_overlay

  • private subroutine ascii_draw_text_overlay(this, x, y, text)

    Place overlay text (legend rows) directly at the given cell so stacked entries keep their own rows. The buffered text path shifts colliding rows to dodge earlier text, which blends adjacent legend labels when the block lands over tick labels; a direct write avoids that.

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    real(kind=wp), intent(in) :: x
    real(kind=wp), intent(in) :: y
    character(len=*), intent(in) :: text

procedure, public :: set_line_width => ascii_set_line_width

  • private subroutine ascii_set_line_width(this, width)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    real(kind=wp), intent(in) :: width

procedure, public :: set_line_style => ascii_set_line_style

  • private subroutine ascii_set_line_style(this, style)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    character(len=*), intent(in) :: style

procedure, public :: save => ascii_save

  • private subroutine ascii_save(this, filename)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    character(len=*), intent(in) :: filename

procedure, public :: save_to_unit => ascii_save_to_unit

  • private subroutine ascii_save_to_unit(this, unit)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    integer, intent(in) :: unit

procedure, public :: set_title => ascii_set_title

  • private subroutine ascii_set_title(this, title)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    character(len=*), intent(in) :: title

procedure, public :: draw_marker => ascii_draw_marker

  • private subroutine ascii_draw_marker(this, x, y, style, size)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    real(kind=wp), intent(in) :: x
    real(kind=wp), intent(in) :: y
    character(len=*), intent(in) :: style
    real(kind=wp), intent(in), optional :: size

procedure, public :: set_marker_colors => ascii_set_marker_colors

  • private subroutine ascii_set_marker_colors(this, edge_r, edge_g, edge_b, face_r, face_g, face_b)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    real(kind=wp), intent(in) :: edge_r
    real(kind=wp), intent(in) :: edge_g
    real(kind=wp), intent(in) :: edge_b
    real(kind=wp), intent(in) :: face_r
    real(kind=wp), intent(in) :: face_g
    real(kind=wp), intent(in) :: face_b

procedure, public :: set_marker_colors_with_alpha => ascii_set_marker_colors_with_alpha

  • private subroutine ascii_set_marker_colors_with_alpha(this, edge_r, edge_g, edge_b, edge_alpha, face_r, face_g, face_b, face_alpha)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    real(kind=wp), intent(in) :: edge_r
    real(kind=wp), intent(in) :: edge_g
    real(kind=wp), intent(in) :: edge_b
    real(kind=wp), intent(in) :: edge_alpha
    real(kind=wp), intent(in) :: face_r
    real(kind=wp), intent(in) :: face_g
    real(kind=wp), intent(in) :: face_b
    real(kind=wp), intent(in) :: face_alpha

procedure, public :: fill_heatmap => ascii_fill_heatmap

  • private subroutine ascii_fill_heatmap(this, x_grid, y_grid, z_grid, z_min, z_max, colormap_name)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    real(kind=wp), intent(in), contiguous :: x_grid(:)
    real(kind=wp), intent(in), contiguous :: y_grid(:)
    real(kind=wp), intent(in), contiguous :: z_grid(:,:)
    real(kind=wp), intent(in) :: z_min
    real(kind=wp), intent(in) :: z_max
    character(len=*), intent(in), optional :: colormap_name

procedure, public :: draw_arrow => ascii_draw_arrow

  • private subroutine ascii_draw_arrow(this, x, y, dx, dy, size, style)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    real(kind=wp), intent(in) :: x
    real(kind=wp), intent(in) :: y
    real(kind=wp), intent(in) :: dx
    real(kind=wp), intent(in) :: dy
    real(kind=wp), intent(in) :: size
    character(len=*), intent(in) :: style

procedure, public :: draw_arrowhead => ascii_draw_arrowhead

  • private subroutine ascii_draw_arrowhead(this, x, y, dx, dy, size, style)

    ASCII has no separate head-only glyph; reuse draw_arrow.

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    real(kind=wp), intent(in) :: x
    real(kind=wp), intent(in) :: y
    real(kind=wp), intent(in) :: dx
    real(kind=wp), intent(in) :: dy
    real(kind=wp), intent(in) :: size
    character(len=*), intent(in) :: style

procedure, public :: draw_quiver_arrow => ascii_draw_quiver_arrow

  • private subroutine ascii_draw_quiver_arrow(this, x, y, u, v)

    Stamp a quiver arrow directly onto the canvas via the axis-policy layer path so it clips to the plot interior and never corrupts axis spines, tick marks, or tick/axis labels (issue #2071).

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    real(kind=wp), intent(in) :: x
    real(kind=wp), intent(in) :: y
    real(kind=wp), intent(in) :: u
    real(kind=wp), intent(in) :: v

procedure, public :: get_ascii_output => ascii_get_output_method

  • private function ascii_get_output_method(this) result(output)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(in) :: this

    Return Value character(len=:), allocatable

procedure, public :: set_text_charset => ascii_set_text_charset

  • private subroutine ascii_set_text_charset(this, charset)

    Select the text charset. 'braille' ensures a subpixel canvas sized to the character grid; 'unicode'/'auto'/'ascii' are stored for the render-time frame/marker translation (#2060). An already-allocated braille canvas of the right size is preserved so re-saving an already-rendered figure keeps its dots.

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    character(len=*), intent(in) :: charset

procedure, public :: set_text_color_mode => ascii_set_text_color_mode

New polymorphic methods to eliminate SELECT TYPE

  • private subroutine ascii_set_text_color_mode(this, mode)

    Store the ANSI color mode applied at output assembly. Unknown names normalize to 'never' so stray input never leaks escapes (#2062).

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    character(len=*), intent(in) :: mode

procedure, public :: get_width_scale => ascii_get_width_scale

  • private function ascii_get_width_scale(this) result(scale)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(in) :: this

    Return Value real(kind=wp)

procedure, public :: get_height_scale => ascii_get_height_scale

  • private function ascii_get_height_scale(this) result(scale)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(in) :: this

    Return Value real(kind=wp)

procedure, public :: fill_quad => ascii_fill_quad

  • private subroutine ascii_fill_quad(this, x_quad, y_quad)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    real(kind=wp), intent(in) :: x_quad(4)
    real(kind=wp), intent(in) :: y_quad(4)

procedure, public :: render_legend_specialized => ascii_render_legend_specialized

  • private subroutine ascii_render_legend_specialized(this, legend, legend_x, legend_y)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    type(legend_t), intent(in) :: legend
    real(kind=wp), intent(in) :: legend_x
    real(kind=wp), intent(in) :: legend_y

procedure, public :: calculate_legend_dimensions => ascii_calculate_legend_dimensions

  • private subroutine ascii_calculate_legend_dimensions(this, legend, legend_width, legend_height)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(in) :: this
    type(legend_t), intent(in) :: legend
    real(kind=wp), intent(out) :: legend_width
    real(kind=wp), intent(out) :: legend_height

procedure, public :: set_legend_border_width => ascii_set_legend_border_width

  • private subroutine ascii_set_legend_border_width(this)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this

procedure, public :: calculate_legend_position_backend => ascii_calculate_legend_position

  • private subroutine ascii_calculate_legend_position(this, legend, x, y)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(in) :: this
    type(legend_t), intent(in) :: legend
    real(kind=wp), intent(out) :: x
    real(kind=wp), intent(out) :: y

procedure, public :: extract_rgb_data => ascii_extract_rgb_data

  • private subroutine ascii_extract_rgb_data(this, width, height, rgb_data)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(in) :: this
    integer, intent(in) :: width
    integer, intent(in) :: height
    real(kind=wp), intent(out) :: rgb_data(width,height,3)

procedure, public :: get_png_data_backend => ascii_get_png_data

  • private subroutine ascii_get_png_data(this, width, height, png_data, status)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(in) :: this
    integer, intent(in) :: width
    integer, intent(in) :: height
    integer(kind=1), intent(out), allocatable :: png_data(:)
    integer, intent(out) :: status

procedure, public :: prepare_3d_data => ascii_prepare_3d_data

  • private subroutine ascii_prepare_3d_data(this, plots)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    type(plot_data_t), intent(in) :: plots(:)

procedure, public :: render_ylabel => ascii_render_ylabel

  • private subroutine ascii_render_ylabel(this, ylabel)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    character(len=*), intent(in) :: ylabel

procedure, public :: draw_axes_and_labels_backend => ascii_draw_axes_and_labels

  • private subroutine ascii_draw_axes_and_labels(this, xscale, yscale, symlog_threshold, x_min, x_max, y_min, y_max, title, xlabel, ylabel, x_date_format, y_date_format, z_min, z_max, has_3d_plots)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    character(len=*), intent(in) :: xscale
    character(len=*), intent(in) :: yscale
    real(kind=wp), intent(in) :: symlog_threshold
    real(kind=wp), intent(in) :: x_min
    real(kind=wp), intent(in) :: x_max
    real(kind=wp), intent(in) :: y_min
    real(kind=wp), intent(in) :: y_max
    character(len=:), intent(in), optional, allocatable :: title
    character(len=:), intent(in), optional, allocatable :: xlabel
    character(len=:), intent(in), optional, allocatable :: ylabel
    character(len=*), intent(in), optional :: x_date_format
    character(len=*), intent(in), optional :: y_date_format
    real(kind=wp), intent(in), optional :: z_min
    real(kind=wp), intent(in), optional :: z_max
    logical, intent(in) :: has_3d_plots

procedure, public :: save_coordinates => ascii_save_coordinates

  • private subroutine ascii_save_coordinates(this, x_min, x_max, y_min, y_max)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(in) :: this
    real(kind=wp), intent(out) :: x_min
    real(kind=wp), intent(out) :: x_max
    real(kind=wp), intent(out) :: y_min
    real(kind=wp), intent(out) :: y_max

procedure, public :: set_coordinates => ascii_set_coordinates

  • private subroutine ascii_set_coordinates(this, x_min, x_max, y_min, y_max)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    real(kind=wp), intent(in) :: x_min
    real(kind=wp), intent(in) :: x_max
    real(kind=wp), intent(in) :: y_min
    real(kind=wp), intent(in) :: y_max

procedure, public :: render_axes => ascii_render_axes

  • private subroutine ascii_render_axes(this, title_text, xlabel_text, ylabel_text)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    character(len=*), intent(in), optional :: title_text
    character(len=*), intent(in), optional :: xlabel_text
    character(len=*), intent(in), optional :: ylabel_text

procedure, public :: clear_ascii_legend => ascii_clear_legend_lines

  • private subroutine ascii_clear_legend_lines(this, header)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    character(len=*), intent(in), optional :: header

procedure, public :: add_ascii_legend_entry => ascii_add_legend_entry

  • private subroutine ascii_add_legend_entry(this, label, value_text)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    character(len=*), intent(in) :: label
    character(len=*), intent(in), optional :: value_text

procedure, public :: clear_pie_legend_entries => ascii_clear_pie_legend_entries

  • private subroutine ascii_clear_pie_legend_entries(this)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this

procedure, public :: register_pie_legend_entry => ascii_register_pie_legend_entry

  • private subroutine ascii_register_pie_legend_entry(this, label, value_text)

    Arguments

    Type IntentOptional Attributes Name
    class(ascii_context), intent(inout) :: this
    character(len=*), intent(in) :: label
    character(len=*), intent(in) :: value_text