Looking for a XPCE tutorial [closed]
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
开发者_如何学CImprove this questionI'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
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.
精彩评论