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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:17:19+00:00 2026-05-23T22:17:19+00:00

Im am currently using LibCanvas to do canvas drawing in my html page, but

  • 0

Im am currently using LibCanvas to do canvas drawing in my html page, but I can’t seem to figure out how to draw an image. Can anyone help me with this?

http://libcanvas.github.com/

EDIT: I am currently using this piece code, I see the image being drawn but then it dissapears;

var libcanvas = new LibCanvas('canvas', { preloadImages: false }).start();

var img = new Image();
img.src = 'images/draw.png';
img.width = 400;
img.height = 400;

libcanvas.addEvent('ready', function()
{
   libcanvas.ctx.drawImage(img);
});
  • 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-23T22:17:19+00:00Added an answer on May 23, 2026 at 10:17 pm

    It depends on your aim.
    If you just want to draw image – you can use plain context, without creating LibCanvas object:

    var img = atom.dom.create( 'img', { src: 'images/draw.png' })
        .bind( 'load', function () {
            atom.dom( 'canvas' ).first
                .getContext( '2d-libcanvas' )
                .drawImage( img );
        });
    

    Your image dissapears because you draw it not in frame. So, second way – is to draw it in “render” part:

    new LibCanvas('canvas', {
        preloadImages: { foo: 'images/draw.png' }
    }).start(function () {
        this.ctx.drawImage( this.getImage('foo') );
    });
    

    The right way if you try to create big app – is creating special object:

    LibCanvas.extract();
    
    var ImageDrawer = atom.Class({
        Extends: DrawableSprite,
    
        initialize: function (sprite, shape) {
            this.sprite = sprite;
            this.shape  = shape;
        }
    });
    
    new LibCanvas('canvas', {
        preloadImages: { foo: 'images/draw.png' }
    })
    .start()
    .addEvent('ready', function () {
        var drawTo = new Rectangle( 0, 0, 100, 100 );
        var drawer = new ImageDrawer( this.getImage('foo'), drawTo );
        this.addElement( drawer );
    });
    

    In such way you can easy make it, e.g. draggable:

    LibCanvas.extract();
    
    var ImageDrawer = atom.Class({
        Extends: DrawableSprite,
    
        Implements: [ Draggable ],
    
        initialize: function (sprite, shape) {
            this.sprite = sprite;
            this.shape  = shape;
        }
    });
    
    new LibCanvas('canvas', {
        preloadImages: { foo: 'images/draw.png' }
    })
    .start()
    .addEvent('ready', function () {
        var drawTo = new Rectangle( 0, 0, 100, 100 );
        var drawer = new ImageDrawer( this.getImage('foo'), drawTo );
        this.addElement( drawer );
        drawer.draggable();
    });
    

    For answers about LibCanvas you can write to me, shocksilien@gmail.com

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

Sidebar

Related Questions

Currently using: @^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?$ How can i make http:// not compulsory but if it does
Currently using Google Analytics as a supplement to our paid tracking software, but neither
I'm currently using the awesome attachment-fu plugin for a Rails app, but as a
currently using spring 'exposedContextBeanNames' to allow me to display properties in my view but
Currently using ColdFusion 8 enterprise on 32 bit linux box to send out our
Im currently using jquery to link all td's to the edit link but i
Currently using wxHTML to display a remote web page in a C++ Windows wxWidgets
I am currently using a datareader as the source but I want to instead
I currently using jquery in my website but when i try to open this
Currently using HtmlUnit. Getting first login page is no problem, succesfully logging in, getting

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.