1

I'm going to write a simple animation in XPCE (four glasses puzzle to be precise). I know absolutely nothing about XPCE so I looked up a tutorial but the results are disappointing. Could anyone point me to some materials on the following:

  • working with a "canvas"
  • animation
  • timers

EDIT: Okay, here's a more detailed problem: I want to draw two boxes, wait two seconds, hide the boxes, then start a timer.

new(@box1, box(100,100)),
send(W, display, @box1),
new(@box2, box(100,100)),
send(W, display, @box2, point(200, 200)),

% wait two seconds here
% hide the boxes here

new(Msg1, and(message(B1, relative_move, point(5, 0)),
              message(B4, relative_move, point(0, 5)))),
send(W, attribute, attribute(timer, new(T, timer(0.1, Msg1)))),

send(T, start),

EDIT 2: Okay, here is another question (should I open a new question?): This is the code I'm using:

get_file(0, 'glass.gif').
get_file(180, 'glass180.gif').

main(GA, GB, GC, GD) :- % e.g. main(0,0,180,0).
    new(B1, figure),
    get_file(GA, G1),
    send(B1, display, new(BM1, bitmap(G1))),
    send(BM1, transparent, @on),
    send(W, display, B1, point(0,0)),     

%analogically for the other three glasses

I'd like to set a new bitmap for B1. How do I do that? Would altering BM1 be enough? Or perhaps there is an alternative solution? I've been thinking about drawing both upright and reversed glasses off-screen and swapping them, but I'm not sure about the details of such solution.

EDIT2': Solved it. For posterity:

send(B1, clear),
send(B1, display, bitmap('glass_while_animating_1.gif')),
send(timer(0.1), delay),
send(B1, clear),
send(B1, display, bitmap('glass_while_animating_2.gif')),
% etc
false
  • 10,264
  • 13
  • 101
  • 209
Igor
  • 2,673
  • 5
  • 33
  • 39
  • Would you explain a bit more about what working with a "canvas" means? Are you thinking about tools for developing image resources? Or is it the same as controlling a "window"? – hardmath Jan 20 '11 at 15:37
  • By canvas I mean an area where I can draw geometric shapes, draw images, &c. I did some testing and I'm working with a `window` now. I'm not sure if it's the correct structure but it works so far. My goal is just to move some glasses (taken from .gif or .png files), pause, put arrows over the ones I'm flipping, then repeat. – Igor Jan 20 '11 at 15:58
  • Did you take a look at the juggler and kangaroo animations from XPCE demos? – hardmath Jan 20 '11 at 16:19
  • I did and I got translations and drawing from them, but they're no help with my current problem (see edit). – Igor Jan 20 '11 at 17:34

1 Answers1

0

Would this searchable pdf be of help?

link text

"Chapter 5. Simple graphics" talks about a picture (ie. a canvas).

On page 260 there's an example of using a timer to introduce a delay, and page 266 shows using a timer for a blinking graphical.

On page 40 there's a mention of utilizing 'graphical->flush' to explicitly force redraw right now.

Roman
  • 1,179
  • 6
  • 7