CoordinateSystem

From Gnash Project Wiki

Jump to: navigation, search

Coordinates encoded in an SWF movie are expressed in TWIPS, which are 1/20 of a PIXEL when the movie is rendered at 100% scale.

As movies are scaled up or down, scale factor of a rendered PIXEL change, but ActionScript "view" of it is always 20*TWIP. In other words, if you define a 128x128 pixel square, it's width will always be 128 when fetched by ActionScript, no matter the actual size the square is rendered to screen or buffer.

Stage Coordinate System

The Stage Coordinate System is the coordinate system used internally by the core lib. It matches with the system used to define the SWF. It is completely independent of the actual gui/renderer coordinate space. Every output from the core lib (calls to the renderer) is expressed in this system. Every input to the core lib is expected in this system.

Since the Stage Coordinate System natively uses TWIPS as units, it is likely clean to expect all input and give all output in TWIPS as well.

NOTE: ActionScript 'view' of the Stage Coordinate System always uses a pseudo-pixel unit, which is always 20 TWIPS in size, no matter renderer/gui scaling. This is true for any view of dimensions: _x,_y,_width,_height and the like; including Stage.width and Stage.height.

GUI Coordinate System

The GUI Coordinate System is space of user input/output. This is tipically a window with pixel units. User moves the mouse on pixel boundaries and sees a pixel-accurate rendering.

In initial conditions (assuming the window could be created with stage size in pseudo-pixels). The origin of gui-coordinate space would match origin of the stage-coordinate space, and size of a user-pixel would match size of a stage-pseudopixel.

The hosting application (tipically a Gui) should be responsible to convert gui-coordinates to stage-coordinates when notifying mouse events and stage-coordinates to gui(or better, renderer)-coordinates when rendering.