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 6224689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:42:53+00:00 2026-05-24T08:42:53+00:00

All of my canvas drawing functions start something like this: function drawMe(){ var canvas

  • 0

All of my canvas drawing functions start something like this:

function drawMe(){

    var canvas = document.getElementById('canvas-id');

    var ctx = null;

    ctx = canvas.getContext('2d');

    ...
}

However I now want to draw the same image on a (variable) number of canvases, is there some alternative to getElementById() (perhaps in jQuery?) which can be used to easily grab more than one at once?

Thanks!

Josh

  • 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-24T08:42:54+00:00Added an answer on May 24, 2026 at 8:42 am

    drawing to multiple canvases will be extremely inefficient, because rendering is one of most expensive operations you can do.

    what you want to do is to use buffer. you can simply draw from one canvas to another.

    var canvas1 = document.getElementById("canvas1");
    var canvas2 = document.getElementById("canvas2");
    
    var ctx1 = canvas1.getContext("2d");
    var ctx2 = canvas2.getContext("2d");
    
    ctx1.fillStyle = "black";
    ctx1.fillRect(10, 10, 10, 10);
    
    ctx2.drawImage(canvas1, 0, 0);
    

    here’s a fiddle.

    remember, you only need to call ctx.drawImage once – after you’re done with all drawing on first canvas.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to draw an image on HTML canvas: var mainCanvas = document.getElementById('mainCanvas');
I'm having an issue drawing to a canvas, I'm sure i'm missing something obvious
I'm new to HTML5 canvas drawing im trying to fill this shape: This is
Are all canvas tag dimensions in pixels? I am asking because I understood them
I have a JFrame with a menu bar and a canvas covering all the
All I want is to update an ListViewItem's text whithout seeing any flickering. This
All too often I want a WPF slider that behaves like the System.Windows.Forms.TrackBar of
I have a static image (a png) that I'm drawing on a canvas element
When drawing on a canvas in firefox, if you attempt to draw at or
I made a simple drawing app with HTML5 canvas. You click in two different

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.