473,796 Members | 2,658 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

c without usin any graphics function

if u give cordinates to programme at run time and want a line to be
drawn.. how to do this in c without usin any graphics function?
like x1,y1 and x2,y2
and lines should be drawn from the 1st co-ordinate to 2nd one

any pointer would be appreciated

Thanks

Sep 6 '07 #1
43 1922
shaanxxx said:
if u give cordinates to programme at run time and want a line to be
drawn.. how to do this in c without usin any graphics function?
like x1,y1 and x2,y2
and lines should be drawn from the 1st co-ordinate to 2nd one
Use putchar.
any pointer would be appreciated
putchar is a pointer (except in cases where it's a macro).

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Sep 6 '07 #2
shaanxxx wrote:
if u give cordinates to programme at run time and want a line to be
drawn.. how to do this in c without usin any graphics function?
Drawing a line is a graphics function. You can either get one for your
target system or write your own, but in either case you would be using a
graphics function.

--
Thad
Sep 6 '07 #3
On Sep 6, 8:50 am, shaanxxx <shaan...@yahoo .comwrote:
if u give cordinates to programme at run time and want a line to be
drawn.. how to do this in c without usin any graphics function?
like x1,y1 and x2,y2
and lines should be drawn from the 1st co-ordinate to 2nd one

any pointer would be appreciated

Thanks
#define GIVEN_COORDINAT E1_X 1
#define GIVEN_COORDINAT E1_Y 1
#define GIVEN_COORDINAT E2_X 2
#define GIVEN_COORDINAT E2_Y 2

int main(int argc, char *argv[])
{
printf("Take pencil and draw line from (%d,%d) to (%d,%d).\n",
GIVEN_COORDINAT E1_X, GIVEN_COORDINAT E1_Y,
GIVEN_COORDINAT E2_X, GIVEN_COORDINAT E2_Y);
}

And for pointers you can take a look here:
http://en.wikipedia.org/wiki/Pointer_(dog_breed)

Or you could try to do your own homework.

Sep 6 '07 #4
On Sep 5, 11:50 pm, shaanxxx <shaan...@yahoo .comwrote:
if u give cordinates to programme at run time and want a line to be
drawn.. how to do this in c without usin any graphics function?
like x1,y1 and x2,y2
and lines should be drawn from the 1st co-ordinate to 2nd one

any pointer would be appreciated

Thanks
Most portable ways, not requiring graphics libraries:
1. Draw the line using printf(), assuming 1 character = 1 pixel. You
can save this to a text file.
2. Draw the line in a memory buffer and then save it to a graphics
file that you can view using a web browser or graphics editor/viewer.
Formats that are easy to implement: BMP, XBM (http://en.wikipedia.org/
wiki/XBM :), PCX, etc.

Alex

Sep 6 '07 #5
>if u give cordinates to programme at run time and want a line to be
>drawn.. how to do this in c without usin any graphics function?

Drawing a line is a graphics function. You can either get one for your
target system or write your own, but in either case you would be using a
graphics function.
Does "ASCII art" qualify as drawing a line? ( ---------- or _________
or you can use "character pixels" where every character position on a
(large) piece of paper is, say, @ or space). At least it doesn't
require graphics hardware.

Is "ASCII art" a graphics function?
Sep 6 '07 #6
On Thu, 06 Sep 2007 07:25:07 -0600, in comp.lang.c , Thad Smith
<Th*******@acm. orgwrote:
>shaanxxx wrote:
>if u give cordinates to programme at run time and want a line to be
drawn.. how to do this in c without usin any graphics function?

Drawing a line is a graphics function.
Whats wrong with
puts("_______") ;
puts("|");
puts("|");
puts("|");

?
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Sep 6 '07 #7
"Mark McIntyre" writes:
>>Drawing a line is a graphics function.

Whats wrong with
puts("_______") ;
puts("|");
puts("|");
puts("|");
It doesn't meet the spec. The OP gave x and y coordinates in his question.
Rounding an angle to the nearest 45 degrees, at best, wouldn't satisfy that
by any stretch of the imagination.
Sep 7 '07 #8
In article <5k************ @mid.individual .net>,
osmium <r1********@com ast.netwrote:
>"Mark McIntyre" writes:
>>>Drawing a line is a graphics function.
>Whats wrong with
puts("_______" );
puts("|");
puts("|");
puts("|");
>It doesn't meet the spec. The OP gave x and y coordinates in his question.
Rounding an angle to the nearest 45 degrees, at best, wouldn't satisfy that
by any stretch of the imagination.
The OP did not require that the drawn line proceed straight from
the beginning to ending coordinates. If the coordinates are
integral and finite, then you could draw a 45 degree line of length
min(abs(x1-x0),abs(y1-y0)), and a straight line of length
max(abs(x1-x0),abs(y1-y0))-min(abs(x1-x0),abs(y1-y0))
provided that the shorter of these two fit whatever page-size is in use.
--
Okay, buzzwords only. Two syllables, tops. -- Laurie Anderson
Sep 7 '07 #9
On Sep 5, 11:50 pm, shaanxxx <shaan...@yahoo .comwrote:
if u give cordinates to programme at run time and want a line to be
drawn.. how to do this in c without usin any graphics function?
like x1,y1 and x2,y2
and lines should be drawn from the 1st co-ordinate to 2nd one
It's fairly difficult to draw a line. They are infinitely long.
Segments are a bit easier.

1. Ask for rows and columns available on the terminal
2. Create an array of [rows][columns] characters
3. Draw a segment through your grid with something like this:
http://pubpages.unh.edu/~cs770/notes/lines.html

Sep 7 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3382
by: JBiagio | last post by:
Hello All, I am attempting to learn a bit about the GDI+ transforms and charting data and I feel like I'm getting a handle on how the transforms work. My chart object has a large "canvas" bitmap that all data is scaled to and rendered on, and I display a smaller "window" of the canvas that the user can page through left and right. I've been able to scale my data (for the purposes of this discussion, x values are 0 - 2PI and y values...
14
3103
by: Pmb | last post by:
At the moment I'm using Borland's C++ (http://www.borland.com/products/downloads/download_cbuilder.html#) I want to be able to take an array of points and plot them on the screen. Is there a way to do this? E.g. I want to be able to graph a function. At this point I'm not up to a level in C++ where I want to start learning Visual C++ so I don't want to go that route. Thanks
7
8744
by: Marc Pelletier | last post by:
Hello all, I have a class which includes a method to create a chart. I want to be able to call this method from asp.net code as well as windows application code, so I have sketched it out as returning a bitmap instance. In my asp.net code I think I should call this method to return a bitmap and then somehow stream it using the response object to the Webcontrols.image. Is that right? The image object is on a page with a number of...
0
1055
by: RamyaKarthik | last post by:
pls give some guide lines for developing project for online survey usin c++
1
1403
by: Ringo | last post by:
I need some help. I have an app that talks to a sonar board via the serial port. In my sp_DataReceived I gather all the data and put it into arrays. Then I want to draw the data in a pictureBox. I wrote a function called Draw_sonar2 that does all the drawing. It usually works but sometimes crashes saying the graphics object is already in use. After digging I saw that I should be doing the Drawing in the PB.paint, not a seperate function....
11
6738
by: Slickuser | last post by:
I have this function that will fill the ellipse every 10 seconds with specific x,y,w,h. Now I want do the the reverse, to clear the ellipse with given x,y using Timer at every 30s. Or I have put these (x,y,w,h) to an array? Later go back the array and fill ellipse with the same color as background? Is there an easy way?
6
4146
by: jt | last post by:
i think i was not clear in my quesiton. my question actually was how to store a graphics image generated in C. Eg. #include<graphics.h> void main() { int gm,gd=DETECT; initgraph(&gd,&gm,""); rectangle(50,50,200,300);
9
2667
by: DaveL | last post by:
hello I have a Bit map 1367 wide 32 high this bitmap contains like 40 separate Images 32x32 I tell it the id*32 to get the approiate Image from the source Bitmap When i CreateGraphics() From the Standard CreateGraphics() function the code below works
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10461
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10190
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10019
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6796
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4122
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.