123456789101112131415161718192021222324252627282930 |
- document.getElementsByName("func_expr")[0].addEventListener("keydown", keydownhandler);
- document.getElementsByName("func_expr")[0].focus();
- var plot = new Fooplot(document.getElementsByName("plot")[0]);
- function keydownhandler(e){
- switch (e.key){
- case "Enter":
- draw_func();
- break;
- case "SoftLeft":
- plot.deleteAllPlots();
- plot.reDraw();
- break;
- case "":
- }
- }
- function draw_x2(){
- plot = new Fooplot(document.getElementsByName("plot")[0]);
- plot.addPlot('x^2', FOOPLOT_TYPE_FUNCTION, {'color': '#ff0000'});
- plot.reDraw();
- }
- function draw_func(){
- var func_expr = document.getElementsByName("func_expr")[0].value;
- var colors = ["green", "red", "blue", "purple", "black", "orange",
- "yellow"];
- var color = colors[Math.floor(Math.random() * colors.length)];
- plot.addPlot(func_expr, null,{"color": color});
- plot.reDraw();
- }
|