File: dash.ml

package info (click to toggle)
ocaml-cairo2 0.6.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 716 kB
  • sloc: ml: 2,955; ansic: 2,132; makefile: 24; sh: 17
file content (24 lines) | stat: -rw-r--r-- 587 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(* Example by Øyvind Kolås taken from http://cairographics.org/samples/ *)

open Cairo

let () =
  let cr = Cairo.create(Cairo.PDF.create "dash.pdf" ~w:400. ~h:300.) in

  let dashes = [| 50.0;  (* ink *)
                  10.0;  (* skip *)
                  10.0;  (* ink *)
                  10.0   (* skip*)
               |] in
  let ofs = -50.0 in

  set_dash cr dashes ~ofs;
  set_line_width cr 10.0;

  move_to cr 128.0 25.6;
  line_to cr 230.4 230.4;
  rel_line_to cr (-102.4) 0.0;
  curve_to cr 51.2 230.4 51.2 128.0 128.0 128.0;
  stroke cr;

  Surface.finish(get_target cr)