Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-01-2012, 09:44 PM   PM User | #1
verminousdan
New to the CF scene

 
Join Date: Oct 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
verminousdan is an unknown quantity at this point
Help with a programming problem for Uni

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.
verminousdan is offline   Reply With Quote
Old 10-02-2012, 12:19 AM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
This isn't java code: var myImage = new Image();. Var isn't a valid datatype in Java, although myImage.drawImage would be a valid method call (assuming that myImage is of type java.awt.Graphics or a subclass).
Are you sure this isn't meant to be in the Javascript forum?
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:48 PM.


Advertisement
Log in to turn off these ads.