INT center_set ( <INT FileID> , <INT GraphID> , <INT x> , <INT y>)
Allows you to change the center of a graphic.
This function changes a graphic's center pixel, which is the pixel that is located on screen at the graph's x and y coordinates. So changing this will influence the position on the screen.
The previous name set_center() is deprecated.
|INT FileID||- The FileID of the file containing the graphic|
|INT GraphID||- The GraphID of the graphic to change the center of.|
|INT x||- The new horizontal center coordinate of the graphic.|
|INT y||- The new vertical center coordinate of the graphic.|
INT : Successrate
|-1||- Specified graphic is invalid.|
|1||- The center was set successfully.|
You set the position of control point 0 in the graphic. This control point acts as the graphic's coordinate on screen. For example, if a graphic's center is set to 0,0 , then the upper left pixel of the graphic will be placed on screen at the graphic's coordinates. If no center is set, by default control point 0 is set to the graphics true geometric center.
Another key feature is that the graphic will rotate around its center, as set by this function, and any horizontal or vertical mirrors (set with flags) will flip at this point.
When a graphic is used as a mouse pointer, its center point is used for the mouse tip. Most mouse cursors in Operating Systems have a mouse with the tip in the upper left of the image. Therefore, for a standard mouse pointer in Bennu, you will have to set the center at 0,0 to enable mouse accuracy.
import "mod_map" import "mod_text" import "mod_key" Process Main() Begin graph=png_load("set_center.png"); //Loads a 128x128 image as the graphic x=160; y=100; //Places the graphic in the centre of the screen write(0,0,0,0,"Press  to set center to 0,0"); write(0,0,0,10,"Press  to set center to 64,64"); Loop if(key(_1)) center_set(0,graph,0,0); end if(key(_2)) center_set(0,graph,64,64); end angle+=100; //Rotates the graphic constantly frame; End End
File(s) used in example: set_center.png