Center set

From Bennu Wiki
Jump to: navigation, search


Definition

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.

Parameters

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.

Returns

INT : Successrate

-1 - Specified graphic is invalid.
1 - The center was set successfully.

Notes

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.

Example

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 [1] to set center to 0,0");
    write(0,0,0,10,"Press [2] 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

Used in example: graph, png_load(), key(), write(), center_set()

File(s) used in example: set_center.png


Mod_map
Globals None
Imported:
FullscreenGraphmodeM7ScalemodeScaleresolutionScaleresolutionaspectratioScaleresolutionorientation
Constants BCLEARCHARSETCP850CHARSETISO8859GANIMATIONSPEEDGANIMATIONSTEPGANIMATIONSTEPSGCENTERXGCENTERYGDEPTHGFRAMESGHEIGHTGPITCHGWIDEGWIDTHGXCENTERGYCENTERNFBFIXEDWIDTHNFBVARIABLEWIDTH
Imported:
BABLENDBALPHABHMIRRORBNOCOLORKEYBSBLENDBTRANSLUCENTBVMIRRORDOUBLEBUFFERHWSURFACEM1024X768M1280X1024M320X200M320X240M320X400M360X240M376X282M400X300M512X384M640X400M640X480M800X600MODE16BITSMODE16BPPMODE2XSCALEMODE8BITSMODE8BPPMODEDOUBLEBUFFERMODEFRAMELESSMODEFULLSCREENMODEHARDWAREMODEMODALMODEWAITVSYNCMODEWINDOW
Functions Bdfload()Centerset()Colorfind()Colorsget()Colorsset()Fade()Fadeoff()Fadeon()Fntload()Fntnew()Fntsave()Fntunload()Fpgadd()Fpgdel()Fpgexists()Fpgload()Fpgnew()Fpgsave()Fpgunload()Getpixel()Glyphget()Glyphset()Graphicinfo()Graphicset()Mapblockcopy()Mapbuffer()Mapclear()Mapclone()Mapdel()Mapexists()Mapgetpixel()Mapinfo()Mapinfoget()Mapinfoset()Mapload()Mapname()Mapnew()Mapput()Mapputpixel()Mapsave()Mapsetname()Mapunload()Mapxput()Mapxputnp()Palclone()Paldel()Palget()Palload()Palmapassign()Palmapgetid()Palmapremove()Palnew()Palrefresh()Palsave()Palset()Palunload()Paletteconvert()Paletteroll()Pcxload()Pngload()Pngsave()Pointget()Pointset()Putpixel()Rgb()Rgbget()Rgba()Rgbaget()