#+title: Math triangle #+date: <2021-05-13 Thu> #+nocomments: t {status; this page isn't public} Like a painting student learning by copying masterpieces, I wanted to recreate [[https://acegikmo.com/trianglesolver/][Freya Holmer's math triangle widget]], originally posted on [[https://twitter.com/FreyaHolmer/status/1392571957221208070][twitter]]. (I made this based on the tweets, before the final version was published.) *Click on the edges and angles* to toggle them. #+begin_export html
$$a$$ $$b$$ $$c$$ $$A$$ $$B$$ $$C$$
#+end_export I knew how to use KaTeX \(\text{for typesetting}\), but I didn't know how to make it work inside an SVG diagram. I learned that == lets you put HTML inside SVG, and you can use KaTeX inside that HTML!. This seems like it'll come in handy for my projects. I need to investigate how font sizes work though, since that HTML is going to be in document scale and not the SVG's viewbox scale, right, I think. Minor notes about polish: 1. I made another line underneath the visible ones. It's black, and also accepts clicks. This is especially useful on mobile where you don't have precise positioning. I needed to place this underneath the text, whereas the visible lines are above the text. 2. I disabled pointer events on the text boxes by using =pointer-events: none=. 3. I changed the cursor while hovering over the clickable areas by using =cursor: pointer=. 4. I disabled user-selection of the text by using =user-select: none= on the foreignobject. This was because clicking fast can lead to selecting that text. 5. I also tried to stop the double click behavior by setting an =ondblclick= handler but I am not sure whether this had the intended effect. 6. I drew the angles by drawing a == with a clip region set to the triangle area. Source code: [[href:./index.org][index.org]] (html + javascript). #+begin_export html Created 13 May 2021;   Last modified: 14 May 2021 #+end_export