Page 1 of 1

PostPosted: Sun Dec 10, 2000 1:12 pm
by Eric
hi,
im new to programming with pocketc and i wonder if it is possible or not to create some simple paint program?!
i tried with standard functions and then moved on to the faster ptoolbox lib, but it still paints no "line" when i move some faster...

my minimalistic code:

// Graph Test
library "PToolboxLib"

main () {
graph_on();
title("Graph Test");

while (event(0)!=1) {
SetPixel(penx(),peny());
}

text(50,2,"end");
wait();
}

where can i gain speed? or is it impossible with pocketc?


thanks,
Eric

PostPosted: Sun Dec 10, 2000 10:24 pm
by jstadolnik
This is actually not a speed problem. The palm OS checks for events at a fixed time interval. When the pen is moved quickly across the screen, some of the pen positions don't get sampled and thus do not get registered as events. So you'd get the same problem even with gcc or codewarrior!

However, there is a simple work around which is to draw lines between the pen events which do get recorded.

Here are two implementations, one uses the Pocket Toolbox, the other does not:

<pre id=code><font face=courier size=2 id=code><font color=blue>//sketch1.c
main() {
int x, y, x_old, y_old, e;
graph_on();

while((e=event(1)) != 1) {
x=penx();
y=peny();
if(e==2) {
x_old=x;
y_old=y;
}
line(1,x,y,x_old,y_old);
x_old=x;
y_old=y;
}
}


//sketch2.c
library "PToolboxLib"
main() {
int e, mode;
graph_on();

while((e=event(1)) != 1) {
if(e==2) mode=0;
else mode=1;

plot(mode,penx(),peny(),0,0);
}
}</font id=blue></font id=code></pre id=code>

Joe Stadolnik


Edited by - jstadolnik on 12/10/2000 16:39:39