Debian Codegraph @

texmf-dist/doc/luatex/barracuda/test/test-libgeo/001-libgeo-test.tex

raw
1 % !TeX program = LuaTeX
2 % test for ga-canvas pdfliteral driver
3 %
4 % Copyright (C) 2019-2022 Roberto Giacomelli
5 % see LICENSE.txt file
6
7 \newbox\mybox
8 \directlua{
9 barracuda = require [[barracuda]]
10 pt = tex.sp [[1pt]] % 1pt = 65536sp
11 }
12
13 Test 1: test Archive class and Vbar arithmetic:
14
15 \medskip
16 \directlua{
17 % retrive the Vbar class
18 local libgeo = barracuda:libgeo()
19 local Vbar = libgeo.Vbar
20 % create three Vbar objects
21 local b1 = Vbar:from_int(22556, 2*pt)
22 local b2 = Vbar:from_int(3134563, 2*pt)
23 local b3 = Vbar:from_int(1111111, 2*pt)
24 % retrive the Archive class
25 local Archive = libgeo.Archive
26 % create a new instance of an archive and insert vbars
27 local archive = Archive:new()
28 assert(archive:insert(b1, 1))
29 assert(archive:insert(b2, 2))
30 assert(archive:insert(b3, 3))
31 % fill a queue (an array) two times
32 local queue = assert(archive:get(1)) + 20*pt
33 queue = queue + assert(archive:get(2)) + 20*pt
34 queue = queue + assert(archive:get(3)) + 20*pt
35 queue = queue + assert(archive:get(1)) + 20*pt
36 queue = queue + assert(archive:get(2)) + 20*pt
37 queue = queue + assert(archive:get(3))
38 % retrive a canvas instance
39 local ga = barracuda:new_canvas()
40 % draw the canvas with the driver component
41 assert(ga:encode_vbar_queue(queue, 0, 0, 30*pt))
42 local driver = barracuda:get_driver()
43 driver:ga_to_hbox(ga, [[mybox]])
44 }A\box\mybox A
45
46 \bye
47
48