Prolog "vector"

Admin User, erstellt 16. Apr. 2024
         
/**
* Modern Albufeira Prolog Interpreter
*
* Warranty & Liability
* To the extent permitted by applicable law and unless explicitly
* otherwise agreed upon, XLOG Technologies AG makes no warranties
* regarding the provided information. XLOG Technologies AG assumes
* no liability that any problems might be solved with the information
* provided by XLOG Technologies AG.
*
* Rights & License
* All industrial property rights regarding the information - copyright
* and patent rights in particular - are the sole property of XLOG
* Technologies AG. If the company was not the originator of some
* excerpts, XLOG Technologies AG has at least obtained the right to
* reproduce, change and translate the information.
*
* Reproduction is restricted to the whole unaltered document. Reproduction
* of the information is only allowed for non-commercial uses. Selling,
* giving away or letting of the execution of the library is prohibited.
* The library can be distributed as part of your applications and libraries
* for execution provided this comment remains unchanged.
*
* Restrictions
* Only to be distributed with programs that add significant and primary
* functionality to the library. Not to be distributed with additional
* software intended to replace any components of the library.
*
* Trademarks
* Jekejeke is a registered trademark of XLOG Technologies AG.
*/
:-(ensure_loaded(library(/(misc, markup)))).
:-(svg_begin(L), ','(current_output(S), svg_begin(S, L))).
:-(svg_begin(S, L), ','(sys_svg_opts(L, -(100, 100), -(W, H)), ','(is(SW, /(*(W, 500), 100)), ','(is(SH, /(*(H, 400), 100)), ','(is(DW, /(SW, 12)), ','(is(DH, /(SH, 12)), tag_format(S, '<svg style=\"width: ~gem; height: ~gem\" viewBox=\"0 0 ~g ~g\">', '.'(DW, '.'(DH, '.'(SW, '.'(SH, []))))))))))).
:-(svg_rect(X, Y, W, H, C), ','(current_output(S), svg_rect(S, X, Y, W, H, C))).
:-(svg_rect(S, X, Y, W, H, C), tag_format(S, '<rect x=\"~g\" y=\"~g\" width=\"~g\" height=\"~g\" class=\"~a\"/>', '.'(X, '.'(Y, '.'(W, '.'(H, '.'(C, []))))))).
:-(svg_line(X1, Y1, X2, Y2, C), ','(current_output(S), svg_line(S, X1, Y1, X2, Y2, C))).
:-(svg_line(S, X1, Y1, X2, Y2, C), tag_format(S, '<line x1=\"~g\" y1=\"~g\" x2=\"~g\" y2=\"~g\" class=\"~a\"/>', '.'(X1, '.'(Y1, '.'(X2, '.'(Y2, '.'(C, []))))))).
:-(svg_text(X, Y, T, C), ','(current_output(S), svg_text(S, X, Y, T, C))).
:-(svg_text(S, X, Y, T, C), ','(tag_format(S, '<text x=\"~g\" y=\"~g\" class=\"~a\">', '.'(X, '.'(Y, '.'(C, [])))), ','(write(S, T), tag(S, '</text>')))).
:-(svg_circle(X, Y, R, C), ','(current_output(S), svg_circle(S, X, Y, R, C))).
:-(svg_circle(S, X, Y, R, C), tag_format(S, '<circle cx=\"~g\" cy=\"~g\" r=\"~g\" class=\"~a\"/>', '.'(X, '.'(Y, '.'(R, '.'(C, [])))))).
:-(svg_path(L, C), ','(current_output(S), svg_path(S, L, C))).
:-(svg_path(S, L, C), ','(sys_shape_list(L, R), ','(atom_split(D, ' ', R), tag_format(S, '<path d=\"~a\" class=\"~a\"/>', '.'(D, '.'(C, [])))))).
:-(sys_shape_list('.'(X, L), '.'(Y, R)), ','(sys_shape(X, Y), sys_shape_list(L, R))).
sys_shape_list([], []).
:-(sys_shape(X, Y), ','(number(X), ','(!, format_atom('~g', '.'(X, []), Y)))).
:-(sys_shape(X, Y), format_atom('~w', '.'(X, []), Y)).
:-(svg_image(X, Y, W, H, U), ','(current_output(S), svg_image(S, X, Y, W, H, U))).
:-(svg_image(S, X, Y, W, H, U), tag_format(S, '<image x=\"~g\" y=\"~g\" width=\"~g\" height=\"~g\" href=\"~a\" preserveAspectRatio=\"none\" pointer-events=\"none\"/>', '.'(X, '.'(Y, '.'(W, '.'(H, '.'(U, []))))))).
:-(svg_end, ','(current_output(S), svg_end(S))).
:-(svg_end(S), tag(S, '</svg>')).
:-(sys_svg_opts(V, _, _), ','(var(V), throw(error(instantiation_error, _)))).
:-(sys_svg_opts('.'(X, L), I, O), ','(!, ','(sys_svg_opt(X, I, H), sys_svg_opts(L, H, O)))).
:-(sys_svg_opts([], H, H), !).
:-(sys_svg_opts(L, _, _), throw(error(type_error(list, L), _))).
:-(sys_svg_opt(V, _, _), ','(var(V), throw(error(instantiation_error, _)))).
:-(sys_svg_opt(width(W), -(_, H), -(W, H)), !).
:-(sys_svg_opt(height(H), -(W, _), -(W, H)), !).
:-(sys_svg_opt(O, _, _), throw(error(type_error(svg_option, O), _))).
:-(ensure_loaded(foreign(/(misc, portlib)))).