package archimedes

  1. Overview
  2. Docs

Area on which graphs can be made.

Sampling functions

type t

Viewport handle.

type coord_name_rstrct = [
  1. | `Device
  2. | `Graph
  3. | `Orthonormal
]
type coord_name = [
  1. | coord_name_rstrct
  2. | `Data
]
val get_coord_from_name : t -> coord_name -> Coordinate.t

get_coord_from_name viewport coord_name returns one of the coordinate systems of the viewport

Create new viewports

val make : t -> ?lines:float -> ?text:float -> ?marks:float -> ?redim:(t -> float -> float -> unit) -> ?coord:[ `Device | `Graph | `Orthonormal ] -> float -> float -> float -> float -> t

make parent xmin xmax ymin ymax creates and returns a viewport on top of parent with top left corner (xmin, ymin) and bottom right corner (xmax, ymax).

  • parameter lines

    see init

  • parameter text

    see init

  • parameter marks

    see init

  • parameter coord

    the coordinate system in which to interpret xmin, xmax, ymin, and ymax. Default: `Device.

  • parameter redim

    the function to execute when the viewport is redimensioned. Default: do nothing.

val show : t -> unit

show vp forces the viewport vp and all its children to immediately display not yet processed instructions.

val redraw : t -> unit

show vp forces the viewport vp and all its children to immediately redraw all their current content.

val get_backend : t -> Backend.t

get_backend vp returns the backend associated to vp, if vp is built over another viewport, the same backend is used.

val desync_ratio : t -> unit

desync_ratio vp make vp single. The ratio used will be the one used before desync.

val sync_ratio : t -> t -> unit

sync_ratio vp vp_base synchronizes vp's ratio with the vp_base's one.

val desync_range : ?x:bool -> ?y:bool -> t -> unit

desync_range vp make vp single. The range used will be the one used before desync.

  • parameter x

    desync the x axis (default: true)

  • parameter y

    desync the y axis (default: true)

val sync_range : ?x:bool -> ?y:bool -> t -> t -> unit

sync_range vp vp_base synchronizes vp's ranges (according to ?x and ?y params) with the ranges of vp_base. The range consists of a xmin and a xmax values, which defines the bounds of the viewport in Coordinate data.

  • parameter x

    sync the x axis (default: false, but true if neither x nor y are set)

  • parameter y

    sync the y axis (default: false, but true if neither x nor y are set)

val desync_unit_size : ?x:bool -> ?y:bool -> t -> unit

desync_unit_size vp make vp single. The unit size used will be the one used before desync.

  • parameter x

    desync the x axis (default: true)

  • parameter y

    desync the y axis (default: true)

val sync_unit_size : ?x:bool -> ?y:bool -> t -> t -> unit

sync_unit_size vp vp_base synchronizes vp's unit sizes (according to ?x and ?y params) with the sizes of vp_base.

  • parameter x

    sync the x axis (default: true)

  • parameter y

    sync the y axis (default: true)

val sync : ?x:bool -> ?y:bool -> t -> t -> unit
val grid : ?syncs:(bool * bool * bool * bool) -> t -> int -> int -> t array array

grid parent nx ny returns vp an array of nx * ny sub-viewports of parent arranged in a grid of nx columns and ny rows. The bottom left viewport is vp.(0).(0), the one to its right (resp. above) is vp.(1).(0) (resp. vp.(0).(1)).

  • parameter syncs

    (cx, cy, rx, ry) where cx (resp. cy) says whether to synchronize the X-axis (resp. the Y-axis) along the columns and rx (resp. ry) says whether to synchronize the X-axis (resp. the Y-axis) along the rows. Default: all false.

val rows : ?syncs:(bool * bool) -> t -> int -> t array

rows parent ny returns vp an array of ny viewports arranged in a column, the bottom one being vp.(0).

  • parameter syncs

    the axes to synchronize (x, y). Default: both false.

val columns : ?syncs:(bool * bool) -> t -> int -> t array

columns parent nx creates n_cols viewports layouted in a row and returns them in an array of viewports

  • parameter syncs

    the axes to synchronize (x, y)

val layout_borders : ?north:float -> ?south:float -> ?west:float -> ?east:float -> t -> t * t * t * t * t

layout_borders parent returns a 5-uple of viewports. The viewports are north, south, west, east, center and are placed conformally to their names.

  • parameter north

    the size of the north's viewport; if zero (default), this viewport is unused (the north viewport will be the same as the center one)

  • parameter south

    the size of the south's viewport; same behaviour as north if zero

  • parameter west

    the size of the west's viewport; same behaviour as north if zero

  • parameter east

    the size of the east's viewport; same behaviour as north if zero

val data_from : t -> coord_name -> (float * float) -> float * float
val ortho_from : t -> coord_name -> (float * float) -> float * float
val ortho_to : t -> coord_name -> (float * float) -> float * float
val set_line_width : t -> float -> unit

set_line_width vp w set the absolute width of the lines on the viewport vp to w. Default is 1.

val set_font_size : t -> float -> unit

set_font_size vp s set the absolute font size of the viewport vp to s. Default is 12.

val set_mark_size : t -> float -> unit

set_mark_size vp s set the absolute mark size of the viewport vp to s . Default is 7

val set_rel_line_width : t -> float -> unit

set_rel_line_width vp w. Same as set_line_width but relative to the viewport.

val set_rel_font_size : t -> float -> unit

set_rel_font_size vp s. Same as set_font_size but relative to the viewport

val set_rel_mark_size : t -> float -> unit

set_rel_mark_size vp s Same as set_mark_size but relative to the viewport

val get_color : t -> Color.t

get_color vp return the current tracing color of the viewport vp

val get_background_color : t -> Color.t

get_background_color vp return the current background color of the viewport vp

val get_line_width : t -> float

get_line_width vp return the current width of the lines on the viewport vp

val get_font_size : t -> float

get_font_size vp return the current size of the font on the viewport vp

val get_mark_size : ?coord:coord_name_rstrct -> t -> float * float

get_mark_size vp return (sx, sy) the current size in x and y of the marks on the viewport vp.

  • parameter coord

    coordinates in which to express the size. Note that for Orthonormal coordinates, sx = sy. If undefined, gives the absolute mark size as to be given to set_mark_size (in that case sx = sy too).

val lower_left_corner : t -> float * float

The device's coordinates of the viewport's lower left corner

val upper_right_corner : t -> float * float

The device's coordinates of the viewport's upper right corner

val dimensions : t -> float * float

The device's width and height of the viewport

val set_color : t -> Color.t -> unit

set_color vp c change the color of the elements in the viewport vp to the color c

val set_global_line_cap : t -> Backend.line_cap -> unit
val set_global_dash : t -> float -> float array -> unit
val set_global_line_join : t -> Backend.line_join -> unit
val get_line_cap : t -> Backend.line_cap
val get_dash : t -> float array * float
val get_line_join : t -> Backend.line_join
val stroke : ?fit:bool -> t -> coord_name -> Path.t -> unit

stroke vp coord p draw the path p on the the viewport vp in the coordinate system coord. p is unchanged.

  • parameter fit

    if true (the default), adjust the ranges so that the path is visible in its entirety.

val fill : ?fit:bool -> t -> coord_name -> Path.t -> unit

fill vp coord p fill the region delimited by the path p on the the viewport vp in the coordinate system coord. p is unchanged.

  • parameter fit

    if true (the default), adjust the ranges so that the path is visible in its entirety.

val set_clip : t -> bool -> unit

set_clip vp c whether to enable or disable clipping for every following instructions on vp.

val clip_rectangle : t -> x:float -> y:float -> w:float -> h:float -> unit

set_clip vp c whether to enable or disable clipping for every following instructions on vp.

val select_font_face : t -> Backend.slant -> Backend.weight -> string -> unit
val text_extents : t -> ?coord:coord_name_rstrct -> ?rotate:float -> ?pos:Backend.text_position -> string -> Matrix.rectangle

text_extents vp text returns the extents of text as displayed by Archimedes.Viewport.text.

  • parameter coord

    the coordinate system in which the extents will be given. Beware that as soon a coordinate system changes, the extents are obsolete.

val text : t -> ?coord:coord_name -> ?rotate:float -> ?pos:Backend.text_position -> float -> float -> string -> unit

text vp x y s display the string s at position (x, y). The text displayed in an orthonormal space, that means that it won't be stretched by the coordinate system coord.

  • parameter coord

    the coordinate system in which the position (x,y) has to be understood. Default: Data.

  • parameter rotate

    the angle (in radian) that the text must be rotated. Default: 0..

  • parameter pos

    the position of the text s w.r.t. the position (x,y). Default: centering both horizontally and vertically.

val mark : ?coord:coord_name -> t -> x:float -> y:float -> string -> unit

mark vp x y m draw the mark given by m on the viewport vp at position (x,y) if both x and y are finite. Otherwise, does nothing.

  • parameter coord

    coordinate system in which to draw the mark.

val axes_ratio : t -> float -> unit

axes_ratio vp ratio forces axes to keep ratio (w / h).

val xrange : t -> float -> float -> unit

axes_ratio vp ratio forces axes to keep ratio (w / h).

xrange vp xmin xmax set the OX interval of the viewport vp from xmin to xmax

val yrange : t -> float -> float -> unit

xrange vp xmin xmax set the OX interval of the viewport vp from xmin to xmax

yrange vp ymin ymax set the OY interval of the viewport vp from xmin to xmax

val xlabel : t -> string -> unit

yrange vp ymin ymax set the OY interval of the viewport vp from xmin to xmax

xlabel vp label set the OX representation to label for the viewport vp

val ylabel : t -> string -> unit

xlabel vp label set the OX representation to label for the viewport vp

ylabel vp label set the OY representation to label for the viewport vp

val title : t -> string -> unit

ylabel vp label set the OY representation to label for the viewport vp

title vp t set the title t above the viewport vp

val xmin : t -> float

xmin vp return the xmin of the range on the viewport vp

val xmax : t -> float

xmin vp return the xmin of the range on the viewport vp

xmax vp return the xmax of the range on the viewport vp

val ymin : t -> float

xmax vp return the xmax of the range on the viewport vp

ymin vp return the ymin of the range on the viewport vp

val ymax : t -> float

ymin vp return the ymin of the range on the viewport vp

ymax vp return the ymax of the range on the viewport vp

val xlog : t -> bool

xlog vp return true if OX is in log scale on the viewport vp

val ylog : t -> bool

xlog vp return true if OX is in log scale on the viewport vp

ylog vp return true if OY is in log scale on the viewport vp

val set_xlog : t -> bool -> unit

ylog vp return true if OY is in log scale on the viewport vp

set_xlog vp true set a log scale on OX on the viewport vp

val set_ylog : t -> bool -> unit

set_xlog vp true set a log scale on OX on the viewport vp

set_ylog vp true set a log scale on OY on the viewport vp

val auto_fit : t -> float -> float -> float -> float -> unit

auto_fit vp x0 y0 x1 y1 ensures that the rectangle delimited by (x0, y0) and (x1, y1) is included into the axes' ranges

val fit : t -> Matrix.rectangle -> unit

fit vp r ensures that the rectangle r is included into the axes ranges.

val save : t -> unit
val restore : t -> unit

Internal functions

val set_line_width_direct : t -> float -> unit -> unit
val set_font_size_direct : t -> float -> unit -> unit
val set_mark_size_direct : t -> float -> unit -> unit
val set_rel_line_width_direct : t -> float -> unit -> unit
val set_rel_font_size_direct : t -> float -> unit -> unit
val set_rel_mark_size_direct : t -> float -> unit -> unit
val set_color_direct : t -> Color.t -> unit -> unit
val set_line_cap_direct : t -> Backend.line_cap -> unit -> unit
val set_dash_direct : t -> float -> float array -> unit -> unit
val set_line_join_direct : t -> Backend.line_join -> unit -> unit
val stroke_direct : t -> coord_name -> Path.t -> unit -> unit
val fill_direct : t -> coord_name -> Path.t -> unit -> unit
val clip_rectangle_direct : t -> x:float -> y:float -> w:float -> h:float -> unit -> unit
val select_font_face_direct : t -> Backend.slant -> Backend.weight -> string -> unit -> unit
val show_text_direct : t -> coord_name -> ?rotate:float -> x:float -> y:float -> Backend.text_position -> string -> unit -> unit
val mark_direct : ?coord:coord_name -> t -> x:float -> y:float -> string -> unit -> unit
val save_direct : t -> unit -> unit
val restore_direct : t -> unit -> unit
val add_instruction : t -> (unit -> unit) -> unit
val do_instructions : t -> unit
val remove_last_instruction : t -> unit
val clear_instructions : t -> unit
OCaml

Innovation. Community. Security.