[ C++ ] Drawing Program.


 
Thread Tools Search this Thread
Top Forums Programming [ C++ ] Drawing Program.
# 8  
Old 12-21-2007
Quote:
Originally Posted by Max_Payne
I just don't know how to do that in the page ?
What representation are you using in Page to hold a page?

For this example I would have a page being an array of characters where each is initialised to a space. Then drawing is simply a matter of setting the appropriate character. Once all the drawing has been done you then emit the page to stdout.
# 9  
Old 12-21-2007
Can you look at the code and give me an example ?
# 10  
Old 12-21-2007
Your page, as far as I can see only has a width and a height.

No storage for the representation of the page itself.

Code:
class Page
{
.....
char *pagedata;

       Page(....)
       {
            pagedata=new char[width*height];
       }

       ~Page()
       {
            delete pagedata;
       }

       plot_character(int x,int y,char c)
       {
            pagedata[(y*width)+x]=c;
       }

       void print_page()
       {
             int y=0;
             char *p=pagedata;
             while (y < height)
             {
                   fwrite(p,width,1,stdout);
                   fprintf(fp,"\n");
                   y++;
                   p+=x;
             }
       }
};

# 11  
Old 12-21-2007
Thanks................

Last edited by Max_Payne; 12-22-2007 at 08:39 PM..
# 12  
Old 12-23-2007
Still can't figure it out.

What do i put in the main() function that will let me print points and lines anywhere i want in the page ?
# 13  
Old 12-23-2007
How about have the main program reading in from stdin a load of text rows, where each row is a sequence of pairs of coordianets describing a path.

Then read the textual representation and create

(a) a page

(b) a series of point collections where each list of points is a path

when you read EOF then render the page into the sequence of characters and print out on stdout.
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Server room drawing software

Hello All, I want to get ride of Excel/word and want some software to draw my server room racks/server and overall topology. Please share you opinion/experience. thanks inadvance (1 Reply)
Discussion started by: Vit0_Corleone
1 Replies

2. Post Here to Contact Site Administrators and Moderators

Question Regarding Megabits Drawing

Dear Admins / Mods, I have been trying my luck with Megabits Drawing few times ;) but I am not sure how it works! :confused: http://i49.tinypic.com/2ake15f.jpg I have few questions:- Why this page for me is still showing 3 Lotto & 4 SuperForumLotto purchased even after the drawing... (22 Replies)
Discussion started by: Yoda
22 Replies

3. Programming

problems with drawing in x using xlib

Hi all, I'm currently learning xlib and I've encountered a bizarre mistake: function calls such as XDrawPoint, XDrawLine, etc., don't seem to work; a blank window with nothing in is appears. I believe this has something to do with the window manager I use, fluxbox. After checking the code and... (0 Replies)
Discussion started by: hydronium
0 Replies

4. Shell Programming and Scripting

Drawing

Hi, Is it possible to draw circle, box and other basic shapes using shell scripts ? If so can anyone please tell as how to do it. Thanks in advance. (3 Replies)
Discussion started by: abrd600
3 Replies

5. Programming

Line-drawing character!

Hi guys, I'm trying to make my program to print out tables usings line-drawing character (alternate char. set) with Curses Library. However, it always prints out control characters (^@) instead of the correct ones. code example: mvwaddch(my_window, 23, 12, ACS_RTEE); appreciate your help,... (5 Replies)
Discussion started by: zecoj
5 Replies
Login or Register to Ask a Question