lonestar108 commited on
Commit
1618cd2
·
verified ·
1 Parent(s): 2707da8

script.js:105 Uncaught ReferenceError: magnets is not defined

Browse files

at drawField (script.js:105:13)
at resizeCanvas (script.js:26:9)
at HTMLDocument.<anonymous> (script.js:30:5)

Files changed (1) hide show
  1. script.js +4 -4
script.js CHANGED
@@ -101,9 +101,8 @@ function resizeCanvas() {
101
 
102
  for (let i = 0; i < steps; i++) {
103
  const angle = (i / steps) * Math.PI * 2;
104
-
105
- magnets.forEach(magnet => {
106
- let x = magnet.x * canvas.width + Math.cos(angle) * 30;
107
  let y = magnet.y * canvas.height + Math.sin(angle) * 30;
108
 
109
  ctx.beginPath();
@@ -112,7 +111,8 @@ function resizeCanvas() {
112
  for (let j = 0; j < lineSteps; j++) {
113
  // Calculate field direction at this point
114
  let fx = 0, fy = 0;
115
- components.magnets.forEach(m => {
 
116
  const dx = x - m.x * canvas.width;
117
  const dy = y - m.y * canvas.height;
118
  const distSq = dx * dx + dy * dy;
 
101
 
102
  for (let i = 0; i < steps; i++) {
103
  const angle = (i / steps) * Math.PI * 2;
104
+ components.magnets.forEach(magnet => {
105
+ let x = magnet.x * canvas.width + Math.cos(angle) * 30;
 
106
  let y = magnet.y * canvas.height + Math.sin(angle) * 30;
107
 
108
  ctx.beginPath();
 
111
  for (let j = 0; j < lineSteps; j++) {
112
  // Calculate field direction at this point
113
  let fx = 0, fy = 0;
114
+ components.
115
+ components.magnets.forEach(m => {
116
  const dx = x - m.x * canvas.width;
117
  const dy = y - m.y * canvas.height;
118
  const distSq = dx * dx + dy * dy;