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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:39:39+00:00 2026-06-05T08:39:39+00:00

A while back webkit (and thus Safari) began to support CSS canvas-backgrounds for elements

  • 0

A while back webkit (and thus Safari) began to support CSS canvas-backgrounds for elements (Source: http://www.webkit.org/blog/176/css-canvas-drawing/).

This could greatly simplify the creation of games and multimedia, in that you dont need to inject a canvas-tag into a DIV (for instance), but simply hook into the background of the DIV directly. Something like this perhaps:

<div id="gameview"
style="background: -webkit-canvas(myscreen); width: 320px; height: 480px;">
</div>

<script>
    var target = document.getElementById("gameview");
    var wd = target.clientWidth;
    var hd = target.clientHeight;
    var context =  document.getCSSCanvasContext("2d", "myscreen", wd, hd);
    /* draw stuff here */
</script>

I was wondering, are there any speed penalties involved in this? In theory i think drawing to a background canvas should be faster than drawing to a canvas tag, especially if the target element is empty.

Have anyone tested this for high-speed demos or games?

  • 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-05T08:39:40+00:00Added an answer on June 5, 2026 at 8:39 am
    test.php:11Regular Canvas 606
    test.php:20Background Canvas 449
    test.php:11Regular Canvas 516
    test.php:20Background Canvas 483
    

    Regular seems to underperform compared to background canvas in my tests on chrome in linux debian, heres the code used ( also added to http://jsfiddle.net/hDPVr/ )

    <div style="width:300; height:200; background: -webkit-canvas(test_canvas); "></div>
    <canvas id="canvas" style="width:300; height:200;"></div>
    
    <script type="text/javascript">
        var canvas = document.getElementById('canvas');
        var context = canvas.getContext('2d');
        var regular_timer = new Date().getTime() ;
        for( var i = 0; i<100000; i++ ){
        context.fillRect( 0,0,10,10);
        }
        console.log( 'Regular Canvas', regular_timer - (new Date().getTime()) )
    
    
    
        var context = document.getCSSCanvasContext('2d', 'test_canvas', 300, 200); 
        var background_timer = new Date().getTime() ;
        for( var i = 0; i<100000; i++ ){
        context.fillRect( 0,0,10,10);
        }
        console.log( 'Background Canvas', background_timer - (new Date().getTime()) )
    
    </script>
    

    So the only thing that I did for testing is fillRect, but it’s still at least 10% better in some cases

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

Sidebar

Related Questions

(A while back I read this great post: http://aaronlongwell.com/2009/06/the-ruby-on-rails-cms-dilemma.html , discussing the Rails CMS
A while back i read somewhere about how to improve upon the MVC pattern
A while back a found a great-looking framework that allowed .net developers to implement
A while back, smart clients had been touted as the solution to occasional connected
A while back I wrote a simple python program to brute-force the single solution
A while back I created a lightbox plugin using jQuery that would load a
a while back, CNET had these really cool Social Share buttons, that when you
A while back I was playing with methods using variable-length argument lists (java) that
I remember a while back reading about editing the proxy pac file which would
I little while back I posted this question . I have updated that question

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.