- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
void drawAAWave(DWORD *image, WAVE *w, int top, int left,
int width, int height, int offsetPx)
{
int thd2 = top + height/2;
float hm2 = this->height - 2;
int x = 0, xc = 0, yc = 0;
float mul = amplify;
if (invert) mul = -mul;
if (x*scale + offsetPx*scale > w->length) return;
float yFrom = (thd2 - w->data[offsetPx*scale]*mul);
if (yFrom < 2.0f) yFrom = 2.0f;
if (yFrom > hm2) yFrom = hm2;
float yTo, dist, delta, sdelta, alpha, lc;
int yMin, yMax, xcl, n;
for ( ; x < width-1 && (x+offsetPx)*scale < w->length; x++)
{
yTo = thd2 - w->data[(x + offsetPx)*scale]*mul;
if (yTo < 2) yTo = 2; if (yTo > hm2) yTo = hm2;
delta = yTo - yFrom;
sdelta = 1.0f / sqrtf(1.0f + delta*delta);
lc = ((x + 0.5f)*yTo - (x + 1.5f)*yFrom) + 0.5f;
yMin = (int)(min(yFrom, yTo)) - 1;
yMax = (int)(max(yFrom, yTo)) + 1;
xcl = x;
if (delta > 1.0f || delta < -1.0f) xcl++;
for (xc = x; xc <= xcl; xc++)
for (yc = yMin; yc <= yMax; yc++)
{
dist = ((-delta)*(xc + 0.5f) + yc + lc)*sdelta;
alpha = 1.0f - fabs(dist*0.8f);
if (alpha < 0.0f) alpha = 0.0f;
n = maxWidth*yc + xc;
image[n] = clrBlend(image[n], lineColor, alpha);
}
yFrom = yTo;
}
}