Tip:
Highlight text to annotate it
X
hello welcome to graphics programming here we have a simple
line drawing algorithm the program in C language it is given
as we are using graphics include graphics.h
and stdio.h, conoi.h math.h and all the header files
and we have a user defined function round
to round off the values
read the xy values of the line starting and ending points
inintgraph() is used to initialize the graphics
I have diven the c code for the program u can download
and you can do some experiments
and here the calculations are done we are finding
dx and dy, that x difference and y difference
and increment value for x and are calculated
we have step value being incremented
steps and each and every time displaying
and put pixel function is used plot the line with dots
Here the complete program is given for download
run the program it is asking values for x1
x2, y2
see the line is being drawn slowly
each and every x ,y value is displayed for the understanding
according to the slope of the line X&Y values that dynamically calculated
how to dx dy values calculated is given here
and the increment values
Xin & Yin that depends upon the slope of the line
vertical, horizontal lines download the code and try it
again we will try some meore examples
give some other value
50,100 and 100,
100 for this is going to be a horizontal line
y value is 100 in both y1 and y2
and x is incremented
again
one more time
10, 100 and 100,
10
dx, dy values
x and y incremented
delay function is given for visualization
see
see the line
thank you
subscribe the channel. I have crossed 1000 Subscribers
thank you for your support bye