|
|
|
|
|
by mkl
1179 days ago
|
|
This looks great! I use Desmos and GeoGebra a lot for teaching, and things like implicit curves are often frustratingly slow with them. Can you explain a bit how KGraph works? Do you plan to open source it? (No judgement if not.) You can get maths notation input using MathQuill: http://mathquill.com/ (that's what Desmos uses) |
|
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...