Catalogue of Renderers (SWISH)

95 views
Skip to first unread message

Jan Burse

unread,
Mar 19, 2017, 8:29:42 PM3/19/17
to SWI-Prolog
Dear All,

I wonder whether this is the actual list of renderers:
  • General purpose renderers
    • table renders tables
    • svgtree renders Prolog terms as trees
    • graphviz render graphs using Graphviz.
    • c3 renders c3 dicts as charts (line, bar, pie etc.) using C3.js
    • codes renders lists of code-points as text.
  • Domain specific renderers
    • bdd renders CLP(B) residual goals as Binary Decision Diagrams (BDDs)
    • chess renders chess positions (currently only N-queen boards).
    • sudoku renders sudoku puzzles.
http://swish.swi-prolog.org/example/rendering.swinb

What I wonder is whether there are plans for renderers:
   - mathematical formulas
   - 2d drawings, static or interactive
   - 3d drawings, static or interactive

Why do I ask? Well I saw the followng:

      http://immersivemath.com/ila/index.html

And its all Java Scipt. (I guess MathJax and SamIllustration)

Jan Wielemaker

unread,
Mar 20, 2017, 8:38:33 AM3/20/17
to Jan Burse, SWI-Prolog
On 03/20/2017 01:29 AM, Jan Burse wrote:

> http://swish.swi-prolog.org/example/rendering.swinb
>
> What I wonder is whether there are plans for renderers:
> - mathematical formulas
> - 2d drawings, static or interactive
> - 3d drawings, static or interactive
>
> Why do I ask? Well I saw the followng:
>
> http://immersivemath.com/ila/index.html
>
> And its all Java Script. (I guess MathJax and SamIllustration)

The provided examples deal with pure HTML rendering, JavaScript
rendering and server-side rendering in two quite different setups
(one using an external process and the other using a Prolog
foreign extension). That should be enough to implement an
extension. Submit as a github pull request and if reasonable
it will become part of swish. `Reasonable', as usual, implies
there is a reasonable trade-off between new functionality and
added complexity and size of SWISH.

Note that `interactive' as in client-side manipulation of the
returned result is no problem. `Interactive' in the sense that
clicking on the result triggers further Prolog interaction to
refine or modify the query doesn't fit too well in the SWISH
architecture (but can be hacked to some extend).

Cheers --- Jan

Jan Burse

unread,
Mar 20, 2017, 9:40:44 AM3/20/17
to SWI-Prolog, burs...@gmail.com
For the 2D drawings there might be some overlap with the
functionality of C3, which is already provided.

But I guess there is more around than only SamIllustration
for 2D drawing, some use mathquill-embed-latex

https://github.com/mathquill

Douglas Miles

unread,
Mar 20, 2017, 10:33:02 AM3/20/17
to SWI-Prolog, burs...@gmail.com
On the subject of renderers here is a small one... but probably one of my favorites :)


:- if(exists_source(swish(lib/render))).

:- module(swish_render_html,
 
[ term_rendering//3 % +Term, +Vars, +Options
 
]).
/** <module> swish_render_html - SWISH html renderer

 Provides HTML Rendering in SWISH

*/

:- use_module(library(http/html_write)).
:- use_module(swish(lib/render)).

:- register_renderer(html, "Render html representations").


%% term_rendering(+Term, +Vars, +Options)//
%

term_rendering
(Term, _Vars, _Options) --> {compound(Term),Term=html(_)}, html(Term).

:- endif.

PR or what do you think?

Jan Wielemaker

unread,
Mar 20, 2017, 10:40:54 AM3/20/17
to Douglas Miles, SWI-Prolog, burs...@gmail.com
On 03/20/2017 03:33 PM, Douglas Miles wrote:
> On the subject of renderers here is a small one... but probably one of
> my favorites :)

I understand, but it is unsafe. Just return html(\format-my-harddrive) :(

We'd need to provide support for html//1 in the sandbox ... Not saying
that can't be done, but it is a little challenging.

Cheers --- Jan

>
>
> |
> :-if(exists_source(swish(lib/render))).
>
> :-module(swish_render_html,
> [term_rendering//3 % +Term, +Vars, +Options
> ]).
> /** <module> swish_render_html - SWISH html renderer
>
> Provides HTML Rendering in SWISH
>
> */
> :-use_module(library(http/html_write)).
> :-use_module(swish(lib/render)).
>
> :-register_renderer(html,"Render html representations").
>
>
> %%term_rendering(+Term,+Vars,+Options)//
> %
>
> term_rendering(Term,_Vars,_Options)-->{compound(Term),Term=html(_)},html(Term).
>
> :-endif.
> |
>
>
> PR or what do you think?
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "SWI-Prolog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to swi-prolog+...@googlegroups.com
> <mailto:swi-prolog+...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/swi-prolog.
> For more options, visit https://groups.google.com/d/optout.

Jan Burse

unread,
Mar 20, 2017, 11:08:36 AM3/20/17
to SWI-Prolog, burs...@gmail.com
Thats not extremely MVC, model-viewer-controller. What is the
interesting model? What is the interesting view?

For example SamIllustration has in one incarnation as a model
some 2D drawing, represented as point lists. And then its

possible to combine points into arrows etc..

// the SamIllustration3DObj
// - a class for doing simple 2D interactive illustrations
// - this class is designed around the concept of a list of 1D coordinates
// - 2D points can be formed from two of these 1D coordinates
// - and other objects (e.g., arrows) can be created from such 2D points
// - and some of the 2D points can be moved by the user

http://immersivemath.com/ila/javascript/samillustration3d.js

The interesting controller is then to move around 2D points
by the end user, solely realized as the client side Java Script

code I guess. So the quest is for something high level (from the
API viewpoint) for a particular problem domain.

Jan Burse

unread,
Mar 20, 2017, 11:12:59 AM3/20/17
to SWI-Prolog, burs...@gmail.com
Possibly it would be of advantage when tags such as:

 <script src="javascript/samillustration3d.js"></script>

Go into the header in advance before the canvas is generated.
Reply all
Reply to author
Forward
0 new messages