next up previous index
Next: Using Pixmaps Up: Using Xlib Primitives Previous: Predefined Predicates

Drawing Text

The animation in our money example in section 5.2.4 did not run very fast. This may have been due to the speed of the finite domain solver or just due to the speed of the Tk display. We can find out which one was the culprit if we replace the digits display by Xlib. To do this, we have to make several changes:

The modifications are in the file moneyx.pl:

:- [money].

:- lib('tk/xlib').

draw_letter(Char, Row, Col) :-
    getval(xid, XID),
    X is 180 - 10*Col,
    Y is 74 + 15*(Row-1),
    xlib_image_string(XID, Char, X, Y).

init :-
    message("Start"),
    tcl 'tkwait visibility .c',
    xlib_init('.c', XID),
    xlib_font(XID, "-*fixed*bold-R-Normal-*-*-120-*"),
    setval(xid, XID),
    xlib_foreground(XID, black),
    xlib_background(XID, "#d9d9d9").

reset :-
    getval(xid, XID),
    xlib_clear_area(XID, 10, 10, 200, 130).

When we compile this file with Xlib modifications and run top/0, we can see that the money program runs much faster, we get a solution fast enough even with the plain list ordering. This means that for constraint programs that use the display intensively it might often be necessary to use Xlib.



next up previous index
Next: Using Pixmaps Up: Using Xlib Primitives Previous: Predefined Predicates



Micha Meier
Tue Jul 2 09:49:39 MET DST 1996