SetLayerAnchor(id, ax, ay)
The anchor point can be any point inside the layer ranging from 0.0/0.0 (top left corner of the layer) to 1.0/1.0 (bottom right corner of the layer). The center of the layer would be defined by an anchor point of 0.5/0.5.
For example, if you want to have a layer that shall be rotated around its center point, then you need to set this layer's anchor point to 0.5/ 0.5. If it shall be rotated around its top left corner, you have to use 0.0/0.0 as the anchor point. To rotate around the layer's bottom right corner, use 1.0/1.0 as the anchor point. The usual setting is to rotate around the center, so you should normally set the anchor point to 0.5/0.5.
When using an anchor point different than 0.0/0.0, keep in mind that all position specifications will be relative to the anchor point now. This means that a position of 0:0 does not necessarily mean that the layer will appear at the top-left display corner. For example, if you have a layer with an anchor point of 1.0/1.0, moving this layer to position 0:0 (top left corner of display) would make the layer pretty much invisible because its anchor point is set to the bottom-right corner of the layer. Thus, if you move a layer with a bottom-right anchor point to position 0:0, it means that the bottom-right corner of the layer will actually appear at 0:0. This obviously means that only a single pixel of the layer will be visible. The rest will be off-screen.
By default, all layers will use an anchor point of 0.0/0.0.
EnableLayers SetFillStyle(#FILLCOLOR) Box(300, 200, 300, 200, #RED) WaitLeftMouse SetLayerAnchor(1, 0.5, 0.5) WaitLeftMouse SetLayerAnchor(1, 1.0, 1.0) WaitLeftMouseThe code above demonstrates three different anchor points: First, at 0.0/0.0, then at 0.5/0.5, finally at 1.0/1.0. You can see that the layer will move with every call to
SetLayerAnchor(). That is because the position of a layer is always relative to its anchor point. Thus, the layer will move although its position will always be 300:200.