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

  • SEARCH
  • Home
  • 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 6346141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:57:37+00:00 2026-05-24T20:57:37+00:00

What is best practice? Should I make a separate canvas tag for each image

  • 0

What is best practice? Should I make a separate canvas tag for each image in html5, or is it just as functional to put multiple images in one canvas, and how would I do that.

My Code so far:

var canvas = document.getElementById("e");
var context = canvas.getContext("2d");

var cat = new Image();
cat.src = "images/cartoonPaul01.jpg";
cat.onload = function() {
    context.drawImage(cat, 0, 0, 169, 207);
};
  • 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-05-24T20:57:38+00:00Added an answer on May 24, 2026 at 8:57 pm

    You can do this dynamically, if you’re so inclined. muro from deviant art uses a few base canvases – temp, buffer, and background. Then you dynamically create and delete layers using a control on the side. It depends largely on what you want to do.

    If you are just printing to the canvas, and you don’t need to necessarily alter the images in a way that needs dynamism, you can draw them all to one canvas. If you need layering, use it.

    Dynamic canvas and context creation:

    // This is not best practice, just an example using globals.
    var layers = [];
    var lyrCtx = [];
    
    createLayer = function() {
      // Create the canvas.
      layers.push(document.createElement('canvas'));
      layers[layers.length - 1].setAttribute('id', 'layer'+layers.length-1);
    
      // Create the context. Provided you do it in order, lyrCtx[i] should correlate to layers[i]
      lyrCtx.push(layers[layers.length - 1].getContext("2d"));
    
      // Handle context settings here.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a security best practice and I'm wondering if I should even be
What is the best practice? How should I implement it so that the database
What’s the best practice when returning something from a routine? Should I return a
What's the best practice for dealing with objects in for or foreach loops? Should
I've got a design decision to make and am looking for some best practice
Should you make one request/response object for each method or should you have one
what is the best practice for serving images from a different sub-domain(like media.host.com) in
What best practices should be observed when implementing HDL code? What are the commonalities
Are there any guidelines/best practices for deciding what type of data should be stored
What are the best practices for dealing with Things that should be hashed. i.e.

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.