Is there anything glaring that I'm missing from my circle
implementation for skija that is preventing it from working with center
? The rectangle works fine
(defrecord Circle [rad]
ui/IOrigin
(-origin [_]
[0 0])
ui/IBounds
(-bounds [this]
[(* rad 2) (* rad 2)])
skija/IDraw
(draw [this]
(.drawCircle ^Canvas skija/*canvas* 0.0 0.0 (float rad)
(skija/map->paint skija/*paint*))))
(defn draw []
(let [x 500
y 350
circ
(ui/translate x y
(ui/with-color [1.0 0.7529411764705882 0.796078431372549]
(Circle. 50)))
rect
(ui/translate 100 100
(ui/with-color [0.6784313725490196 0.8470588235294118 0.9019607843137255]
(ui/rectangle 100 100)))]
[rect
(ui/center
(ui/translate 100 100
(ui/label (str (ui/origin rect) "," (ui/bounds rect))))
(ui/bounds rect))
circ
(ui/center
(ui/translate x y
(ui/label (str (ui/origin circ) "," (ui/bounds circ))))
(ui/bounds circ))]))
the origin should be in the upper left. I don't know off the top of my head if .drawCircle draws from the center or not
Ah! that's probably it
I haven't had a chance to think through all the implications of having a negative origin, so there might be some issues with hit detection (if you're using the default ui/mouse-move
/`ui/mouse-down`/etc event functions when the origin is negative
if you are using the ui/mouse*
stuff, then you might want to translate the circle before drawing so you can have a >= 0 point of origin
What about just keeping the origin at [0 0]
and changing the skija drawCircle
call to use rad
as x and y
? because I did that and it seems to work
yea, as long as the origin >= [0,0]
thanks!