Bitmap/Bresenham's line algorithm: Difference between revisions

m
→‎{{header|C}}: interface/impl
m (→‎{{header|Perl}}: libheader imlib2)
m (→‎{{header|C}}: interface/impl)
Line 180:
=={{header|C}}==
 
To be added to <tt>imglib.h</tt>.
<lang c>#define plot(x, y) put_pixel_clip(img, x, y, r, g, b)
 
<lang c>void draw_line(
image img,
unsigned int x0, unsigned int y0,
unsigned int x1, unsigned int y1,
color_component r,
color_component g,
color_component b );</lang>
 
The implementation code:
 
<lang c>#include "imglib.h"
 
<lang c>#define plot(x, y) put_pixel_clip(img, x, y, r, g, b)
#define swap_uint(a, b) do{ unsigned int tmp; tmp = a; a = b; b = tmp; }while(0)