Page 1 of 1

Displaying part of one image using a canvas

PostPosted: Wed Dec 01, 2010 12:43 am
by BloodRedDragon
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

Re: Displaying part of one image using a canvas

PostPosted: Wed Dec 01, 2010 1:40 am
by DarkParadox
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.

Re: Displaying part of one image using a canvas

PostPosted: Thu Jan 20, 2011 11:06 am
by BloodRedDragon
That works fine, but how would you move the image around (Like scrolling) whilst the canvas is in the same place? :idea: