Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2012
    Thanked 0 Times in 0 Posts

    Help with Uni question

    I have been given this exercise to complete for my Uni class, but am having great difficulty making it work.

    Find an image on the internet that you like and copy its URL.
    o Make sure it will fit in the dimensions of the canvas!
    • Put this code after you declare the context but before you do any drawing:
    var myImage = new Image();
    myImage.src = “###”
    // paste your URL instead of ###!
    • The first line declares a new image variable.
    • The second line fills the image variable with the contents of the image at the specified URL
    (this is called the source, and can either be an image on your computer or on the internet).
    • The image won’t display yet because even though it is in memory, it is not being drawn.
    • Try to figure out how to get the image displaying on the screen using the canvas
    drawImage command.
    • Once you have done this, create several different images on your hard drive and display
    them all at various locations on the canvas.

    i have tried adding a source file under the context variable, and before the actual drawing part, but nothing happens. I tried using myImage.drawImage for the drawing part but still ntohign happens. Can someone please help me.

  2. #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    London, England
    Thanked 2,699 Times in 2,675 Posts
    This forum is not a free coding service. As a general rule, the people helping out in this forum don't write code for others (especially code that appears to be for homework), but try to help with fixing code that doesn't work. You may perhaps get someone to write this script for you, but you'll be far more likely to get help if you have made a substantial effort and written some code yourself. Then someone here will almost certainly help you correct/improve your work.

    Have a look at https://developer.mozilla.org/en-US/...l/Using_images

    It is your responsibility to die() if necessary….. - PHP Manual
    Last edited by Philip M; 10-02-2012 at 09:29 AM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts