Displaying part of one image using a canvas

Non-platform specific questions.

Displaying part of one image using a canvas

Postby BloodRedDragon » Wed Dec 01, 2010 12:43 am

Hi,
Is there a way to display a section of an image that is the same size as the canvas itself? For example, if you were to have two actors, one is an image, the other a canvas, if you made the canvas much smaller than the image, could you get rid of everything outside the canvas without adding any extra actors?
Thanks :P
Current projects:
Techno-Tank Arena: on hold
Techno-Tank SuperPortal (working title): 0.1%
Bowels of Galaxies: 35% (was a bit too optimistic)
User avatar
BloodRedDragon
 
Posts: 123
Joined: Tue Jan 29, 2008 10:07 pm
Location: The Underworld
Score: 5 Give a positive score

Re: Displaying part of one image using a canvas

Postby DarkParadox » Wed Dec 01, 2010 1:40 am

It would be a matter of doing this:
Resize the canvas to the size of the image you want left-over;
Put in the following code [with corresponding modifications]:
Code: Select all
draw_from("actor_name", actorname.width/2, actorname.height/2, 1);
// replace 'actor_name' with the actors name.
// the two after the name are x & y drawing positions,
//     It's currently drawing the top left corner of the image, at the top left of the canvas
//     add -20 or however much to the end of each to draw further into the image
// 1 is the scale of the image, sizing it up and down... for this you
//     shouldn't bother modifying it.

e.g.,
Code: Select all
draw_from("a_image", a_image.width/2 -40, a_image.height/2 -40, 1);
// Will draw the actor a_image 40 pixels in.
// For example, my avatar is 80x80 pixels, so this would only draw the bottom right corner
// if it was "a_image.width/2 -40, a_image.height/2" it would draw the right half of my avatar.


I didn't explain this very well... so ask again with other specifics and I'll try again.
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

Re: Displaying part of one image using a canvas

Postby BloodRedDragon » Thu Jan 20, 2011 11:06 am

That works fine, but how would you move the image around (Like scrolling) whilst the canvas is in the same place? :idea:
Current projects:
Techno-Tank Arena: on hold
Techno-Tank SuperPortal (working title): 0.1%
Bowels of Galaxies: 35% (was a bit too optimistic)
User avatar
BloodRedDragon
 
Posts: 123
Joined: Tue Jan 29, 2008 10:07 pm
Location: The Underworld
Score: 5 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest