Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

150
Views
No se puede acceder a 'Agente' antes de la inicialización

Hola, es la primera vez que uso canvas con este tipo de código... no entiendo por qué ocurre el error, si pudiera ayudarme a saber por qué esto no funciona... dicen que no se pudo encontrar al agente al inicio de la lectura ... de todos modos está tratando todo el tiempo de tener una solución. pero me pasan horas a nada..

 const randomRange = (min,max) => { return Math.random() * (max - min) + min; } //code var c = document.getElementById("canvastarget"); var width = c.offsetWidth var height = c.offsetHeight var context = c.getContext("2d"); //content var numberofelements = 40 const agents = [] for (let index = 0; index < numberofelements; index++){ const x = randomRange(0, width) const y = randomRange(0, height) agents.push(new Agent(x, y)) } //classes class Point { constructor(x,y){ this.x = x this.y = y } } class Agent{ constructor(x, y) { this.pos = new Point(x,y) this.radius = 10 } draw(context) { context.fillStyle = "black" context.beginPath() context.arc(this.pos.x,this.pos.y,this.radius,0,Match.PI * 2); context.fill(); } }
 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <canvas id= canvastarget width = "1080px" height="1080px"></canvas> </body> </html>

¡El error no está claro para mí, es la primera vez que hago una clase!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!