Skip to content

Commit 5f8cfc8

Browse files
author
Stefan Fenn
committed
simplified examples
1 parent e73cd88 commit 5f8cfc8

3 files changed

Lines changed: 5 additions & 13 deletions

File tree

exampleFunction2d.html

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,17 @@
2020
import {drawGrid, drawFunction} from './graphplot.js';
2121

2222
const canvas = document.getElementById("grid");
23-
const ctx = canvas.getContext("2d");
24-
2523
const config = {
2624
xMin: -3,
2725
xMax: 5,
2826
yMin: -1,
2927
yMax: 2,
30-
ctx: ctx
28+
ctx: canvas.getContext("2d")
3129
};
3230

3331
const canvasF2 = document.getElementById("fn2");
34-
const ctxF2 = canvasF2.getContext("2d");
3532
const configF2 = Object.assign({}, config);
36-
configF2.ctx = ctxF2;
33+
configF2.ctx = canvasF2.getContext("2d");
3734

3835
drawGrid(config);
3936
drawFunction(

exampleFunction3d.html

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,17 @@
2020
import {drawGrid, getGradientVector, draw3dFunction} from './graphplot.js';
2121

2222
const canvas = document.getElementById("grid");
23-
const ctx = canvas.getContext("2d");
24-
2523
const config = {
2624
xMin: -3,
2725
xMax: 5,
2826
yMin: -1,
2927
yMax: 2,
30-
ctx: ctx
28+
ctx: canvas.getContext("2d")
3129
};
3230

3331
const canvasF3 = document.getElementById("fn3");
34-
const ctxF3 = canvasF3.getContext("2d");
3532
const configF3 = Object.assign({}, config);
36-
configF3.ctx = ctxF3;
33+
configF3.ctx = canvasF3.getContext("2d");
3734

3835
const func3 = function (x, y) {
3936
return Math.sin(x * 2) * y + Math.cos(y * 5) * x;

exampleGrid1.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@
55
import {drawGrid} from './graphplot.js';
66

77
const canvas = document.getElementById("grid");
8-
const ctx = canvas.getContext("2d");
9-
108
const config = {
119
xMin: -3,
1210
xMax: 5,
1311
yMin: -1,
1412
yMax: 2,
15-
ctx: ctx
13+
ctx: canvas.getContext("2d")
1614
};
1715

1816
drawGrid(config);

0 commit comments

Comments
 (0)