Logarithmic scale depending on variable

master
Stefan Jahn 3 years ago
parent c4b45efb9a
commit 7046b2edc9

@ -25,6 +25,7 @@ int histogram_pressed_x; // window x-coordinate when pressing a b
int histogram_released_x; // window x-coordinate when releasing a button
int histogram_pressed = 0; // indicates button pressed or not
int histogram_zoomed = 0; // indicates zoom
int histogram_log = 1; // logarithmic or linear scale
extern GtkBuilder *_builder_; // work around for threads
@ -72,7 +73,10 @@ void cb_histogramda_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer da
int histogram_scale = histogram_width - 1 > 0 ? histogram_width - 1 : 1;
for (int i = 0; i < histogram_width; i++) {
px = HISTOGRAM_MARGIN + ((clientw-HISTOGRAM_MARGIN*2) * i) / histogram_scale;
if (histogram_log)
py2 = (clienth-HISTOGRAM_MARGIN) - ((clienth-HISTOGRAM_MARGIN*2) * log10(histogram[chan][histogram_zoom_start+i]+1) / log10(histogram_max));
else
py2 = (clienth-HISTOGRAM_MARGIN) - ((clienth-HISTOGRAM_MARGIN*2) * histogram[chan][histogram_zoom_start+i] / histogram_max);
if (i == 0) cairo_move_to(cr, px, py2);
else cairo_line_to(cr, px, py2);

Loading…
Cancel
Save