Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7759345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:36:15+00:00 2026-06-01T13:36:15+00:00

So, I create a few images like this: images = []; images[0] = new

  • 0

So, I create a few images like this:

images = [];

images[0] = new Image();
images[0].src = "bla.jpg";

images[1] = new Image();
images[1].src = "bla1.jpg";

images[2] = new Image();
images[2].src = "bla2.jpg";

This isn’t the actual loading algorithm, but the product is the same: I’m left with an array called “images”, which, of course, contains a few images.

I’m making a game, and I need to resize the canvas, to fit the screen size of the player. I know how to do that, but now, I need to resize all of the images as well. I don’t know how to do that.

My initial approach was this:

for (var i = 0; i < images.length; i ++)
{
    images[i].width *= ratio; // newWidth/defaultWidth
    images[i].height *= ratio;
}

I didn’t notice a change, though, so I did this, just to be sure:

for (var i = 0; i < images.length; i ++)
{
    images[i].width = 3; //I'd probably notice if every image in the game was shrunk to this size
    images[i].height = 3;
}

This was even stranger. The images, again, remained unchanged, however, the game slowed a lot. The FPS went down to 0.5 or something similar.

Now, how do I go about resizing images?

EDIT: I do not, of course, wish to resize the images in real time like this:

context.drawImage(image, x, y, image.w*r, image.h*r);

Because in my experience, it greatly reduces the performance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:36:17+00:00Added an answer on June 1, 2026 at 1:36 pm

    Instead of setting width & height attributes, set the css properties instead:

    var i, image;
    for ( i = 0; i < images.length; i++ )
    {
        image = $( images[i] );
        image.css( 'width', image.width() * ratio );
        image.css( 'height', image.height() * ratio );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have few question in this regard When you create an internet page, does
I am new to programming on the Android and would like to create an
I have to create a few functions for a website that will get a
We are planning to create a few javascript widgets which will be served to
I'm trying to learn JavaFX and maybe create a few learner games. I always
In the spirit of re-using code, I'm trying to create a few library projects.
I have a module that is being used to create only a few page
I created few user defined types in my database as below CREATE TYPE [dbo].[StringID]
I know there are a few workarounds to create an always visible bottom menu
I'm working on a few scripts to create txt files, rsync a few files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.