Skip to content

foresight_backend_dumb ​

foresight_backend_dumb, text output device (gnuplot dumb terminal).

The page is a grid of character cells, CELL_WIDTH x CELL_HEIGHT font sizes each, so the layout engine works unchanged in its virtual pixels. Series are drawn with gnuplot's dumb symbols, one per color in order of use, the frame with +, - and |, the grid with .; superscripts become ^. Data segments are clipped to the plot area before rasterisation: points far outside the range never cost more than the cells actually drawn.

With colors other than mono (gnuplot ansi, ansi256, ansirgb) the cells of each series take its color through ANSI escape sequences, the nearest of the 6 basic colors, of the 256-color palette, or the color itself; frame, grid, text, and black, white or named series colors keep the terminal's own color.

Data are drawn through px_segment and px_point, in pixels: a device drawing at a finer resolution than the cells (foresight_backend_block) overrides them, cell, clear, rect and polyline, and keeps the rest.

Readouts are seven-segment digits in characters, 3 rows of 4 columns per cell (_, |_|, |_|, the decimal point a . in the fourth column); the unlit segments are not drawn, text has no faint intensity. A filled rectangle (the readout window) clears the cells it covers.

Filled polygons (boxes, filledcurves) fill the cells whose centre lies inside with the symbol of the fill color (gnuplot's dumb uses #, which is also a series symbol here: a fill would hide the second curve), whatever the opacity, then draw the border with the color symbol; in the plot area they are clipped to it first (Sutherland-Hodgman). Fills go through px_fill, which a finer device overrides.

Images (with image, color boxes) are drawn a character per cell, the cell taking the pixel at its centre: a character of density growing with the pixel luminance ( .:-=+*#%@), in its color with ansi; transparent pixels (undefined values) are left blank.

Source: src/lib/foresight_backend_dumb.F90

Dependencies

Contents ​

Variables ​

NameTypeAttributesDescription
SYMBOLScharacter(len=*)parameterSeries symbols, cycled.
FRAME_COLORcharacter(len=*)parameterFrame color, drawn as ticks.
GRID_COLORcharacter(len=*)parameterGrid color, drawn as dots on blank cells.
PATTERN_SYMBOLScharacter(len=*)parameterCell symbols of the fill patterns 1 to 7.
CELL_WIDTHreal(kind=R8P)parameterCell width [font size].
CELL_HEIGHTreal(kind=R8P)parameterCell height [font size].
TEXT_COLORScharacter(len=*)parameterColor modes (gnuplot names).
ESCcharacter(len=1)parameterEscape character.

Derived Types ​

color_symbol ​

Symbol assigned to a color.

Components ​

NameTypeAttributesDescription
colorcharacter(len=:)allocatableSVG color.
symbolcharacter(len=1)Cell symbol.

backend_dumb ​

Text output device.

Inheritance

Extends: backend_object

Components ​

NameTypeAttributesDescription
themetype(theme_object)Output theme: colors the layout's ones are mapped to (foresight_theme).
clear_screenlogicalClear the terminal before writing to standard output.
filecharacter(len=:)allocatableOutput file, - for standard output.
gridcharacter(len=1)allocatableCells, (column, row).
symbolstype(color_symbol)allocatableSymbols in use.
tintinteger(kind=I4P)allocatableCell color, index in symbols, 0 for the default.
colorscharacter(len=7)Color mode: mono, ansi, ansi256, ansirgb.
cwreal(kind=R8P)Cell width [px].
chreal(kind=R8P)Cell height [px].
font_sizereal(kind=R8P)Font size [px].
areareal(kind=R8P)Plot area: left, top, width, height [px].
hiddenlogicalInside a hidden group: nothing is drawn.

Type-Bound Procedures ​

NameAttributesDescription
begin_pagepass(self)
end_pagepass(self)
begin_axespass(self)
end_axespass(self)
begin_grouppass(self)
end_grouppass(self)
rectpass(self)
polylinepass(self)
dotspass(self)
polygonpass(self)
imagepass(self)
textpass(self)
begin_plot_areapass(self)
end_plot_areapass(self)
data_polylinepass(self)
data_dotspass(self)
data_barspass(self)
data_polygonpass(self)
data_imagepass(self)
text_widthpass(self)
readoutpass(self)
readout_extentpass(self)
data_arrowspass(self)
data_labelpass(self)
cellpass(self)Text of a cell.
clearpass(self)Blank a box.
colpass(self)Column of an abscissa [px].
color_indexpass(self)Index of a color in symbols.
px_fillpass(self)Fill a polygon [px].
px_pointpass(self)Draw a data point [px].
px_segmentpass(self)Draw a data segment [px].
rowpass(self)Row of an ordinate [px].
putpass(self)Set a cell.
segmentpass(self)Rasterise a cell segment.
symbol_ofpass(self)Symbol of a color.
unit_segmentpass(self)Clip and draw a unit-square segment.

Subroutines ​

begin_page ​

Start a blank page of width x height px.

fortran
subroutine begin_page(self, file, width, height, font_size)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
filecharacter(len=*)inOutput file, - for standard output.
widthreal(kind=R8P)inPage width [px].
heightreal(kind=R8P)inPage height [px].
font_sizereal(kind=R8P)inFont size [px].

Call graph

end_page ​

Write the page, rows right-trimmed: to standard output, or atomically to the file.

fortran
subroutine end_page(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.

Call graph

begin_axes ​

No panel metadata in text.

fortran
subroutine begin_axes(self, view)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
viewtype(axes_view)inPanel geometry and axis ranges.

Call graph

end_axes ​

No panel metadata in text.

fortran
subroutine end_axes(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.

Call graph

begin_group ​

A hidden group (the grid when off) is not drawn at all.

fortran
subroutine begin_group(self, name, visible, series)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
namecharacter(len=*)inGroup name.
visiblelogicalinoptionalGroup shown.
seriesinteger(kind=I4P)inoptionalSeries number, unused in text.

Call graph

end_group ​

Leave the group.

fortran
subroutine end_group(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.

Call graph

rect ​

Stroked rectangles are drawn with -, | and + corners; a fill blanks the cells covered.

fortran
subroutine rect(self, x, y, width, height, stroke, fill, line_width)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
xreal(kind=R8P)inLeft side [px].
yreal(kind=R8P)inTop side [px].
widthreal(kind=R8P)inWidth [px].
heightreal(kind=R8P)inHeight [px].
strokecharacter(len=*)inStroke color.
fillcharacter(len=*)inFill color.
line_widthreal(kind=R8P)inStroke width [px].

Call graph

polyline ​

Frame polylines (ticks) mark their start with +, grid lines dot blank cells, others use the color symbol.

fortran
subroutine polyline(self, x, y, color, line_width, dasharray)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
xreal(kind=R8P)inAbscissae [px].
yreal(kind=R8P)inOrdinates [px].
colorcharacter(len=*)inStroke color.
line_widthreal(kind=R8P)inStroke width [px].
dasharraycharacter(len=*)inSVG dash array.

Call graph

dots ​

Dots are the color symbol, whatever the point type.

fortran
subroutine dots(self, x, y, color, diameter, pt, line_width)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
xreal(kind=R8P)inAbscissae [px].
yreal(kind=R8P)inOrdinates [px].
colorcharacter(len=*)inFill color.
diameterreal(kind=R8P)inDot diameter [px].
ptinteger(kind=I4P)inoptionalPoint type, ignored.
line_widthreal(kind=R8P)inoptionalMarker line width, ignored.

Call graph

polygon ​

Closed polygon [px]: its inside filled (px_fill) unless fill is none, then its border with the symbol of stroke unless none; the opacity has no meaning in text, a ghost (unlit cell) is not drawn.

fortran
subroutine polygon(self, x, y, fill, opacity, stroke, line_width, ghost)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
xreal(kind=R8P)inVertex abscissae [px].
yreal(kind=R8P)inVertex ordinates [px].
fillcharacter(len=*)inFill color.
opacityreal(kind=R8P)inFill opacity, unused.
strokecharacter(len=*)inBorder color.
line_widthreal(kind=R8P)inBorder width, unused.
ghostlogicalinoptionalUnlit cell of a segmented fill.

Call graph

image ​

Raster image over the box of top-left (x0, y0) and bottom-right (x1, y1) corners [px]: a character per cell whose centre lies inside, the density of the pixel luminance, in the pixel color.

fortran
subroutine image(self, x0, y0, x1, y1, rgba)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
x0real(kind=R8P)inLeft [px].
y0real(kind=R8P)inTop [px].
x1real(kind=R8P)inRight [px].
y1real(kind=R8P)inBottom [px].
rgbainteger(kind=I4P)inPixels.

Call graph

text ​

Text in the row of its baseline; superscripts appended after ^; rotated text written top to bottom.

fortran
subroutine text(self, x, y, string, anchor, sup, rotate)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
xreal(kind=R8P)inAnchor abscissa [px].
yreal(kind=R8P)inAnchor ordinate (baseline) [px].
stringcharacter(len=*)inText.
anchorcharacter(len=*)inHorizontal anchor: start, middle or end.
supcharacter(len=*)inoptionalSuperscript appended to string.
rotatereal(kind=R8P)inoptionalRotation [deg].

Call graph

begin_plot_area ​

Remember the plot area, where unit-square coordinates map.

fortran
subroutine begin_plot_area(self, x, y, width, height)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
xreal(kind=R8P)inLeft side [px].
yreal(kind=R8P)inTop side [px].
widthreal(kind=R8P)inWidth [px].
heightreal(kind=R8P)inHeight [px].

Call graph

end_plot_area ​

Nothing to close in text.

fortran
subroutine end_plot_area(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.

Call graph

data_arrows ​

Arrows [unit square]: shafts clipped to the plot area with the color symbol, heads (at a tip inside the plot area) as two short segments, filled or not.

fortran
subroutine data_arrows(self, x1, y1, x2, y2, color, line_width, head, filled)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
x1real(kind=R8P)inTail abscissae [unit].
y1real(kind=R8P)inTail ordinates [unit].
x2real(kind=R8P)inTip abscissae [unit].
y2real(kind=R8P)inTip ordinates [unit].
colorcharacter(len=*)inStroke color.
line_widthreal(kind=R8P)inStroke width [px].
headinteger(kind=I4P)inHeads: 0 none, 1 end, 2 start, 3 both.
filledlogicalinFilled heads.

Call graph

data_label ​

Text at a data point [unit square] inside the plot area, moved by the offset; unrotated in text.

fortran
subroutine data_label(self, x, y, string, anchor, rotate, color, dx, dy)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
xreal(kind=R8P)inAnchor abscissa [unit].
yreal(kind=R8P)inAnchor ordinate [unit].
stringcharacter(len=*)inText.
anchorcharacter(len=*)inHorizontal anchor: start, middle or end.
rotatereal(kind=R8P)inRotation [deg, counterclockwise], ignored.
colorcharacter(len=*)inText color, ignored.
dxreal(kind=R8P)inHorizontal offset [px].
dyreal(kind=R8P)inVertical offset [px, downward].

Call graph

data_polyline ​

Polyline [unit square] drawn with the color symbol, clipped to the plot area; grid lines (the polar grid) with ., frame lines (the polar border, the r axis) with -, | or + by their slope, as gnuplot's dumb.

fortran
subroutine data_polyline(self, x, y, color, line_width, dasharray)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
xreal(kind=R8P)inAbscissae [unit].
yreal(kind=R8P)inOrdinates [unit].
colorcharacter(len=*)inStroke color.
line_widthreal(kind=R8P)inStroke width [px].
dasharraycharacter(len=*)inSVG dash array.

Call graph

data_dots ​

Dots [unit square] inside the plot area drawn with the color symbol, whatever the point type.

fortran
subroutine data_dots(self, x, y, color, diameter, pt, line_width)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
xreal(kind=R8P)inAbscissae [unit].
yreal(kind=R8P)inOrdinates [unit].
colorcharacter(len=*)inFill color.
diameterreal(kind=R8P)inDot diameter [px].
ptinteger(kind=I4P)inoptionalPoint type, ignored.
line_widthreal(kind=R8P)inoptionalMarker line width, ignored.

Call graph

data_bars ​

Error bars [unit square] as | (vertical) or - (horizontal) runs, clipped to the plot area; no caps.

fortran
subroutine data_bars(self, x1, y1, x2, y2, color, line_width, cap, vertical)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
x1real(kind=R8P)inBar start abscissae.
y1real(kind=R8P)inBar start ordinates.
x2real(kind=R8P)inBar end abscissae.
y2real(kind=R8P)inBar end ordinates.
colorcharacter(len=*)inStroke color.
line_widthreal(kind=R8P)inStroke width [px].
capreal(kind=R8P)inCap length [px].
verticallogicalinVertical bars.

Call graph

data_polygon ​

Closed polygon [unit square] clipped to the plot area, then drawn in it as polygon.

fortran
subroutine data_polygon(self, x, y, fill, opacity, stroke, line_width, ghost)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
xreal(kind=R8P)inVertex abscissae [unit].
yreal(kind=R8P)inVertex ordinates [unit].
fillcharacter(len=*)inFill color.
opacityreal(kind=R8P)inFill opacity.
strokecharacter(len=*)inBorder color.
line_widthreal(kind=R8P)inBorder width [px].
ghostlogicalinoptionalUnlit cell of a segmented fill.

Call graph

data_image ​

Raster image over the box of bottom-left (x0, y0) and top-right (x1, y1) corners [unit square], clipped to the plot area: the pixels of the visible part drawn as image.

fortran
subroutine data_image(self, x0, y0, x1, y1, rgba)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
x0real(kind=R8P)inLeft [unit].
y0real(kind=R8P)inBottom [unit].
x1real(kind=R8P)inRight [unit].
y1real(kind=R8P)inTop [unit].
rgbainteger(kind=I4P)inPixels.

Call graph

readout ​

Seven-segment readout of top-left corner (x, y) [px] in characters: the label row, then 3 rows of 4 columns per cell, lit segments in the series color, the whole glass written so that it covers what lies below; the digit height is not used, characters have one size.

fortran
subroutine readout(self, x, y, height, masks, label, prefix, suffix, color, font_size)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
xreal(kind=R8P)inLeft side [px].
yreal(kind=R8P)inTop side [px].
heightreal(kind=R8P)inDigit height [px], unused.
masksinteger(kind=I4P)inSegments of each cell.
labelcharacter(len=*)inLabel, empty for none.
prefixcharacter(len=*)inText before the glass.
suffixcharacter(len=*)inText after the glass.
colorcharacter(len=*)inColor of the lit segments.
font_sizereal(kind=R8P)inFont size [px], unused.

Call graph

clear ​

Blank the cells of the box of top-left corner (x, y) and size width x height [px].

fortran
subroutine clear(self, x, y, width, height)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
xreal(kind=R8P)inLeft side [px].
yreal(kind=R8P)inTop side [px].
widthreal(kind=R8P)inWidth [px].
heightreal(kind=R8P)inHeight [px].

Call graph

px_fill ​

Fill the cells whose centre lies inside the polygon (x, y) [px] with the symbol of color (even-odd rule).

fortran
subroutine px_fill(self, x, y, color)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
xreal(kind=R8P)inVertex abscissae [px].
yreal(kind=R8P)inVertex ordinates [px].
colorcharacter(len=*)inFill color.

Call graph

px_point ​

A data point at p [px]: the color symbol in its cell.

fortran
subroutine px_point(self, p, color)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
preal(kind=R8P)inPoint [px].
colorcharacter(len=*)inColor.

Call graph

px_segment ​

A data segment from a to b [px] with symbol, or the color symbol if empty.

fortran
subroutine px_segment(self, a, b, color, symbol)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
areal(kind=R8P)inStart [px].
breal(kind=R8P)inEnd [px].
colorcharacter(len=*)inColor.
symbolcharacter(len=*)inSymbol, empty for the color symbol.

Call graph

put ​

Set cell (c, r) and its color index tint (default 0), ignoring cells off the page.

Attributes: pure

fortran
subroutine put(self, c, r, symbol, tint)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
cinteger(kind=I4P)inColumn.
rinteger(kind=I4P)inRow.
symbolcharacter(len=1)inSymbol.
tintinteger(kind=I4P)inoptionalColor index in symbols.

Call graph

segment ​

Bresenham segment between cells, optionally writing blank cells only.

Attributes: pure

fortran
subroutine segment(self, c1, r1, c2, r2, symbol, blank_only, tint)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
c1integer(kind=I4P)inStart column.
r1integer(kind=I4P)inStart row.
c2integer(kind=I4P)inEnd column.
r2integer(kind=I4P)inEnd row.
symbolcharacter(len=1)inSymbol.
blank_onlylogicalinWrite blank cells only.
tintinteger(kind=I4P)inoptionalColor index in symbols.

Call graph

unit_segment ​

Clip the unit-square segment to [0, 1]^2 (Liang-Barsky), then draw it in the plot area.

fortran
subroutine unit_segment(self, u1, v1, u2, v2, color, symbol)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
u1real(kind=R8P)inStart abscissa [unit].
v1real(kind=R8P)inStart ordinate [unit].
u2real(kind=R8P)inEnd abscissa [unit].
v2real(kind=R8P)inEnd ordinate [unit].
colorcharacter(len=*)inColor.
symbolcharacter(len=*)inSymbol, empty for the color symbol.

Call graph

clip_unit ​

The polygon (x, y) clipped to the unit square (Sutherland-Hodgman, one side at a time).

Attributes: pure

fortran
subroutine clip_unit(x, y, cx, cy)

Arguments

NameTypeIntentAttributesDescription
xreal(kind=R8P)inVertex abscissae.
yreal(kind=R8P)inVertex ordinates.
cxreal(kind=R8P)outallocatableClipped abscissae.
cyreal(kind=R8P)outallocatableClipped ordinates.

Call graph

Functions ​

text_width ​

Width of string in cells [px]: superscripts take full cells after a ^.

Attributes: pure

Returns: real(kind=R8P)

fortran
function text_width(self, string, sup, font_size) result(width)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inDevice.
stringcharacter(len=*)inText.
supcharacter(len=*)inSuperscript.
font_sizereal(kind=R8P)inFont size [px].

Call graph

readout_extent ​

Width and height [px] of a readout in characters: 4 columns per cell and the unit text, 3 rows and the label.

Attributes: pure

Returns: real(kind=R8P)

fortran
function readout_extent(self, height, cells, label, prefix, suffix, font_size) result(extent)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inDevice.
heightreal(kind=R8P)inDigit height [px], unused.
cellsinteger(kind=I4P)inGlass cells.
labelcharacter(len=*)inLabel, empty for none.
prefixcharacter(len=*)inText before the glass.
suffixcharacter(len=*)inText after the glass.
font_sizereal(kind=R8P)inFont size [px].

Call graph

cell ​

Text of the cell (c, r): its character.

Attributes: pure

Returns: character(len=:)

fortran
function cell(self, c, r) result(text)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inDevice.
cinteger(kind=I4P)inColumn.
rinteger(kind=I4P)inRow.

Call graph

col ​

Column of the cell containing the abscissa x [px], clamped to the page.

Attributes: elemental

Returns: integer(kind=I4P)

fortran
function col(self, x) result(c)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inDevice.
xreal(kind=R8P)inAbscissa [px].

Call graph

row ​

Row of the cell containing the ordinate y [px], clamped to the page.

Attributes: elemental

Returns: integer(kind=I4P)

fortran
function row(self, y) result(r)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inDevice.
yreal(kind=R8P)inOrdinate [px].

Call graph

color_index ​

Index of color in symbols, assigning the next symbol on first use.

Returns: integer(kind=I4P)

fortran
function color_index(self, color) result(k)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
colorcharacter(len=*)inSVG color.

Call graph

symbol_of ​

Symbol of color, assigning the next one on first use.

Returns: character(len=1)

fortran
function symbol_of(self, color) result(symbol)

Arguments

NameTypeIntentAttributesDescription
selfclass(backend_dumb)inoutDevice.
colorcharacter(len=*)inSVG color.

Call graph

scanline ​

Sorted abscissae where the horizontal line yc crosses the edges of the closed polygon (x, y): pairs bound its inside (even-odd rule). An edge counts its lower end and not its upper one, so a vertex on the line counts once.

Attributes: pure

Returns: real(kind=R8P)

fortran
function scanline(x, y, yc) result(xs)

Arguments

NameTypeIntentAttributesDescription
xreal(kind=R8P)inVertex abscissae.
yreal(kind=R8P)inVertex ordinates.
ycreal(kind=R8P)inLine ordinate.

Call graph

color_rgb ​

Red, green, blue (0-255) of the color k of symbols in the theme; -1 for the terminal's own color: index 0, a color that is not #rrggbb, black or white (unreadable on one of the backgrounds).

Attributes: pure

Returns: integer(kind=I4P)

fortran
function color_rgb(symbols, k, theme) result(rgb)

Arguments

NameTypeIntentAttributesDescription
symbolstype(color_symbol)inSymbols in use.
kinteger(kind=I4P)inIndex, 0 for the default.
themetype(theme_object)inOutput theme.

Call graph

ansi_escape ​

ANSI escape sequence setting the foreground to rgb in the color mode, or to the default if rgb is -1: the nearest of the 6 basic colors (no black and white) for ansi, of the 6x6x6 cube and the gray ramp for ansi256, the color itself for ansirgb.

Attributes: pure

Returns: character(len=:)

fortran
function ansi_escape(mode, rgb) result(escape)

Arguments

NameTypeIntentAttributesDescription
modecharacter(len=*)inansi, ansi256 or ansirgb.
rgbinteger(kind=I4P)inColor, -1 for the default.

Call graph