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 - Can't figure out how to code something.

Can't figure out how to code something.

Discuss PocketC for Palm OS (including Desktop Edition)

Postby jnetzley on Mon Jun 12, 2006 1:11 am

Was wondering if anyone can help me figure out something.

I am making a program that allows someone to draw a series of shapes in black, and then the program will randomly delete them. I am using a buffer with the background image on it, then copying it to the viewable screen. I then allow someone to draw shapes (squiggly lines, straight lines etc) all in black. These shapes can overlap. The problem is how to delete them in a random order. It seems like you would have to remember the shapes in order ( or copy the screen into a different buffer every time someone put a shape on the screen,) that way you could delete [say] shape #3 while leaving shape #1,2,4 etc.

One thought I hade was drawing each shape in a different shade of black. Then you could do a search on the entire screen and delete the pixels with the shade that went with shape #3. The problem is if the shapes overlap, this will delete the shape underneath, leaving a hole in it where they overlapped. Not to mention this could potentially run out of shades.

I also thought of keeping an array of the shapes, using the screen as an array. You could then use the array corresponding to shape #3 as a guide of what to delete, but this seems like overkill. You would need a 160X160 array for every shape.

This is almost like an 'undo' function in a drawing program in that you are able to delete specific shapes. I would really appreciate if someone could help me. I have been working on this for 4 months.
jnetzley
 
Posts: 3
Joined: Mon Jun 12, 2006 12:59 am

Postby wolfgang on Tue Jun 13, 2006 1:30 am

I can think of two ways to solve this, one time consuming but perfect, the other one fast and compact but maybe not excactly what you want.

First, you could stored the shapes e.g. as arrays of segments or the like. To delete a shape you'd have to clear the screen and then re-draw all shapes that haven't yet been deleted. Perfect but slow if there are many shapes.

Second, instead of drawing all shapes as solid black, draw them as "XOR". I.e. when you set a pixel for a new shape, you make it black if the position is currently white, and you make it white when the position is currently black. To delete a shape, you just re-draw it again in the same mode. The advantage is that this take virtually no processing power or program intelligence. (It was the preferred way to drag-and-drop a shape back in the 80's home computer days when real-time screen buffering wasn't realistically possible with the slow processors of the time). Hope my explanation is clear enough, if nout I'll be glad to expand.

Wolfgang


Composing music on the PocketPC! - http://www.pdamusician.com
Composing music on the PocketPC! - http://www.pdamusician.com
wolfgang
 
Posts: 281
Joined: Tue Dec 12, 2000 4:22 am
Location: USA


Return to PocketC for Palm OS

Who is online

Users browsing this forum: No registered users and 4 guests

cron