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

214
Views
¿Cómo hago coincidir mi imagen de fondo con mi tamaño de lienzo establecido?

 const canvas = document.querySelector('canvas'); const c = canvas.getContext('2d') const CANVAS_WIDTH = canvas.width = 1024 const CANVAS_HEIGHT = canvas.height = 576 //fillRect() is a method of the 2d drawing context object. c.fillRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT) const gravity = 0.5 //adding the {} within () allows the values to operate without it having to be in order. const backgroundLayer1 = new Sprite({ position: { x: 0, y: 0 }, imageSrc: './img/background/background_layer_1.png', }) const backgroundLayer2 = new Sprite({ position: { x: 0, y: 0, }, imageSrc: './img/background/background_layer_2.png', }) const backgroundLayer3 = new Sprite({ position: { x: 0, y: 0 }, imageSrc: './img/background/background_layer_3.png', }) . . . function animate() { window.requestAnimationFrame(animate) c.fillStyle = "black" c.clearRect(0, 0, canvas.width, canvas.height) backgroundLayer1.update() backgroundLayer2.update() backgroundLayer3.update() }

El código anterior es solo la parte del código que cubre el BG. Aquí muestra el tamaño del lienzo y la imagen BG, pero cuando ejecuto el código, la imagen BG aparece pequeña solo en la esquina superior izquierda. Por favor, avíseme si necesito proporcionar más código si ayuda.

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!