PPI of Canvas

You must understand the Game Editor concepts, before post here.

PPI of Canvas

Postby EvanAgain » Tue Jan 22, 2013 8:04 pm

Now I might be answering my own question with this but I don't really understand how it works and how the canvas "knows" how many pixels to have and how to do it. I imagine its like other painting programs but I can't be sure.


So, as in the subject, How do you get the PPI of canvas? Also, how can I get EXACT measurements of canvas for drawing objects within? I imagine this are just simple math equations...
EvanAgain
 
Posts: 51
Joined: Thu Jan 10, 2013 5:40 pm
Score: 4 Give a positive score

Re: PPI of Canvas

Postby skydereign » Tue Jan 22, 2013 10:37 pm

The pixel size for the canvas is exactly that of everything else in the game (it is 1 to 1). Just try it out with as simple canvas.
Code: Select all
setpen(255, 255, 255, 0, 1); // pen now has a size of 1
putpixel(width/2, height/2); // uses the pen on specified point (middle of the canvas)

setpen(255, 0, 0, 0, 10); // now size 10 and red
putpixel(width/2+20, height/2);

You'll notice from the above, the canvas is using relative coordinates to itself. Where (width-1, height-1) is the bottom right, and (0, 0) is the top left.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: PPI of Canvas

Postby EvanAgain » Tue Jan 22, 2013 11:15 pm

Ok so it is based on the screen resolution that you specify in Config settings?

I am working with the canvas and I have a series of canvas questions now because the scripting reference doesn't really specify the things I am trying to do. But I am not quite sure of the question as of yet, because I am still playing with it and trying to discover it on my own.

Yet though, how to I get the coordinates of an Actor to be used to draw onto the Canvas.

Say:

I am dragging and dropping an Actor around the canvas and I want the canvas to draw the Actor at the exact position of where I dropped it.

Now I have done this using an Activation Event, although it requires the Signal come from a specified clone rather than any Actor with the same name. With this method I wouldn't be able to destroy the Actor. Which IS something I (may or may not) need to do.

Specifically, what method would I use to convert the Actor's screen coordinates into Canvas Coordinates.


I, also, was trying to draw a box on the Canvas (around) the coordinates of a Filled Region. Using this:

Filled Region with name myActor.

Code: Select all
setpen(255, 0, 0, 0.0, 3);
moveto(myActor.x - myActor.width/2 , myActor.y - myActor.height/2);

lineto (myActor.x + myActor.width/2 , myActor.y - myActor.height/2);
lineto (myActor.x + myActor.width/2 , myActor.y + myActor.height/2);
lineto (myActor.x - myActor.width/2 , myActor.y + myActor.height/2);
lineto (myActor.x - myActor.width/2 , myActor.y - myActor.height/2);




But, nothing was draw to the Canvas.
EvanAgain
 
Posts: 51
Joined: Thu Jan 10, 2013 5:40 pm
Score: 4 Give a positive score

Re: PPI of Canvas

Postby skydereign » Tue Jan 22, 2013 11:21 pm

EvanAgain wrote:Specifically, what method would I use to convert the Actor's screen coordinates into Canvas Coordinates.

This is just like when an actor is parented to another. It is usually a good idea to find the offset using screen variables, that way you don't run into any parenting position problems.
Code: Select all
int r_x = myActor.xscreen-xscreen;


EvanAgain wrote:I, also, was trying to draw a box on the Canvas (around) the coordinates of a Filled Region. Using this:

Filled Region with name myActor.

Another thing to remember is the filled region coordinates are based off of the top left position, not the center like normal actors.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: PPI of Canvas

Postby EvanAgain » Wed Jan 23, 2013 12:22 am

Thank you, Thank you!

I didn't know about either of those subjects until you said them just now.
EvanAgain
 
Posts: 51
Joined: Thu Jan 10, 2013 5:40 pm
Score: 4 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron