This wiki is out of date, use the continuation of this wiki instead

Set center

From FenixWiki

Revision as of 14:07, 22 May 2007 by G105b (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search


Contents

Definition

INT set_center ( <INT FileID> , <INT GraphID> , <INT x> , <INT y>)

Allows you to change the centre pixel of a graph.

This function changes a graphic's centre pixel, which is the pixel that is located on screen at the graph's x and y coordinates.

Parameters

INT FileID - The FileID assigned to the archive.
INT GraphID - The GraphID who's centre to change.
INT x - The new horizontal centre coordinate of the graph.
INT y - The new vertical centre coordinate of the graph.

Returns

INT : Always returns 1 (?).

Notes

You set the position of control point 0 in the graphic. This control point gives acts as the graphic's coordinate on screen. For example, if a graphic's centre 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 centre is set, by default control point 0 is set to the graphics true geometric centre.

Another key feature is that the graphic will rotate around its centre, 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 centre 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 Fenix, you will have to set the centre at 0,0 to enable mouse acuracy.

Example

Program example;
Begin
    graph=load_png("example.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 [1] to set centre to 0,0");
    write(0,0,0,10,"Press [2] to set centre to 64,64");
    Loop
        if(key(_1))   
            set_center(0,graph,0,0);
        end
        if(key(_2))
            set_center(0,graph,64,64);
        end
        angle+=100;                      //Rotates the graphic constantly
        frame;
    End
End
Personal tools