Skip to content

dzuizz/graphide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GraphIDE

a graphing calculator in pure HTML/CSS/JS, no dependencies

live demo ↗

heart graph in graphide

Just type an equation, and watch those curves! Run it locally if you wish.

what it does

  • explicit functions - y=x^2, sin(x)/x, or just x^2 (the y = is optional)
  • inverse explicitx = y^2 - 3
  • implicit curvesx^2 + y^2 = 9, sin(x) = cos(y)
  • implicit multiplication2x, xy, 3sin(x), (x+1)(x-1)
  • 25+ functions — trig, inverse trig, hyperbolics, log / ln / log2, sqrt / cbrt, floor / ceil / round / trunc, min / max / hypot, sign, abs
  • supported constantspi, tau, e
  • graph multiple functions at once, to each their own colour
  • pan by dragging, zoom by scrolling (anchored at the cursor)

Conventions: log is base 10, ln is natural

design notes

why a 6px grid for marching squares? Cost is O(W·H/S²). At S=6 on a 1440×900 window that's ~36k evaluations per implicit curve per repaint, which stays at 60fps even while panning. S=3 looks slightly smoother but costs 4x as much. 6 is where it stopped feeling too laggy.

why redraw the whole canvas on every pan frame? Blitting the existing pixels and only recomputing the newly-exposed strip would be more optimal in most cases. However, i believe the complexity of its implementation is not worth it since a full repaint is only ~5ms at the current resolution.

running it

git clone https://github.com/dzuizz/graphide.git
cd graphide
open index.html          # or: python3 -m http.server

roadmap

  • polar coordinates — r = 2sin(3θ)
  • parametric curves
  • per-function domain restrictions — y = sqrt(x) {x > 0} (needs a real parser)
  • shareable URL state
  • inequality shading
  • trace / coordinate readout on hover

built by @dzuizz - dzuizz.com

Contributors

Languages