package qrc

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

QR 2D matrices.

The type for sequence of bits.

type t

The type for 2D square matrices of modules (binary pixels).

For a matrix of width w, the module at position (0,0) is the top-left corner, and (w-1,w-1) is the bottom-right corner. The quiet zone (surrounding frame of four zero modules) is not included. We store the bits in row-major order.

val zero : w:int -> t

zero ~w is a matrix of zeros of size w.

val of_bits : w:int -> bits -> t

of_bits ~w bits is a matrix from the sequence of bits bits interpreted in row-major order. Exceeding final bits are ignored.

val w : t -> int

w m is the matrix width.

val bits : t -> bits

bits m are the matrix's bits (modules) in row-major order. If there are more bits than (w m) * (w m), exceeding final bits should be ignored.

val copy : t -> t

copy m is a copy of m.

val get : t -> x:int -> y:int -> bool

get m ~x ~y is the (x,y) module of m.

val set : t -> x:int -> y:int -> unit

set m ~x ~y v sets the (x,y) module of m to true.

val clear : t -> x:int -> y:int -> unit

clear m ~x ~y sets the (x,y) module of m to false.

val fold : (int -> int -> bool -> 'a -> 'a) -> t -> 'a -> 'a

fold f m acc folds f over all the modules (x,y) of m as f x y (get m ~x ~y) acc' in row-major order and starting with acc.

val to_svg : ?w_mm:int -> ?invert:bool -> ?quiet_zone:bool -> t -> string

to_svg ~w_mm ~invert ~quiet_zone m is an SVG image for m in a coordinate system using one (slightly larger) unit black square per set module. The image, including the quiet zone, has a width and height of w_mm millimeters (defaults to 50). If invert is true (defaults to false) black modules are white and vice-versa. If quiet_zone is true (default) the surrounding frame of four zero modules is included.

OCaml

Innovation. Community. Security.