diff options
| author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-01-13 01:34:05 +0100 |
|---|---|---|
| committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-01-13 01:34:05 +0100 |
| commit | dfa9e1677f24e06e8da8a136bc568c2f0be1d050 (patch) | |
| tree | 8333c6917ca845f57ff596c30a326d3415e9019a /src/CurveEditor.cxx | |
| parent | f17430be7bf4aaef23b991d04c8804b4f171d7b0 (diff) | |
apply curves in pnmlcms
Diffstat (limited to 'src/CurveEditor.cxx')
| -rw-r--r-- | src/CurveEditor.cxx | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/CurveEditor.cxx b/src/CurveEditor.cxx index ad73758..8ff8671 100644 --- a/src/CurveEditor.cxx +++ b/src/CurveEditor.cxx @@ -43,7 +43,7 @@ CurveEditor::draw() { for (double _x = 0.0; _x < 1.0; _x = _x + 0.01) { double _y = gsl_spline_eval(spline, _x, acc); - fl_vertex(x() + _x * w(), y() + h() * _y); + fl_vertex(x() + _x * w(), y() + h() - h() * _y); } fl_end_line(); @@ -53,7 +53,7 @@ CurveEditor::draw() { } else { fl_color(FL_WHITE); } - fl_rect(x() + w() * X[i] - 2, y() + h() * Y[i] - 2, 4, 4); + fl_rect(x() + w() * X[i] - 2, y() + h() - h() * Y[i] - 2, 4, 4); } } @@ -69,7 +69,7 @@ CurveEditor::handle(int event) { if (Fl::event_button() == 1) { for (int i = 0; i < n; i++) { int x_i = (int) rint(X[i] * w()); - int y_i = (int) rint(Y[i] * h()); + int y_i = (int) rint(h() - Y[i] * h()); if (mark_x >= x_i - 2 && mark_x <= x_i + 2 && mark_y >= y_i - 2 && mark_y <= y_i + 2) { @@ -83,7 +83,7 @@ CurveEditor::handle(int event) { return 1; break; case FL_DRAG: - set(marked_point, (double) mark_x / w(), (double) mark_y / h()); + set(marked_point, (double) mark_x / w(), 1.0 - (double) mark_y / h()); return 1; break; @@ -113,5 +113,11 @@ CurveEditor::set(int i, double _x, double _y) { X[i] = _x; Y[i] = _y; gsl_spline_init (spline, X, Y, n); + + printf("%4f,%4f", X[0], Y[0]); + for (int i = 1; i < n; i++) { + printf(";%4f,%4f", X[i], Y[i]); + } + printf("\n"); redraw(); } |
