diff options
author | Robin Gareus <robin@gareus.org> | 2014-05-30 03:04:02 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2014-05-30 03:04:02 +0200 |
commit | fed5599baa4940f12d8b4edce70cf3c9c762572a (patch) | |
tree | ee3fa72c42dd94838378fd97303420e1092947f2 /libs/canvas/canvas.cc | |
parent | 38891288f3ad60c16832829f5c07c458a35051a9 (diff) |
smooth visual curve drawing
Diffstat (limited to 'libs/canvas/canvas.cc')
-rw-r--r-- | libs/canvas/canvas.cc | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/libs/canvas/canvas.cc b/libs/canvas/canvas.cc index d5d8562361..ceaa366c35 100644 --- a/libs/canvas/canvas.cc +++ b/libs/canvas/canvas.cc @@ -193,14 +193,15 @@ Canvas::window_to_canvas (Duple const & d) const } Duple -Canvas::canvas_to_window (Duple const & d) const +Canvas::canvas_to_window (Duple const & d, bool rounded) const { Duple wd = d.translate (Duple (-_scroll_offset_x, -_scroll_offset_y)); - /* Note that this intentionally always returns integer coordinates */ - - wd.x = round (wd.x); - wd.y = round (wd.y); + /* Note that this intentionally almost always returns integer coordinates */ + if (rounded) { + wd.x = round (wd.x); + wd.y = round (wd.y); + } return wd; } @@ -212,16 +213,18 @@ Canvas::window_to_canvas (Rect const & r) const } Rect -Canvas::canvas_to_window (Rect const & r) const +Canvas::canvas_to_window (Rect const & r, bool rounded) const { Rect wr = r.translate (Duple (-_scroll_offset_x, -_scroll_offset_y)); - /* Note that this intentionally always returns integer coordinates */ + /* Note that this intentionally almost always returns integer coordinates */ - wr.x0 = round (wr.x0); - wr.x1 = round (wr.x1); - wr.y0 = round (wr.y0); - wr.y1 = round (wr.y1); + if (rounded) { + wr.x0 = round (wr.x0); + wr.x1 = round (wr.x1); + wr.y0 = round (wr.y0); + wr.y1 = round (wr.y1); + } return wr; } |