Digital differential analyzer (graphics algorithm): Difference between revisions

Content deleted Content added
Line 33:
{
float x = xa;
float mmx = (xb - xa) / (yb - ya);
float mc [3];
int y, color [3];
mc[0] = (colorb[0] - colora[0]) / (colorb[0] - colora[0]);
mc[1] = (colorb[1] - colora[1]) / (colorb[1] - colora[1]);
mc[2] = (colorb[2] - colora[2]) / (colorb[2] - colora[2]);
for (y=ya; y<=ys; y++) {
output(round(x), y, color);
x = x + mmx;
color[0] += mmc[0]; /* Red component */
color[1] += mmc[2]; /* Green component */
color[2] += mmc[1]; /* Blue component */
}
}
</code>
 
 
==Integer Implementation with seperated Fractional Part==