void GraphData::render( ImageObject& img, const Rect& r ) { int pixel = 0; int old_pixel = 0; for(int i = 0; i < values-1; i++) { if(pInterpolation == GRAPH_INTERPOLATION_NONE) { img.putPixel(data_pixels[i][0], (int)getValue(i, 1), lineColor); } else { int spacing = (data_pixels[i+1][0]-data_pixels[i][0]); for(int i2 = 0; i2 < spacing; i2++) { float pos = ((float)i2/(float)(data_pixels[i+1][0]-data_pixels[i][0])); //TODO: Select interpolation type if(pInterpolation == GRAPH_INTERPOLATION_SPLINE) { pixel = (int)splineInterpolation(pos, getValue(i-2,1), getValue(i-1, 1), getValue(i, 1), getValue(i+1, 1), getValue(i+2, 1), getValue(i+3, 1)); } else if(pInterpolation == GRAPH_INTERPOLATION_CUBIC) { pixel = (int)linearInterpolation(pos, getValue(i, 1), getValue(i+1, 1)) + 10; } else { pixel = (int)linearInterpolation(pos, getValue(i, 1), getValue(i+1, 1)); } // Going up if(pixel > old_pixel) { for(int apa = abs(pixel-old_pixel); apa >= 0; apa--) { img.putPixel(data_pixels[i][0]+i2, pixel-apa, lineColor); } } // Going down else if(old_pixel > pixel) { for(int apa = abs(pixel-old_pixel); apa >= 0; apa--) { img.putPixel(data_pixels[i][0]+i2, pixel+apa-1, lineColor); } } // Same value as previous sample else { img.putPixel(data_pixels[i][0]+i2, pixel, lineColor); img.putPixel(data_pixels[i][0]+i2, pixel-1, lineColor); } old_pixel = pixel; } } } }