membrane

https://github.com/phronmophobic/membrane
2021-02-25T01:29:10.050600Z

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))]))

phronmophobic 2021-02-25T01:30:31.051700Z

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

2021-02-25T01:30:51.051900Z

Ah! that's probably it

phronmophobic 2021-02-25T01:32:59.053700Z

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

phronmophobic 2021-02-25T01:34:08.055Z

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

2021-02-25T01:34:34.055700Z

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

👍 1
phronmophobic 2021-02-25T01:35:05.056300Z

yea, as long as the origin >= [0,0]

2021-02-25T01:36:24.057300Z

thanks!