diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2016-04-25 15:43:26 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2016-04-26 15:12:58 +0200 |
commit | a7c3d73078f9e0cfc12d7eee86d0e2de197768ab (patch) | |
tree | 3c3edc73cf4a49f4e1e8d31e7bc0cd388137314f /docs/mutool/examples/draw-device.js | |
parent | ccba5ca5548a394670f4e71d1df5be0efc66db69 (diff) | |
download | mupdf-a7c3d73078f9e0cfc12d7eee86d0e2de197768ab.tar.xz |
Add 'mutool run' documentation.
Diffstat (limited to 'docs/mutool/examples/draw-device.js')
-rw-r--r-- | docs/mutool/examples/draw-device.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/docs/mutool/examples/draw-device.js b/docs/mutool/examples/draw-device.js new file mode 100644 index 00000000..4912e956 --- /dev/null +++ b/docs/mutool/examples/draw-device.js @@ -0,0 +1,45 @@ +// Use device interface to draw some graphics and save as a PNG. + +var font = new Font("Times-Roman"); +var image = new Image("example.png"); +var path, text; + +var pixmap = new Pixmap(DeviceRGB, [0,0,500,600]); +pixmap.clear(255); +var device = new DrawDevice(pixmap); +var transform = [2,0,0,2,0,0] +{ + text = new Text(); + { + text.showString(font, [16,0,0,-16,100,30], "Hello, world!"); + text.showString(font, [0,16,16,0,15,100], "Hello, world!"); + } + device.fillText(text, transform, DeviceGray, [0], 1); + + path = new Path(); + { + path.moveTo(10, 10); + path.lineTo(90, 10); + path.lineTo(90, 90); + path.lineTo(10, 90); + path.closePath(); + } + device.fillPath(path, false, transform, DeviceRGB, [1,0,0], 1); + device.strokePath(path, {dashes:[5,10], lineWidth:3, lineCap:'Round'}, transform, DeviceRGB, [0,0,0], 1); + + path = new Path(); + { + path.moveTo(100,100); + path.curveTo(150,100, 200,150, 200,200); + path.curveTo(200,300, 0,300, 100,100); + path.closePath(); + } + device.clipPath(path, true, transform); + { + device.fillImage(image, Concat(transform, [300,0,0,300,0,0]), 1); + } + device.popClip(); +} +//device.flush(); + +pixmap.saveAsPNG("out.png"); |