Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - Animator

Animator

A PocketC native palm library offering native forms and assorted utilities

Postby marita on Fri Mar 07, 2003 4:58 pm

I'm not sure that I'm posting this to the right forum but I know Joe's helped me with a similar problem before. I've been noodling with the Palm Programming for absolute beginners and it's great fun but I can't get the Animator to run properly. I do have the latest PocketToolbox and PocketC but I get an error message saying Addr: 13041 Stack ref out of range. I can post the script later if that's neccesary. Thanks a lot.

Aimee M Clay
marita
 
Posts: 21
Joined: Thu Aug 29, 2002 7:29 pm
Location: USA

Postby jstadolnik on Fri Mar 07, 2003 5:49 pm

I don't have this source code, so you'll have to post it for me to assist.

Joe

The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm
jstadolnik
 
Posts: 1741
Joined: Wed Dec 06, 2000 3:34 am
Location: USA

Postby marita on Fri Mar 07, 2003 10:52 pm

//Animator

//illustrates features of PToolbox

//Andy Harris, 5/25/01



library "PToolboxLib"

#include "Ccontrols.c"

#include "events.h"



//function protos

loadPic();

savePic();



//start with menus

Chandle mnbMain;

Chandle mnuFile, mnuEdit, mnuDraw;



//global variables

int oldx, oldy; //used in drawing commands

string mode = "free"; //what command is user requesting

int recNum = 0; //which record in the database is showing

int numRecs = 1; //how many records in the current database

int keepGoing = true; //main looping variable for program

int clipWidth, clipHeight; //used for clipboard functions

string fileName = "SSketch";//determines the name of the current database



countRecs(){

//get number of records (use 'traditional' db access)



if(dbopen(fileName)){;

numRecs = dbnrecs();

dbclose();

} else {

numRecs = 0;

} // end if

} // end countRecs



init(){



//grayscale mode. Set depth to 5 for color palms

SetDepth(4);

graph_on();

clearg();

title("animator: " + fileName + " - " + mode + " ");



//create clipboard buffer

SetDrawBuf(1); //clipboard buffer

SetDrawBuf(0); //move back to normal buffer



//set up menu bars

mnbMain = Cmenubar();



//file menu

mnuFile = Cmenu(5, 80, 40);

Csettopic(mnuFile, "File");

Cadditem(mnuFile, "new frame");

Cadditem(mnuFile, "clear");

Cadditem(mnuFile, "open");

Cadditem(mnuFile, "prev");

Cadditem(mnuFile, "next");

Cadditem(mnuFile, "save");

Cadditem(mnuFile, "view anim");

Cadditem(mnuFile, "exit");

Caddmenu(mnbMain, mnuFile);



//edit menu

mnuEdit = Cmenu(45, 80, 40);

Csettopic(mnuEdit, "Edit");

Cadditem(mnuEdit, "copy");

Cadditem(mnuEdit, "paste");

Cadditem(mnuEdit, "paste 90");

Cadditem(mnuEdit, "paste 180");

Cadditem(mnuEdit, "paste -90");

Cadditem(mnuEdit, "paste flip v");

Cadditem(mnuEdit, "paste flip h");

Cadditem(mnuEdit, "paste x2");

Cadditem(mnuEdit, "paste x4");

Caddmenu(mnbMain, mnuEdit);



//draw menu

mnuDraw = Cmenu(85, 80, 40);

Csettopic(mnuDraw, "Draw");

Cadditem(mnuDraw, "free");

Cadditem(mnuDraw, "oval");

Cadditem(mnuDraw, "rectangle");

Cadditem(mnuDraw, "color");

Cadditem(mnuDraw, "fill");

Cadditem(mnuDraw, "line");

Cadditem(mnuDraw, "poly");

Caddmenu(mnbMain, mnuDraw);



//set up default color and pattern

SetFore(3);

SetPattern("ffffffffffffffff"); //solid fill of foreground color

recNum = 0;

countRecs();

loadPic();

} // end init



savePic(){

//save the picture to the database

OpenBufDb(fileName, 1);

SaveBuf(recNum);

CloseBufDb();

} // end savePic



loadPic(){

//loads a picture from the database

OpenBufDb(fileName, 1);

RestoreBuf(recNum);

CloseBufDb();

} // end loadPic



movePrev(){

recNum--;

if (recNum < 0){

recNum = 0;

} // end if

loadPic();

} // end movePrev



moveNext(){

recNum++;

if (recNum >= numRecs){

recNum = numRecs - 1;

} // end if

loadPic();

} // end moveNext



drawPoly(){

//draws a polygon

//start at center, draw to edge

int a, b, sides, radius;

sides = gets("Number of sides?");

a = oldx - penx();

b = oldy - peny();

//good old pythagorean theorom to determine radius

radius = sqrt(pow(a,2) + pow(b,2));

polygon(oldx, oldy, sides, radius, 0);

} // end drawPoly



viewAnim(){

//view an animation of the file

//pen tap to exit animation

int evt;

int stayInLoop = true;

int lag = 50;



lag = getsd("lag between frames?\r(50 = 1/2 sec)", lag);

while(stayInLoop){

evt = event(lag);

recNum++;

if (recNum >= numRecs){

recNum = 0;

} // end if

loadPic();

if (evt == EVT_PEN_DN){

stayInLoop = false;

} // end

} // end loop

} // end viewAnim



copy(){

//copies a part of the screen to the clipboard



int x, y;

alert("click upper left, lower right of section to copy");

wait();

x = penx();

y = peny();

wait();

clipWidth = penx() - x;

clipHeight = peny() - y;



//copy the rectangle to buffer 1

CopyRect(0, 0, 0, x, y, clipWidth, clipHeight, 0, 1, -1);

} // end copy



paste(string pMode){

//returns clipboard image to screen

//pMode determines what type of paste will occur

int x, y;



alert("click upper left of where image is to go");

wait();

x = penx();

y = peny();

switch (pMode){

case "normal":

CopyRect(1, x, y, 0, 0, clipWidth, clipHeight, 0, 1, 0);

break;

case "r90":

CopyRect(1, x, y, 0, 0, clipWidth, clipHeight, 0, 1, 1);

break;

case "r180":

CopyRect(1, x, y, 0, 0, clipWidth, clipHeight, 0, 1, 2);

break;

case "r-90":

CopyRect(1, x, y, 0, 0, clipWidth, clipHeight, 0, 1, 3);

break;

case "flipH":

CopyRect(1, x, y, 0, 0, clipWidth, clipHeight, 0, 1, 4);

break;

case "flipV":

CopyRect(1, x, y, 0, 0, clipWidth, clipHeight, 0, 1, 5);

break;

case "x2":

CopyRect(1, x, y, 0, 0, clipWidth, clipHeight, 0, 2, 0);

break;

case "x4":

CopyRect(1, x, y, 0, 0, clipWidth, clipHeight, 0, 4, 0);

break;

} // end switch



} // end paste



checkMenus(string command){

switch (command){

//file commands

case "open":

fileName = gets("new file name?");

countRecs();



//load up the first record

recNum = 0;

loadPic();

break;

case "new frame":

recNum = numRecs;

numRecs++;

rect(0,0, 15, 159, 159, 0);

break;

case "clear":

rect(0,0, 15, 159, 159, 0);

break;

case "prev":

movePrev();

break;

case "next":

moveNext();

break;

case "save":

savePic();

break;

case "view anim":

viewAnim();

break;

case "exit":

keepGoing = false;

break;



//edit commands

case "copy":

copy();

break;

case "paste":

paste("normal");

break;

case "paste 90":

paste("r90");

break;

case "paste 180":

paste("r180");

break;

case "paste -90":

paste("r-90");

break;

case "paste flip v":

paste("flipV");

break;

case "paste flip h":

paste("flipH");

break;

case "paste x2":

paste("x2");

break;

case "paste x4":

paste("x4");

break;



//draw commands

case "free":

mode = "free";

break;

case "oval":

mode = "oval";

break;

case "rectangle":

mode = "rect";

break;

case "color":

SetFore(PickColor());

break;

case "fill":

mode = "fill";

break;

case "line":

mode = "line";

plot(0, penx(), peny(), 0, 0);

break;

case "poly":

mode = "poly";

break;

default:

//shouldn't ever happen. If it does, I probably mispelled a command name,

//so tell me what command is.

alert(command);

} // end switch



} // end checkMenus



main(){

int evt;

string command;



init();

hookhard(1); //intercept button presses



while (keepGoing){

evt = event(0);



//check button presses

if (evt == EVT_BTN_ADD){

movePrev();

} else if (evt == EVT_BTN_TODO){

moveNext();



//look for menu events

} else if(Cevent(mnbMain, evt)){

if(Cgetcursel(mnuFile)!= -1){

command = Cgetcontent(mnuFile);

} else if (Cgetcursel(mnuEdit) != -1){

command = Cgetcontent(mnuEdit);

} else if (Cgetcursel(mnuDraw) != -1){

command = Cgetcontent(mnuDraw);

} // end if

checkMenus(command);



//check for pen down event

} else if (evt == EVT_PEN_DN){

oldx = penx();

oldy = peny();

if (mode == "fill"){

FloodFill(0, penx(), peny());

} // end if



//check for pen move event

} else if (evt == EVT_PEN_MV){

switch(mode){

case "free":

rect(4, penx(), peny(), penx() + 2, peny() + 2, 0);

break;

} // end switch



//check for pen up event

} else if (evt == EVT_PEN_UP){

switch(mode){

case "free":

rect(4, penx(), peny(), penx() + 2, peny() + 2, 0);

break;

case "rect":

rect(4, oldx, oldy, penx(), peny(),0);

break;

case "oval":

ellipse(3, oldx, oldy, (penx() - oldx), (peny()-oldy));

break;

case "line":

plot(1, penx(), peny(), 0, 0);

break;

case "poly":

drawPoly();

break;

default:

//alert(mode);

} // end switch

title("animator: " + fileName + " - " + mode + " ");

} // end if

} // end while

} // end main



Aimee M Clay
marita
 
Posts: 21
Joined: Thu Aug 29, 2002 7:29 pm
Location: USA

Postby marita on Fri Mar 07, 2003 10:53 pm

It's pretty long. Thanks again for hemping me out.

Aimee M Clay
marita
 
Posts: 21
Joined: Thu Aug 29, 2002 7:29 pm
Location: USA

Postby jstadolnik on Fri Mar 07, 2003 11:49 pm

My guess would be the polygon() function call. It was removed from the library recently. The functionality still exist, just use the new Arc() function instead.

If you are using PDE, make sure that you are using a current PToolboxLib.lib file in your PDE directory.

Joe

The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm
jstadolnik
 
Posts: 1741
Joined: Wed Dec 06, 2000 3:34 am
Location: USA

Postby marita on Sat Mar 08, 2003 6:41 pm

Okie dokie, I reloaded the Animator as script and changed everywhere it said "polygon(" to "Arc(" now I'm getting undeclared identifier line 275 which is in the vicinty of this:

drawPoly(){
//draws a polygon
//start at center, draw to edge
int a, b, sides, radius;
sides = gets("Number of sides?");
a = oldx - penx();
b = oldy - peny();
//good old pythagorean theorom to determine radius
radius = sqrt(pow(a,2) + pow(b,2));
Arc(oldx, oldy, sides, radius, 0);
} // end drawPoly
Go to... hilites the c in "Arc"
Am I doing something incorrectly?

Aimee M Clay
marita
 
Posts: 21
Joined: Thu Aug 29, 2002 7:29 pm
Location: USA

Postby jstadolnik on Sat Mar 08, 2003 7:08 pm

Arc() takes 7 arguments not 5.

Joe

The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm
jstadolnik
 
Posts: 1741
Joined: Wed Dec 06, 2000 3:34 am
Location: USA

Postby marita on Sat Mar 08, 2003 9:18 pm

Ah yes! I suppose I should have known that. Um, but I didn't make complete sense of even Geometry over the last couple years of Math, definetly not my best subject. what does it mean by
Use The phases are specified in radians. (e.g. arc(80,80,60,40,3*3.14159/2, 5*3.14159/2,-1); //draws an elliptical backwards C arc)
Thanks again

Aimee M Clay
marita
 
Posts: 21
Joined: Thu Aug 29, 2002 7:29 pm
Location: USA

Postby jstadolnik on Sat Mar 08, 2003 9:54 pm

360 degrees = 2*PI radians.

To draw a full circle:
starting radians = 0
ending radians = 2*3.14159

Joe

The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm
jstadolnik
 
Posts: 1741
Joined: Wed Dec 06, 2000 3:34 am
Location: USA

Postby marita on Sat Mar 08, 2003 10:57 pm

Alright that helps. Now the only other problem, hopefully my very last, is having edited the script it's too huge to put on one memo. I have pedit32 or I could call "include" but am a little blitzed and unsure as to the best way to go about.

Aimee M Clay
marita
 
Posts: 21
Joined: Thu Aug 29, 2002 7:29 pm
Location: USA

Postby marita on Sat Mar 08, 2003 11:02 pm

So you don't even have to answer that question I'm goin to go ahead and call an include at the beginning and put everything before main into another memo just so I don't have to bother with pedit. Thanks for your help, I'll let you know if it works.

Aimee M Clay
marita
 
Posts: 21
Joined: Thu Aug 29, 2002 7:29 pm
Location: USA

Postby marita on Sat Mar 08, 2003 11:21 pm

Good! It works! Now the only difficulty is that the color looks junk. My m130 should have- what- 256 colors I think. but the palette has a bunch of brownish shades so I went to RGB and created a briiliant red but It didn't look like that when I drew with it.I can't seem to figure.

Aimee M Clay
marita
 
Posts: 21
Joined: Thu Aug 29, 2002 7:29 pm
Location: USA

Postby jstadolnik on Sat Mar 08, 2003 11:51 pm

The program sets the detpth to 4 (via SetDepth(4))... which enables 16 shade grayscale mode.

Joe

The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm
jstadolnik
 
Posts: 1741
Joined: Wed Dec 06, 2000 3:34 am
Location: USA


Return to Pocket Toolbox

Who is online

Users browsing this forum: No registered users and 1 guest