Page 1 of 1

PPI of Canvas

PostPosted: Tue Jan 22, 2013 8:04 pm
by EvanAgain
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...

Re: PPI of Canvas

PostPosted: Tue Jan 22, 2013 10:37 pm
by skydereign
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.

Re: PPI of Canvas

PostPosted: Tue Jan 22, 2013 11:15 pm
by EvanAgain
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.

Re: PPI of Canvas

PostPosted: Tue Jan 22, 2013 11:21 pm
by skydereign
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.

Re: PPI of Canvas

PostPosted: Wed Jan 23, 2013 12:22 am
by EvanAgain
Thank you, Thank you!

I didn't know about either of those subjects until you said them just now.