LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-24-2003, 03:50 PM   #1
Gerardoj
Member
 
Registered: May 2003
Location: Somewhere over the Rainbow
Distribution: Slackware 9.x, Knoppix, Damn Small Linux, RedHat.
Posts: 465

Rep: Reputation: 30
Draw Circle


Hi, I would like to know how can I draw a circle in MS Visual C++ and when I press the UP arrow in the keyboard the Circle enlarges and when I press the Down Arrow the Circle diminishes. Thanks A Lot
 
Old 08-24-2003, 03:57 PM   #2
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
im only familiar with the standard windows api, you can probably do it easily with mfc but i dont know that. using the basic windows api this is quite a big question, the program to do this would be about 200-300 lines long, if you know c++ then i suggest you have a look at the tutorial at www.winprog.org but you'll have to learn quite a bit before you start this.
 
Old 08-24-2003, 04:38 PM   #3
Gerardoj
Member
 
Registered: May 2003
Location: Somewhere over the Rainbow
Distribution: Slackware 9.x, Knoppix, Damn Small Linux, RedHat.
Posts: 465

Original Poster
Rep: Reputation: 30
Hay thanks for your reply, I understand that is long, but instead to make the all program how can I make just a Circle?

Thanks
 
Old 08-24-2003, 04:44 PM   #4
Proud
Senior Member
 
Registered: Dec 2002
Location: England
Distribution: Used to use Mandrake/Mandriva
Posts: 2,794

Rep: Reputation: 116Reputation: 116
It's gunna take a fair bit of reading and learning, and if you want anything more than a circle you need to understand what you're writing and executing. Otherwise it's a pointless app which makes a circle like magic.
 
Old 08-24-2003, 05:00 PM   #5
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
im gonna get sooo flamed for saying this but it sounds like visual basic would be the sorta thing your after, you could probably do it in a few lines but i dont know vb myself.
 
Old 08-24-2003, 05:01 PM   #6
Gerardoj
Member
 
Registered: May 2003
Location: Somewhere over the Rainbow
Distribution: Slackware 9.x, Knoppix, Damn Small Linux, RedHat.
Posts: 465

Original Poster
Rep: Reputation: 30
Ok I made this one but now have a problem when I compile, appears me that

C:\documents and settings\root\my documents\c code\circle\ircle.cpp(4) : fatal error C1083: Cannot open include file: 'graphics.h': No such file or directory
Error executing cl.exe.

The code

#include <stdio.h>
#include <time.h>
#include <conio.h>
#include <graphics.h>
#include <math.h>
#include <dos.h>
#include <stdlib.h>
#include <time.h>
int main(void)


{
int gdriver = DETECT, gmode;
double x, y, theta, r;
int i, c, thetamax, step;
initgraph(&gdriver, &gmode, "");
struct palettetype pal;
getpalette(&pal);
for (i=0; i<pal.size; i++)
setrgbpalette(pal.colors, i * 2 , 2, i*4);
randomize();


do {
for (i=0; i<pal.size; i++)
setrgbpalette(pal.colors, i * random(14) ,i * random(14), i * random(14));
r = random(230) + 20;
thetamax = random(360) + 1;
step = random(15) + 1;
for(theta = 0; theta <= thetamax; theta+=step)


{
if(kbhit())
c = getch();
x = cos(theta);
y = sin(theta);
setcolor(random(14)+ 1);
delay(10);
rectangle(300 + x * r, 200 + y * r, 350 + x * r, 250 + y * r);
}
for(theta = 0; theta <= thetamax; theta+=step)


{
if(kbhit())
c = getch();
x = cos(theta);
y = sin(theta);
setcolor(0);
delay(10);
rectangle(300 + x * r, 200 + y * r, 350 + x * r, 250 + y * r);
}
if(kbhit())
c = getch();
} while(c != 13);

return(0);
}
 
Old 08-24-2003, 05:08 PM   #7
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
you wrote that recently??? graphics.h was a header that came with turbo c++ for dos about 10 years ago, i didnt know anybody used that library anymore, it certanly wouldnt work on an nt/2000/xp box. anyway back to the point, graphics.h was specific to turbo c++ and doesnt exist in vc++, in fact i cant think of any console graphics library that you can use with vc++
 
Old 08-24-2003, 05:13 PM   #8
Gerardoj
Member
 
Registered: May 2003
Location: Somewhere over the Rainbow
Distribution: Slackware 9.x, Knoppix, Damn Small Linux, RedHat.
Posts: 465

Original Poster
Rep: Reputation: 30
no, I is my friend code , oh now I undestand, and what header can I use instead of 'graphics.h' with Visual C++ to draw?, The above code I made it is very simply, do you think that works fine?

#include <stdio.h>
#include <conio.h> //for getch();
#include <graphics.h>//for graphics
void main ()
{
int dirver, mode ;
int x1=0 , y1=0; //for line
int x2=199 , y2=199; // for line
int xC=100 , yC=100; // for circle
int radius=90; //radius of the circle
dirver = DETECT; // detecting the driver of VGA automatic
initgraph (&dirver , &mode , "c:\\tc\\bgi"); // initilizing graph
line (x1,y1,x2,y2);
circle (xC, yC, radius) ;
getch();
closegraph(); //closing graph
}

Thanks a lot

Last edited by Gerardoj; 08-24-2003 at 05:16 PM.
 
Old 08-24-2003, 05:20 PM   #9
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
i cant see anything disasterously wrong with your code, there are a few things that should be changed to make it standard like 'void main()' but it looks ok.

Quote:
what is the same header that came with Visual C++ to draw instead of graphics.h
as i said above 'in fact i cant think of any console graphics library that you can use with vc++' there is no equivelent to graphics.h in vc++, you could use allegro or sdl but i have absolutely no idea how to set them up with vc++
 
Old 08-24-2003, 05:24 PM   #10
Gerardoj
Member
 
Registered: May 2003
Location: Somewhere over the Rainbow
Distribution: Slackware 9.x, Knoppix, Damn Small Linux, RedHat.
Posts: 465

Original Poster
Rep: Reputation: 30
Thanks, and I would like that you tell me just an Idea, how can I make that the circle enlarge and diminishes? just idea!

Thanks A lot.
 
Old 08-24-2003, 05:29 PM   #11
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
psuedo C

Code:
main()
{
    int radius = 100;

    initialisation();

    while(true) {
        draw_screen();
        get_keyboard_state();
        if(up_key_pressed) radius++;
        if(down_key_pressed) radius--;
    }

    tidy_up();
}
 
Old 08-24-2003, 05:32 PM   #12
Gerardoj
Member
 
Registered: May 2003
Location: Somewhere over the Rainbow
Distribution: Slackware 9.x, Knoppix, Damn Small Linux, RedHat.
Posts: 465

Original Poster
Rep: Reputation: 30
Thanks a LOT
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
HAL... the circle. Peingune Linux - Newbie 10 08-16-2005 06:01 AM
KDE Pen with circle slash icon omega17 Linux - General 2 05-13-2005 03:59 AM
RPM - dependencies going round in circle! The_JinJ Linux - Newbie 6 11-23-2004 04:09 AM
NDISWrapper and the circle of Hate ryanroler Linux - Wireless Networking 3 11-06-2004 08:55 PM
Confusion with RPM's - vicious circle mykyl Linux - Software 13 09-18-2003 02:48 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration