Keeping track of previously drawn objects
Hi,
I have a program that allows the user to draw one line; and when the user trys to draw another line the first one will disappear. How to make my program keep the previously drawn lines? Do I have to use an array (or a linked list) to keep track of all the previously drawn lines? or is there an easier way?
Thank you!
Hi,
Well, easiest thing would be to use a linked-list like you
said. Everytime you draw a line, just put it in the linked
list.
Then in your program''s drawing routine, just clear the
buffer and iterate over all your lines in the list.
Example would be:
Hope this helps...
Bye!
--
Gautam N. Lad
http://www.cubicdesign.com
Well, easiest thing would be to use a linked-list like you
said. Everytime you draw a line, just put it in the linked
list.
Then in your program''s drawing routine, just clear the
buffer and iterate over all your lines in the list.
Example would be:
typedef struct t_line {
float x;
float y;
byte color[3]; // rgb triplet in 0-255 range
} t_line;
// create a list from this using STL
std::list lineList;
void main() {
// add a line
t_line *newLine = new t_line;
// Set line''s properties here...
newLine->x = 10;
newLine->y = 10;
newLine->color[0] = 255;
newLine->color[1] = 155;
newLine->color[2] = 55;
// add it to the list
lineList.push_back(newLine);
}
Hope this helps...
Bye!
--
Gautam N. Lad
http://www.cubicdesign.com
--Gautam N. Ladhttp://www.cubicdesign.com
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement