File: externalimage.ml

package info (click to toggle)
mlpost 0.9-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,844 kB
  • sloc: ml: 21,094; javascript: 4,047; makefile: 430; ansic: 34; lisp: 19; sh: 15
file content (38 lines) | stat: -rw-r--r-- 940 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
open Mlpost

let debug = false

let filename = "powered-by-caml.png"

let height = Num.cm 2.

let width = Num.cm 1.

let square =
  let rect = Shapes.rectangle width height in
  Command.draw
    (Path.shift (Point.scale (Num.bp 0.5) (Point.pt (width, height))) rect)

let extim x = if debug then Command.nop else Command.externalimage filename x

let image1 = Command.seq [ square; extim (`Exact (height, width)) ]

let image2 = Command.seq [ square; extim (`Inside (height, width)) ]

let image3 = Command.seq [ square; extim (`Height height) ]

let image4 = Command.seq [ square; extim (`Width width) ]

let _ =
  List.iter
    (fun (id, name, fig) ->
      Metapost.emit (name ^ id) fig;
      Metapost.emit
        (name ^ "_ro" ^ id)
        (Command.draw_pic (Picture.rotate 128. (Picture.make fig))))
    [
      ("1", "image", image1);
      ("2", "image", image2);
      ("3", "image", image3);
      ("4", "image", image4);
    ]