top | item 35325344

(no title)

kaapipo | 2 years ago

Thanks for your feedback!

Sure! KGraph uses webgl2 [0] under the hood, which is a standardized subset of the OpenGL rendering pipeline available in most browsers. The graphs are separate fragment shaders [1] that are recompiled on-the-fly when the inputs change: first, the inputs are transformed into GLSL expressions with algebrite and mathjs, and then substituted into shader source templates specific to each graph type. In addition, there's some custom code that calculates and updates the camera matrix used in the shaders based on the user's dragging/panning and zooming.

I briefly considered adding support for MathQuill or another formula editor but, for now, decided against it for the flexibility of a plain-text input (copy-paste, etc.). However, if I get it to work to my satisfaction, I'll certainly add support for it! Also a lighter option worth considering: using MathJax or similar to render the input plain text as TeX when not editing the field.

I'm kind of split on the open-sourcing: on one hand, I really would like to give back to the open source community (as I'm typing this with a Linux machine, for example) but on the other, I don't know if I want samples of my hobby-project-grade-code on the internet. Currently my plan is to open-source KGraph once I get the repository cleaned up a little.

0: https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/T... 1: https://webglfundamentals.org/webgl/lessons/webgl-shaders-an...

discuss

order

mkl|2 years ago

Copy and paste actually works fine with MathQuill. It copies as Latex code, and accepts other Latex code pasted in (within its limitations).

Do you handle explicit and implicit plots differently, or treat everything as implicit?

kaapipo|2 years ago

But what if the user wants to paste non-latex code? But yes, I agree that it would have benefits.

Explicit functions are turned into implicit ones by rearranging (and adding a `y = ` to the beginning if necessary). This way the shader code is the same