Navigation menu

WoW:SetTexCoord Transformations: Difference between revisions

Jump to navigation Jump to search
m
Robot: converting/fixing HTML
(Slight error in the example function. If used as-is it won't do what you expect.)
m (Robot: converting/fixing HTML)
Line 9: Line 9:


== The Screen ==
== The Screen ==
The screen is used to refer to what the user sees, it may go by various different names in some graphics systems (canvas, surface, etc), but here we'll just call it the screen.  The term <b>Screen Coordinate</b> is used to specify a point on the screen (In WoW the origin is in the bottom left hand corner).
The screen is used to refer to what the user sees, it may go by various different names in some graphics systems (canvas, surface, etc), but here we'll just call it the screen.  The term '''Screen Coordinate''' is used to specify a point on the screen (In WoW the origin is in the bottom left hand corner).


== Texture Frame Elements ==
== Texture Frame Elements ==
In order to display all part of an image, we use a Texture frame element, which appears as a rectangular area on the screen with vertical and horizontal edges, just like any other Frame. A Texture frame element can have an arbitrary location, size, and scale. Within the rectangle of the Texture, we'll use the term <b>Texture Frame Coordinate</b> to refer to the location within that rectangle where (0,0) is the bottom left corner, (1,0) is the bottom right corner, (0,1) is the top left corner, and (1,1) is the top right corner. Texture will always have an initial capital, for consistency with the element name in the API. Each screen coordinate within the bounds of the Texture on screen can be mapped into a Texture frame coordinate within the box from (0,0) to (1,1).
In order to display all part of an image, we use a Texture frame element, which appears as a rectangular area on the screen with vertical and horizontal edges, just like any other Frame. A Texture frame element can have an arbitrary location, size, and scale. Within the rectangle of the Texture, we'll use the term '''Texture Frame Coordinate''' to refer to the location within that rectangle where (0,0) is the bottom left corner, (1,0) is the bottom right corner, (0,1) is the top left corner, and (1,1) is the top right corner. Texture will always have an initial capital, for consistency with the element name in the API. Each screen coordinate within the bounds of the Texture on screen can be mapped into a Texture frame coordinate within the box from (0,0) to (1,1).


== The Image ==
== The Image ==
Texture frame elements display images, these are generally loaded from files and are specified with a path. The WoW UI engine handles various different sizes of images, as long as each side is a power of 2 (64x64, 256x256, 512x128, etc). Within an image, we'll use the term <b>Image Coordinate</b> to refer to the location within the contents of the image. The corners are (0,0) for the <b>top</b> left, (1,0) for the <b>top</b> right, (0,1) for the <b>bottom</b> left, and (1,1) for the <b>bottom</b> right. Notice that the image origin is in a different corner from the screen origin.
Texture frame elements display images, these are generally loaded from files and are specified with a path. The WoW UI engine handles various different sizes of images, as long as each side is a power of 2 (64x64, 256x256, 512x128, etc). Within an image, we'll use the term '''Image Coordinate''' to refer to the location within the contents of the image. The corners are (0,0) for the '''top''' left, (1,0) for the '''top''' right, (0,1) for the '''bottom''' left, and (1,1) for the '''bottom''' right. Notice that the image origin is in a different corner from the screen origin.


While image coordinate box from (0,0) to (1,1) contains the whole image as it appears in its source file, the image logically extends to infinity in each direction, by repeating the edge pixel of the image file. So, if your image has a left edge which is entirely blue pixels, then there would be blue at (x, 0.5) for all x &lt;= 0. Similarly, if the image has a top edge that is transparent, then you'll get transparency at (0.5, y) for all y &gt;= 1.
While image coordinate box from (0,0) to (1,1) contains the whole image as it appears in its source file, the image logically extends to infinity in each direction, by repeating the edge pixel of the image file. So, if your image has a left edge which is entirely blue pixels, then there would be blue at (x, 0.5) for all x &lt;= 0. Similarly, if the image has a top edge that is transparent, then you'll get transparency at (0.5, y) for all y &gt;= 1.
Line 30: Line 30:


==Overview==
==Overview==
The way in which the image coordinates map to Texture frame coordinates, and then onto Screen Coordinates (or vice versa) is through a series of <b>Affine Transformations</b>, these are transformations which preserve linearity (points which lay on a line before the transformation, continue to lay on a line after it), and distance ratios (the ratio of distance between two pairs of points on a line before the transformation remain the same afterwards). In the 2D world affine transformations are any combination of:
The way in which the image coordinates map to Texture frame coordinates, and then onto Screen Coordinates (or vice versa) is through a series of '''Affine Transformations''', these are transformations which preserve linearity (points which lay on a line before the transformation, continue to lay on a line after it), and distance ratios (the ratio of distance between two pairs of points on a line before the transformation remain the same afterwards). In the 2D world affine transformations are any combination of:


* Translation (Moving things relative to the origin)
* Translation (Moving things relative to the origin)
Anonymous user