Jagged arcs

This commit is contained in:
Simon Robertshaw 2011-06-27 18:16:25 +01:00
parent 36ee81fc6b
commit 3fe82bf525
2 changed files with 36 additions and 0 deletions

View File

@ -893,6 +893,8 @@ void set_emap(int x, int y);
int parts_avg(int ci, int ni, int t);
void create_arc(int sx, int sy, int dx, int dy, int midpoints, int variance, int type);
int nearest_part(int ci, int t);
void update_particles_i(pixel *vid, int start, int inc);

View File

@ -1244,6 +1244,40 @@ int nearest_part(int ci, int t)
return id;
}
void create_arc(int sx, int sy, int dx, int dy, int midpoints, int variance, int type)
{
int i;
float xint, yint;
int *xmid, *ymid;
int voffset = variance/2;
xmid = calloc(midpoints + 2, sizeof(int));
ymid = calloc(midpoints + 2, sizeof(int));
xint = (float)(dx-sx)/(float)(midpoints+1.0f);
yint = (float)(dy-sy)/(float)(midpoints+1.0f);
xmid[0] = sx;
xmid[midpoints+1] = dx;
ymid[0] = sy;
ymid[midpoints+1] = dy;
for(i = 1; i <= midpoints; i++)
{
ymid[i] = ymid[i-1]+yint;
xmid[i] = xmid[i-1]+xint;
}
for(i = 0; i <= midpoints; i++)
{
if(i!=midpoints)
{
xmid[i+1] += (rand()%variance)-voffset;
ymid[i+1] += (rand()%variance)-voffset;
}
create_line(xmid[i], ymid[i], xmid[i+1], ymid[i+1], 0, 0, type);
}
free(xmid);
free(ymid);
}
//the main function for updating particles
void update_particles_i(pixel *vid, int start, int inc)
{