Algorithm-Line-Bresenham-C
view release on metacpan or search on metacpan
Line/Bresenham/C/C.xs view on Meta::CPAN
LiloHuang @ 2008, kenwu@cpan.org
*/
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
MODULE = Algorithm::Line::Bresenham::C PACKAGE = Algorithm::Line::Bresenham::C
void circle(int y, int x, int radius)
PPCODE:
AV * point;
int curr_x = 0;
int curr_y = radius;
int d = 3 - (radius << 1);
while(1) {
EXTEND(SP, 8);
point = (AV *)sv_2mortal((SV *)newAV());
av_push(point, newSViv(y + curr_y));
Line/Bresenham/C/C.xs view on Meta::CPAN
if (d < 0) {
d += (curr_x << 2) + 6;
}else{
d += ((curr_x - curr_y) << 2) + 10;
curr_y -= 1;
}
curr_x++;
}
void line(int from_y, int from_x, int to_y, int to_x)
PPCODE:
AV * point;
int curr_maj, curr_min, to_maj, to_min, delta_maj, delta_min;
int delta_y = to_y - from_y;
int delta_x = to_x - from_x;
int dir = 0;
if(abs(delta_y) > abs(delta_x)) dir = 1;
if(dir) {
curr_maj = from_y;
curr_min = from_x;
( run in 1.029 second using v1.01-cache-2.11-cpan-71847e10f99 )