--> Construction de la courbe d'une fonction Considérons la fonction $h$ définie sur $\mathbb{R}$ par : $h:t\longmapsto t^2$, et son tableau de valeurs suivants :
$t$ $-4$ $-3$ $-2$ $-1,5$ $-1$ $-0,5$ $0$ $0,5$ $1$ $1,5$ $2$ $3$ $4$
$h(t)$ $16$ $9$ $4$ $2,25$ $1$ $0,25$ $0$ $0,25$ $1$ $2,25$ $4$ $9$ $16$

function affiche(){ couleur = noir peinture = "#ffffff" transparence = 1 rectangle([-20,20],40,40) Xmin = -4.5 Xmax = 4.5 Ymin = -1 Ymax = 16.5 traceG() traceX() traceY() segment([1,-0.2],[1,0.2]) segment([-0.1,1],[0.1,1]) texte("0",[-0.3,-0.7]) texte("1",[0.9,-0.8]) texte("1",[-0.4,0.8]) } affiche() n = 0 L = [-4,-3,-2,-1.5,-1,-0.5,0,0.5,1,1.5,2,3,4] var btn = document.createElement("BUTTON"); btn.innerHTML = "Cliquer"; document.getElementById('addB').appendChild(btn); btn.addEventListener ("click", function() { function f(t){ return t*t; } if ( n == 14 ){ affiche() n = 0 } if( n == 13 ){ graphe(f,-4.5,4.5); n++ document.getElementById("t12").style.backgroundColor = "rgba(255,0,0,0)"; document.getElementById("s12").style.backgroundColor = "rgba(255,0,0,0)"; } if( n < 13){ couleur = rouge ptc(L[n]); colore(n) n++ } }); function ptc(x){ point([x,x*x]); } function colore(n){ for(var k = 0; k < 13; k++){ document.getElementById("t"+k).style.backgroundColor = "rgba(255,0,0,0)"; document.getElementById("s"+k).style.backgroundColor = "rgba(255,0,0,0)"; } document.getElementById("t"+n).style.backgroundColor = "rgba(255,0,0,0.3)"; document.getElementById("s"+n).style.backgroundColor = "rgba(255,0,0,0.3)"; }