answersLogoWhite

0

Here is the C code for DDA line drawing...

#include<stdio.h>

#include<conio.h>

#include<graphics.h>

#include<math.h>

void main()

{

int gd, gm;

float x, y, dx, dy, len;

int x1, y1, x2, y2, i;

detectgraph(&gd, &gm);

initgraph(&gd, &gm,"");

printf("\n Enter the coordinates of line : ");

scanf("%d %d %d %d", &x1, &y1, &x2, &y2);

dx = abs(x2-x1);

dy = abs(y2-y1);

if (dx >= dy) len = dx;

else len = dy;

dx = (x2-x1)/len;

dy = (y2-y1)/len;

x = x1 + 0.5;

y = y1 + 0.5;

i = 1;

while (i <= len)

{

putpixel(x, y, 6);

x = x+dx;

y = y+dy;

i++;

}

getch();

}

-Suraj.

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

Opengl programming source code for pool game?

writ an opengl program for pool game


The code 11110101101 was received Using Hamming encoding method 2 what is the original code sent?

the code 11110101101 was received using hamming encoding algorithm what was the original code sent


Matlab code for filters using LMS algorithm?

http://www.mathworks.com/matlabcentral/fileexchange/3649


Java source code for median filter algorithm?

research is going on to develop a source code for median filtering using java


What are the ways representing an algorithm?

You can represent an algorithm by three different ways: 1. Pseudo Code 2. Structured flow charts 3. Actual code


How can i find the version of shader i have?

To find the version of the shader you have, you can typically check the graphics API documentation or your graphics card settings. On Windows, you can use tools like DirectX Diagnostic Tool (dxdiag) or OpenGL Extensions Viewer for OpenGL shaders. Alternatively, you can run a shader code snippet that retrieves the version using GLSL (OpenGL) or HLSL (DirectX) commands to print the shader version in your application.


What is the difference between implementation and algorithm?

An algorithm is a instruction for solving a problem. It is typically illustrated using prose, pseudo code or flowcharts, but other methods exist. The algorithm is the "here's how it's going to work" part of the solution. An implementation (of an algorithm) is a specific expression of this algorithm, using a specific programming language or any other suitable means. The implementation is the "here's how I've done it" part of the solution.


Free car competition sample code on opengl animation?

coding for car animation in open gl


What is the code of pegasis?

PEGASIS Cluster Algorithm Code for WSN Omnet++ ?


What is A algorithm in AI?

A algorithm in artificial intelligence is a line of code meant to simulate a human emotion.


Can someone provide the C program for Prim's algorithm?

The C code for Prim's algorithm can be found in the following link. https://sites.google.com/site/itstudentjunction/lab-programming-solutions/data-structures-programs/program-to-find-minimal-spanning-tree-using--prims-algorithm


What is pseudo code algorithm for create a linked list with a header and insert a four numbers to the list?

pseudo code algorithm to create a linked list