Clojure2D/clojure2d

show-window without window-name doesn't draw

jdf-id-au opened this issue · 2 comments

Thanks for this brilliant project.

I was surprised, when I ignored the docstring and called (show-window canvas) without a window-name, that it did display the window (including taking account of the canvas dimensions) but didn't draw in it.

I think it might be something to do with the 1-arity of show-window somehow destructuring a Canvas, but I can't quite nail it down for a PR.

Everything worked when I passed a window-name 😀

Hi there! Thanks for kind words.

Indeed, (show-window canvas) will not work. At some point of development I decided to switch to a map for 1-arity case. The main reason was the high number of function arguments.

This will work:

(def canvas (c2d/canvas 800 800))
(c2d/with-canvas-> canvas
  (c2d/set-background 0)
  (c2d/line 10 10 790 790))
(c2d/show-window {:canvas canvas}) ;; 1-arity accepts map

I can add some validation of the input and if it's the canvas object it will accept this. It's kind of hack I try to avoid usually, but maybe it's ok here.