Internet
C Programming

How do you draw a line using C graphics?

484950

Top Answer
User Avatar
Wiki User
2006-01-18 09:30:50
2006-01-18 09:30:50

Hi, To draw a line in C, follow steps given below- 1. Load graphics Driver using the syntax: int gd,gm; initgraph(&gd,&gm,""); In this initgraph is a function defined in graphics.h header file. In this function gd is for graphics driver and gm is for graphics mode.Third argument is path to your .bgi file. You are preferred to keep your all .bgi and .chr files in bin folder so no need to give path for these things. .BGI files are graphics adapter so for good graphics you should use enhanced adapter you can take more details about these from help of turbo C++ IDE. Well, you can use EGAVGA.bgi. 2.Now You can use any graphics function like line, circle, rectangle etc. For drawing a line you can use following syntax: line(100,100,300,100); These are initial point and final points of a line respectively. 3.Finally you should close the graphics environment by using closegraph(); ,so control will return back to the text mode. It is not mandatory , but it is a good practice. Thanx n Regards Ajay vijaywargiya(SE) BMC s/w pune(INDIA)

1
๐Ÿ™
0
๐Ÿคจ
0
๐Ÿ˜ฎ
0
๐Ÿ˜‚
0

Related Questions

User Avatar

The C language is not a graphics language and you cannot draw logic gates using it. C is a programming language, and it is possible to use a graphics library to do so, but you did not specify which library you were using. Please restate the question.

User Avatar

Write a C program to draw a sphere in computer graphics?

User Avatar

using pie slice function akwinder can draw monkey which exactly looks like her.

User Avatar

I presume you need a graphics package that you can use with C. Do some google searches (and remember to specify your OS) and pick the one you like the best.

User Avatar

Since all graphics are platform-specific, there are no built-in, generic graphics routines, including line drawing. To draw any graphics you will need a suitable API for your platform and hardware, thus the actual code will vary according to which system you are targeting.

User Avatar

C++ has no built-in graphics methods. Graphics are platform-specific, but C++ is a generic language. To use graphics you need a graphics library and API that are specific to your platform and hardware. The code you use will therefore be specific to that library.

User Avatar

You cannot -- not with a generic C or C++ implementation. Both are designed to be as generic as possible, but graphics are platform-specific. For graphics output, you therefore need a suitable graphics library and API for your specific platform and hardware.

User Avatar

C++ has no built-in graphics methods, including line drawing. Graphics is platform-specific and, as such, requires a graphics API and library specific to your platform and hardware. As a result, there is no generic, one-size-fits-all C++ code for drawing graphics of any kind.

User Avatar

the diagram shows that u cant because that a half turn

User Avatar

C++ is a generic, cross-platform language, but graphics are platform-dependant. thus C++ has no built-in methods for graphics output. To draw graphics in C++ you need a low-level API and library specific to the platform and hardware you intend to target. Some libraries are highly abstract and therefore support cross-platform development, but most are platform-specific. Consult the documentation that came with your library.

User Avatar

Graphics is not part of the standard C-library.

User Avatar

There are no built-in functions that can draw lines since C++ is a generic language and graphics are platform-dependent. Even the standard library does not provide any line drawing methods aside from printing ASCII line-drawing characters on the console. Even so, consoles are also platform-dependent; there are no generic methods of printing a specific character at a specific position. To draw lines -- that is to say a straight line between two points within a viewport -- you will need a graphics library that supports your platform. OpenGL is your best option as it provides a generic interface.

User Avatar

You cannot draw any graphics in standard C++. For graphics output you need an appropriate API that supports your platform and hardware. Since this is platform-specific, it is not part of the standard.

User Avatar

If you mean how do you draw a curve in C++, you can't. C++ does not have any built-in graphics support of any kind. All graphics are platform-specific so, to be able to draw graphics, you need a graphics API and library suitable for your platform and hardware. As a result, the code you use will not be portable. In most graphics libraries you will draw curves as a series of arcs, so you want to look up the arc() function in your library documentation.

User Avatar

C++ is a generic, cross-platform programming language, while 3D graphics are platform-specific. To draw graphics of any kind you need a low-level API and library specific to your platform and hardware.

User Avatar

You don't: the C and C++ languages do not have any built-in graphics tool. Further, it is impossible to draw a concentric circle. Multiple circles are concentric when they share the same center.In C or C++, graphic functions such as the drawing of lines, rectangles or circles are provided through third party libraries, or through wrappers which provide access to the operating system's graphics functions.

User Avatar

Download and install the WinBGIM Devpack. Once installed, you can include graphics.h to draw graphics.

User Avatar

C does not provide any native support for graphics manipulation. C is a general-purpose language, not a system-specific language. To add graphics support you must link to a graphics library. Generic libraries such as OpenGL are recommended.

User Avatar

C++ has no built-in function to draw lines, nor indeed to perform any type of graphics output. The standard library is designed to be as generic as possible, and is therefore capable of supporting all platforms using text output only. Graphics output is obviously possible, but it is platform-specific so you will need a graphics API that provides functions that are specific to your operating system and/or hardware.

User Avatar

i want a coding of a program of a calculator using graphics in c language??

User Avatar

first you draw a horizontal line, the on the left side of the line draw a line going down, then at the end of the line draw a curve which looks like a inverted c. Then you have 5 then put a dot on the bottom side of the 5 then draw a curve which looks like and inverted c, then on the bottom draw a line which goes horizontally, now you have 5.2 then you make a curve which looks like a sphere but the end of the line touches the middle of the line, forming a loop. Now you have 5.26 then draw a line horizontally, then at the right side draw a line which goes diagonally. Now you have wrote 5.267

User Avatar

You draw an angle and its vertex should be A on its left B and on its right C. ( An Acute)Confirmed

User Avatar

pro c language to implement linear search using pointers

User Avatar

C has no native support for graphics. You would either have to use your local APIs or use an external library (ex: OpenGL).


Copyright ยฉ 2020 Multiply Media, LLC. All Rights Reserved. The material on this site can not be reproduced, distributed, transmitted, cached or otherwise used, except with prior written permission of Multiply.