This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/packages/python/examples/pyx.pl

50 lines
1.4 KiB
Perl
Raw Normal View History

2012-11-27 12:10:41 +00:00
:- use_module(library(python)).
:- initialization(main).
2012-11-27 13:50:18 +00:00
setup_dir :-
prolog_load_context(directory, Dir),
2012-12-01 14:28:25 +00:00
atom_concat(Dir,'pyx/',Base),
2012-11-27 13:50:18 +00:00
assert(base(Base)).
:- setup_dir.
2012-11-27 12:10:41 +00:00
main :-
2012-12-01 14:28:25 +00:00
python_import(pyx),
2012-11-27 12:10:41 +00:00
ex(X),
flush_output,
fail.
main.
2012-12-01 14:28:25 +00:00
ex(hello) :-
c := canvas:canvas(_),
2012-11-27 13:50:18 +00:00
:= $c:text(0, 0, 'Hello, world!'),
:= $c:stroke(path:line(0, 0, 2, 0)),
:= $c:writePDFfile('hello').
2012-12-03 12:39:25 +00:00
ex(pathitem) :-
c := canvas:canvas(_),
rect1 := path:path(path:moveto(0, 0), path:lineto(1, 0),
path:moveto(1, 0), path:lineto(1, 1),
path:moveto(1, 1), path:lineto(0, 1),
path:moveto(0, 1), path:lineto(0, 0)),
rect2 := path:path(path:moveto(2, 0), path:lineto(3, 0),
path:lineto(3, 1), path:lineto(2, 1),
path:lineto(2, 0)),
rect3 := path:path(path:moveto(4, 0), path:lineto(5, 0),
path:lineto(5, 1), path:lineto(4, 1),
path:closepath(_)),
:= $c:stroke($rect1, [style:linewidth:'THICK']),
:= $c:stroke($rect2, [style:linewidth:'THICK']),
:= $c:stroke($rect3, [style:linewidth:'THICK']),
:= $c:writePDFfile('pathitem').
2012-11-27 13:50:18 +00:00
ex(changebar) :-
2012-12-01 14:28:25 +00:00
g := graph:graphxy(width=8, x=graph:axis:bar(_)),
base(Source), atomic_concat(Source, 'minimal.dat', Data),
:= $g:plot(graph:data:file(Data, xname=0, y=2), [graph:style:changebar(_)]),
2012-11-27 13:50:18 +00:00
:= $g:writePDFfile(changebar).
2012-11-27 12:10:41 +00:00