fortplot_line_styles Module

Line pattern and style rendering algorithms

This module contains line style pattern rendering and segment drawing algorithms following the Single Responsibility Principle.

SOLID: Single responsibility for line style implementation



Functions

public function get_pattern_length(pattern, pattern_size)

Calculate total length of pattern cycle Following KISS principle - simple sum calculation

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: pattern(20)
integer, intent(in) :: pattern_size

Return Value real(kind=wp)

public function should_draw_at_distance(distance, pattern, pattern_size, pattern_length)

Determine if line should be drawn at given distance in pattern Following SRP - handles only pattern position logic

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: distance
real(kind=wp), intent(in) :: pattern(20)
integer, intent(in) :: pattern_size
real(kind=wp), intent(in) :: pattern_length

Return Value logical


Subroutines

public subroutine get_line_pattern(linestyle, pattern, pattern_size)

Get line pattern array for a given style, in points. Single source of truth: the matplotlib default dash sequences. On/off lengths are in points; callers scale by line width (points) and convert to device units (see scale_pattern_to_pixels).

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: linestyle
real(kind=wp), intent(out) :: pattern(20)
integer, intent(out) :: pattern_size

public subroutine scale_pattern_to_pixels(pattern, pattern_size, dpi, line_width_pt)

Scale a point-based pattern in place to device pixels, matching matplotlib: multiply each on/off length (points) by the line width (points), then convert points to pixels via px = pt * dpi / 72. The solid sentinel is left untouched.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(inout) :: pattern(20)
integer, intent(in) :: pattern_size
real(kind=wp), intent(in) :: dpi
real(kind=wp), intent(in) :: line_width_pt

public subroutine advance_pattern_state(current_distance, segment_length, pattern_length, new_distance)

Advance pattern state for continuous rendering Following SRP - handles only state advancement

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: current_distance
real(kind=wp), intent(in) :: segment_length
real(kind=wp), intent(in) :: pattern_length
real(kind=wp), intent(out) :: new_distance