Allow for setting alignment of text
jedahan opened this issue · 1 comments
jedahan commented
A hacky prototype:
(defn text-right
"Draw text right aligned"
[canvas ^String s ^long x ^long y]
(let [width (.stringWidth (.getFontMetrics (.graphics canvas)) s)]
(clojure2d.core/text canvas s (- x width) y)))tsulej commented
Thank for the code. Added as a optional parameter to text function
- (text "blah" 100 100) or (text "blah" 100 100 :left) - left aligned
- (text "blah" 100 100 :right) - right aligned
- (text "blah" 100 100 :center) - centered