mgsLib  1.3
Mermaja's Graphic Screen. A simple C library to build Windows graphic applications from console programs.
Macros | Functions
mgsLib.h File Reference

Header file for the MGS Library. More...

Macros

#define mgsRGBColor(r, g, b)   ((((b)&0xFF)<<16)|(((g)&0xFF)<<8)|((r)&0xFF))
 Creates a RGB color from its R, G and B components. More...
 
#define mgsGetScreenInfo(s, p)   mgsGetScreenInfoAdvanced((s), (p), NULL);
 Gets position and size information for an screen or the desktop. More...
 
Macros to draw non bordered figures.

Non bordered versions of the functions to draw figures.

#define mgsRectangle(s, l, t, r, b, c)   mgsBorderedRectangle((s), (l), (t), (r), (b), (c), 0, -1)
 Non bordered version of the corresponding function.
 
#define mgsEllipse(s, x, y, h, v, c)   mgsBorderedEllipse((s), (x), (y), (h), (v), (c), 0, -1)
 Non bordered version of the corresponding function.
 
#define mgsRegPolygonCR(s, n, x, y, r, c)   mgsBorderedRegPolygonCR((s), (n), (x), (y), (r), (c), 0, -1)
 Non bordered version of the corresponding function.
 
#define mgsRegPolygonVC(s, n, x, y, a, b, c)   mgsBorderedRegPolygonVC((s), (n), (x), (y), (a), (b), (c), 0, -1)
 Non bordered version of the corresponding function.
 
#define mgsPolygon(s, n, v, c)   mgsBorderedPolygon((s), (n), (v), (c), 0, -1)
 Non bordered version of the corresponding function.
 
#define mgsStarCR(s, n, x, y, e, i, c)   mgsBorderedStarCR((s), (n), (x), (y), (e), (i), (c), 0, -1)
 Non bordered version of the corresponding function.
 
#define mgsStarVC(s, n, x, y, a, b, i, c)   mgsBorderedStarVC((s), (n), (x), (y), (a), (b), (i), (c), 0, -1)
 Non bordered version of the corresponding function.
 
#define mgsESector(s, x, y, h, v, i, e, c)   mgsBorderedESector((s), (x), (y), (h), (v), (i), (e), (c), 0, -1)
 Non bordered version of the corresponding function.
 
#define mgsESegment(s, x, y, h, v, i, e, c)   mgsBorderedESegment((s), (x), (y), (h), (v), (i), (e), (c), 0, -1)
 Non bordered version of the corresponding function.
 
#define mgsRotatedRectangle(s, l, t, r, b, a, c)   mgsRotatedBorderedRectangle((s), (l), (t), (r), (b), (a), (c), 0, -1)
 Non bordered version of the corresponding function.
 
#define mgsRotatedEllipse(s, x, y, h, v, a, c)   mgsRotatedBorderedEllipse((s), (x), (y), (h), (v), (a), (c), 0, -1)
 Non bordered version of the corresponding function.
 
#define mgsRotatedRegPolygonCR(s, n, x, y, r, a, c)   mgsRotatedBorderedRegPolygonCR((s), (n), (x), (y), (r), (a), (c), 0, -1)
 Non bordered version of the corresponding function.
 
#define mgsRotatedPolygon(s, n, v, x, y, a, c)   mgsRotatedBorderedPolygon((s), (n), (v), (x), (y), (a), (c), 0, -1)
 Non bordered version of the corresponding function.
 
#define mgsRotatedStarCR(s, n, x, y, e, i, a, c)   mgsRotatedBorderedStarCR((s), (n), (x), (y), (e), (i), (a), (c), 0, -1)
 Non bordered version of the corresponding function.
 
#define mgsRotatedESector(s, x, y, h, v, i, e, a, c)   mgsRotatedBorderedESector((s), (x), (y), (h), (v), (i), (e), (a), (c), 0, -1)
 Non bordered version of the corresponding function.
 
#define mgsRotatedESegment(s, x, y, h, v, i, e, a, c)   mgsRotatedBorderedESegment((s), (x), (y), (h), (v), (i), (e), (a), (c), 0, -1)
 Non bordered version of the corresponding function.
 
#define mgsLeftMouseClk(s, x, y, a, b)   mgsMouseClicked(s, _MLEFT, x, y, a, b)
 Individual macros to select only one mouse button on the advanced mouse functions.
 
#define mgsCenterMouseClk(s, x, y, a, b)   mgsMouseClicked(s, _MCENTER, x, y, a, b)
 Individual macros to select only one mouse button on the advanced mouse functions.
 
#define mgsRightMouseClk(s, x, y, a, b)   mgsMouseClicked(s, _MRIGHT, x, y, a, b)
 Individual macros to select only one mouse button on the advanced mouse functions.
 
#define mgsLeftMousePress(s, x, y, a, b)   mgsMousePressed(s, _MLEFT, x, y, a, b)
 Individual macros to select only one mouse button on the advanced mouse functions.
 
#define mgsCenterMousePress(s, x, y, a, b)   mgsMousePressed(s, _MCENTER, x, y, a, b)
 Individual macros to select only one mouse button on the advanced mouse functions.
 
#define mgsRightMousePress(s, x, y, a, b)   mgsMousePressed(s, _MRIGHT, x, y, a, b)
 Individual macros to select only one mouse button on the advanced mouse functions.
 

Functions

int mgsCreateScreen (int width, int height, char *title, int bckColor, char *bckFile)
 Creates a new graphic screen with the given width, height and background. More...
 
int mgsFullScreen (int bckColor, char *bckFile)
 Creates a borderless, full desktop graphic screen with the given background. More...
 
int mgsDeleteScreen (int scrNumber)
 Delete the screen window whose reference number is given. More...
 
int mgsMoveScreen (int scr, int x, int y)
 Moves a screen to a new position. More...
 
int mgsActivateScreen (int scr)
 Shows at front the screen window whose reference number is given. More...
 
int mgsUpdateScreen (int scrNumber)
 Update the screen window whose reference number is given. More...
 
int mgsClearScreen (int scrNumber)
 Clear the screen whose reference number is given. More...
 
int mgsSetBackground (int scrNumber)
 Freeze as background the current state of the screen whose reference number is given. More...
 
int mgsGetScreenInfoAdvanced (int scrNumber, int *posAndSize, char *handle)
 Gets information about position, size and handle of a screen or the display. More...
 
int mgsPoint (int scrNumber, int x, int y, int color)
 Plots a pixel with the given color at the given screen coordinates. More...
 
int mgsGetColor (int scr, int x, int y)
 Returns the color of the pixel at the given screen coordinates. More...
 
int mgsLine (int scrNumber, int xStart, int yStart, int xEnd, int yEnd, int width, int color)
 Draws a line with the given color and width from the given start to the given end point. More...
 
int mgsEArc (int scrNumber, int centerX, int centerY, int radiusH, int radiusV, int startingAngle, int endingAngle, int width, int color)
 Draws an elliptic arc with the given color and dimensions. More...
 
int mgsRotatedEArc (int scrNumber, int centerX, int centerY, int radiusH, int radiusV, int startingAngle, int endingAngle, int rotationAngle, int width, int color)
 Draws a rotated elliptic arc with the given color and dimensions. More...
 
int mgsDrawRectangle (int scrNumer, int left, int top, int right, int bottom, int width, int color)
 Draws a non filled rectangle with the given color and dimensions. More...
 
int mgsDrawEllipse (int scrNumber, int centerX, int centerY, int radiusH, int radiusV, int width, int color)
 Draws a non filled ellipse with the given color and dimensions. More...
 
int mgsDrawRegPolygonCR (int scrNumber, int sides, int centerX, int centerY, int radius, int width, int color)
 Draws a regular polygon given the number of vertex, radius and center, and its color. More...
 
int mgsDrawRegPolygonVC (int scrNumber, int sides, int vertexX, int vertexY, int centerX, int centerY, int width, int color)
 Draws a regular polygon given the number of vertex, center, one vertice and its color. More...
 
int mgsDrawPolygon (int scrNumber, int sides, int *vertices, int width, int color)
 Draws a generic polygon given its number and list of vertex and its color. More...
 
int mgsDrawStarCR (int scrNumber, int nsides, int centerX, int centerY, int externalRadius, int internalRadius, int width, int color)
 Draws a star given the number of points, inner and outer radius and center, and its color. More...
 
int mgsDrawStarVC (int scrNumber, int sides, int vertexX, int vertexY, int centerX, int centerY, int internalRadius, int width, int color)
 Draws a star given the number of points, center, inner radius, one point and its color. More...
 
int mgsDrawESector (int scrNumber, int centerX, int centerY, int radiusH, int radiusV, int startingAngle, int endingAngle, int width, int color)
 Draws an elliptic sector with the given color and dimensions. More...
 
int mgsDrawESegment (int scrNumber, int centerX, int centerY, int radiusH, int radiusV, int startingAngle, int endingAngle, int width, int color)
 Draws an elliptic segment with the given color and dimensions. More...
 
int mgsDrawRotatedRectangle (int scrNumer, int left, int top, int right, int bottom, int angle, int width, int color)
 Draws a non filled rotated rectangle with the given color and dimensions. More...
 
int mgsDrawRotatedEllipse (int scrNumber, int centerX, int centerY, int radiusH, int radiusV, int angle, int width, int color)
 Draws a non filled rotated ellipse with the given color and dimensions. More...
 
int mgsDrawRotatedRegPolygonCR (int scrNumber, int sides, int centerX, int centerY, int radius, int angle, int width, int color)
 Draws a rotated regular polygon given the number of vertex, radius and center, and its color. More...
 
int mgsDrawRotatedPolygon (int scrNumber, int sides, int *vertices, int centerX, int centerY, int angle, int width, int color)
 Draws a rotated generic polygon given its number and list of vertex and its color. More...
 
int mgsDrawRotatedStarCR (int scrNumber, int nsides, int centerX, int centerY, int externalRadius, int internalRadius, int angle, int width, int color)
 Draws a rotated star given the number of points, inner and outer radius and center, and its color. More...
 
int mgsDrawRotatedESector (int scrNumber, int centerX, int centerY, int radiusH, int radiusV, int startingAngle, int endingAngle, int rotationAngle, int width, int color)
 Draws a rotated elliptic sector with the given color and dimensions. More...
 
int mgsDrawRotatedESegment (int scrNumber, int centerX, int centerY, int radiusH, int radiusV, int startingAngle, int endingAngle, int rotationAngle, int width, int color)
 Draws a rotated elliptic segment with the given color and dimensions. More...
 
int mgsBorderedRectangle (int scrNumber, int left, int top, int right, int bottom, int color, int borderWidth, int borderColor)
 Draws a bordered rectangle with the given colors and dimensions. A macro is provided to draw uniform non bordered rectangles. More...
 
int mgsBorderedEllipse (int scrNumber, int centerX, int centerY, int radiusH, int radiusV, int color, int borderWidth, int borderColor)
 Draws a bordered ellipse with the given colors and dimensions. A macro is provided to draw uniform non bordered ellipses. More...
 
int mgsBorderedRegPolygonCR (int scrNumber, int sides, int centerX, int centerY, int radius, int color, int borderWidth, int borderColor)
 Draws a regular polygon given the number of vertex, radius and center, and its colors. A macro is provided to draw uniform non bordered regular polygons this way. More...
 
int mgsBorderedRegPolygonVC (int scrNumber, int sides, int vertexX, int vertexY, int centerX, int centerY, int color, int borderWidth, int borderColor)
 Draws a regular polygon given the number of vertex, center, one vertice and its colors. A macro is provided to draw uniform non bordered regular polygons this way. More...
 
int mgsBorderedPolygon (int scrNumber, int sides, int *vertices, int color, int borderWidth, int borderColor)
 Draws a generic polygon given its number and list of vertex and its colors. A macro is provided to draw uniform non bordered generic polygons. More...
 
int mgsBorderedStarCR (int scrNumber, int sides, int centerX, int centerY, int externalRadius, int internalRadius, int color, int borderWidth, int borderColor)
 Draws a star given the number of points, inner and outer radius and center, and its colors. A macro is provided to draw uniform non bordered regular stars this way. More...
 
int mgsBorderedStarVC (int scrNumber, int sides, int vertexX, int vertexY, int centerX, int centerY, int internalRadius, int color, int borderWidth, int borderColor)
 Draws a star given the number of points, center, inner radius, one point and its colors. A macro is provided to draw uniform non bordered stars this way. More...
 
int mgsBorderedESector (int scrNumber, int centerX, int centerY, int radiusH, int radiusV, int startAngle, int endAngle, int color, int borderWidth, int borderColor)
 Draws a bordered elliptic sector with the given colors and dimensions. A macro is provided to draw uniform non bordered sectors this way. More...
 
int mgsBorderedESegment (int scrNumber, int centerX, int centerY, int radiusH, int radiusV, int startAngle, int endAngle, int color, int borderWidth, int borderColor)
 Draws an elliptic segment with the given color and dimensions. A macro is provided to draw uniform non bordered segments this way. More...
 
int mgsRotatedBorderedRectangle (int scrNumber, int left, int top, int right, int bottom, int angle, int color, int borderWidth, int borderColor)
 Draws a rotated bordered rectangle with the given colors and dimensions. A macro is provided to draw rotated uniform non bordered rectangles. More...
 
int mgsRotatedBorderedEllipse (int scrNumber, int centerX, int centerY, int radiusH, int radiusV, int angle, int color, int borderWidth, int borderColor)
 Draws a rotated bordered ellipse with the given colors and dimensions. A macro is provided to draw rotated uniform non bordered ellipses. More...
 
int mgsRotatedBorderedRegPolygonCR (int scrNumber, int sides, int centerX, int centerY, int radius, int angle, int color, int borderWidth, int borderColor)
 Draws a rotated regular polygon given the number of vertex, radius and center, and its colors. A macro is provided to draw uniform non bordered rotated regular polygons. More...
 
int mgsRotatedBorderedPolygon (int scrNumber, int sides, int *vertices, int centerX, int centerY, int angle, int color, int borderWidth, int borderColor)
 Draws a rotated generic polygon given its number and list of vertex and its colors. A macro is provided to draw rotated uniform non bordered generic polygons. More...
 
int mgsRotatedBorderedStarCR (int scrNumber, int sides, int centerX, int centerY, int externalRadius, int internalRadius, int angle, int color, int borderWidth, int borderColor)
 Draws a rotated star given the number of points, inner and outer radius and center, and its colors. A macro is provided to draw uniform non bordered rotated regular stars this way. More...
 
int mgsRotatedBorderedESector (int scrNumber, int centerX, int centerY, int radiusH, int radiusV, int startAngle, int endAngle, int rotationAngle, int color, int borderWidth, int borderColor)
 Draws a rotated bordered elliptic sector with the given colors and dimensions. A macro is provided to draw uniform non bordered sectors this way. More...
 
int mgsRotatedBorderedESegment (int scrNumber, int centerX, int centerY, int radiusH, int radiusV, int startAngle, int endAngle, int rotationAngle, int color, int borderWidth, int borderColor)
 Draws an elliptic segment with the given color and dimensions. A macro is provided to draw uniform non bordered segments this way. More...
 
int mgsLoadImage (char *name)
 Loads an image and creates a new image object. More...
 
int mgsSetImportTColor (unsigned int c)
 Sets the color to use for transparent pixels. More...
 
int mgsMakeImage (int scrNumber, int originX, int originY, int width, int height)
 Creates a new image object from a rectangular region of a screen. More...
 
int mgsImageWidth (int imgNumber)
 Returns the width of a image. More...
 
int mgsImageHeight (int imgNumber)
 Returns the height of a image. More...
 
int mgsDeleteImage (int imgNumber)
 Delete the image whose reference number is given. More...
 
int mgsDisplayImage (int scrNumber, int imgNumber, int dx, int dy, int transparent)
 Displays an image on screen at the given position. More...
 
int mgsDisplayRotatedImage (int scrNumber, int imgNumber, int dx, int dy, double scaleX, double scaleY, int angle, int transparent)
 Displays a rotated and scaled image on screen at the given position. More...
 
int mgsSetFont (int scrNumber, int size, int textColor, int backColor)
 Sets font size and colors (text and background). More...
 
int mgsSetFontType (int scrNumber, int size, int angle, char *fontName, int style)
 Sets font type and size. More...
 
int mgsSetFontColor (int scrNumber, int textColor, int backColor)
 Sets font size and colors (text and background). More...
 
int mgsPuts (int scrNumber, int x, int y, char *str)
 Outputs a text string at the given position. More...
 
int mgsPutsAligned (int scrNumber, int mode, int left, int top, int right, int bottom, char *str)
 Outputs a text string aligned at the given position. More...
 
int mgsTextSize (int scrNumber, char *str, int *y)
 Returns the width and height in pixels of the given string on the screen. More...
 
int mgsMouseButtons (int scrNumber)
 Gets the state of the mouse buttons when activated over the given screen. More...
 
int mgsMouseX (int scrNumber)
 Gets the x coordinate of the cusor over the screen. More...
 
int mgsMouseY (int scrNumber)
 Gets the y coordinate of the cusor over the screen. More...
 
int mgsMouseGlobal (int *y)
 Gets the x and y coordinates of the cusor over the desktop. More...
 
int mgsMouseIn (int scrNumber)
 Determines if the cursor is over the screen. More...
 
int mgsMouseWheel (int scrNumber, unsigned char reset)
 Gets the last mouse wheel movement when the screen has the focus. More...
 
void mgsHandleMouse (int scr)
 Advanced mouse handling coordination function. More...
 
unsigned char mgsMouseClicked (int scr, unsigned char b, int x0, int y0, int x1, int y1)
 Detects user clicks on the given rectangular region of the screen. More...
 
unsigned char mgsMousePressed (int scr, unsigned char b, int x0, int y0, int x1, int y1)
 Returns the pressing state of the given button on the given rectangular region of the screen. More...
 
unsigned char mgsMouseOver (int scr, int x0, int y0, int x1, int y1)
 Retruns true if the cursor is over the given rectangular region of the screen. More...
 
unsigned char mgsKeyPressed (int keyCode)
 Checks if a given key is pressed. More...
 
int mgsPlaySoundFile (char *filename, int mode)
 Plays the given .WAV sound file. More...
 
void mgsSetFrameTime (int milliSeconds)
 Sets the new frame duration in ms. More...
 
void mgsWaitFrame (void)
 Stops the main thread until the given frame time expires. More...
 
double mgsPerformanceMeasure (int mode)
 Returns different measures of the inter frame time. More...
 
void mgsShowError (int errNum, char *msg, int flags)
 Displays a console message or a windows message box about the error. More...
 
struct mgsInfo mgsVersionData (void)
 Returns the main MGS System information. More...
 

Detailed Description

Author
German Fabregat
Date
February 2016

Macro Definition Documentation

◆ mgsRGBColor

#define mgsRGBColor (   r,
  g,
 
)    ((((b)&0xFF)<<16)|(((g)&0xFF)<<8)|((r)&0xFF))

This macro creates an int with the appropriate color by combining the R, G, and B components passed individually. Each of them should be a value between 0 and 255

Examples:
colorStar.c, functions.c, and lines.c.

◆ mgsGetScreenInfo

#define mgsGetScreenInfo (   s,
 
)    mgsGetScreenInfoAdvanced((s), (p), NULL);

This macro calls the advanced get screen information but discarding information about the handle

Function Documentation

◆ mgsCreateScreen()

int mgsCreateScreen ( int  sx,
int  sy,
char *  t,
int  bckColor,
char *  file 
)

This function is used to create a graphic screen of the given width and height. If a title is specified it will be used as window title, else the system provides a generic one. Also a color and an optional image for the background are given. If the image exists, it is adjusted to the screen size; if no image is specified or the file does not exist or it is not a valid BMP file, the background is set to the given color. The graphic screen window is created to the right of the main application window, at the same vertical position. This function is previous to the use of any other of the library functions (with exceptions that include keyboard input and sound), so any application should start by creating at least one graphic screen.

Parameters
[in]sxWidth in pixels of the client area of the created screen.
[in]syHeight in pixels of the client area of the created screen.
[in]tTitle of the window. The system provides a generic one if it is NULL.
[in]bckColorBackground color for the screen. It will be used if a background image does not exist.
[in]fileBackground image. It will be used unless it is NULL or it is not a valid bmp file.
Returns
The function returns a 0 or positive integer that references the created screen, or a negative value if an error occurred.

◆ mgsFullScreen()

int mgsFullScreen ( int  bckColor,
char *  file 
)

This function is used to create a full screen borderless graphic screen. Also a color and an optional image for the background are given. If the image exists, it is adjusted to the screen size; if no image is specified or the file does not exist or it is not a valid BMP file, the background is set to the given color. This function is previous to the use of any other of the library functions (with exceptions that include keyboard input and sound), so any application should start by creating at least one graphic screen.

Parameters
[in]bckColorBackground color for the screen. It will be used if a background image does not exist.
[in]fileBackground image. It will be used unless it is NULL or it is not a valid bmp file.
Returns
The function returns a 0 or positive integer that references the created screen, or a negative value if an error occurred.

◆ mgsDeleteScreen()

int mgsDeleteScreen ( int  scr)

This functions deletes from the system the graphic screen whose reference number is given, releasing all associated resources including its window. The reference number and screen slot are released for further use.

Parameters
[in]scrGraphic screen reference number.
Returns
A negative value in case of error, positive otherwise.

◆ mgsMoveScreen()

int mgsMoveScreen ( int  scr,
int  x,
int  y 
)

This functions places the given screen -top left corner- to the indicated position, without altering proportion nor contents. No bounding checks are performed.

Parameters
[in]scrGraphic screen reference number.
[in]xCoordinate of the leftmost position.
[in]yCoordinate of the top position.
Returns
A negative value in case of error, positive otherwise.

◆ mgsActivateScreen()

int mgsActivateScreen ( int  scr)

The screen whose number is given is placed at the topmost Z position which results in this screen being displayed at the front of the display.

Parameters
[in]scrGraphic screen reference number.
Returns
A negative value in case of error, positive otherwise.

◆ mgsUpdateScreen()

int mgsUpdateScreen ( int  scr)

The drawing functions of the library do not affect the window client area but an in memory image of it. When mgsUpdateScreen is called the window is updated and all the modifications actually displayed. The applications has thus control of the updating of the real window, allowing to perform timed updates and animations. Note that this control is not total, as the system will update the window if it is required to redraw it (if it has been totally or partially covered and returns to be completely visible).

Parameters
[in]scrGraphic screen reference number.
Returns
A negative value in case of error, positive otherwise.

◆ mgsClearScreen()

int mgsClearScreen ( int  scr)

The screen is cleared by displaying only the background color or image.

Parameters
[in]scrGraphic screen reference number.
Returns
A negative value in case of error, positive otherwise.

◆ mgsSetBackground()

int mgsSetBackground ( int  scr)

The current contents of the screen are freezed as its background to be used in future calls to mgsClearScreen. This allows to programmatically create backgrounds or to change it as required on runtime.

Parameters
[in]scrGraphic screen reference number.
Returns
A negative value in case of error, positive otherwise.

◆ mgsGetScreenInfoAdvanced()

int mgsGetScreenInfoAdvanced ( int  scr,
int *  ps,
char *  h 
)

Returns postion and size information about the selected window or the desktop. It can also return a handle to the screen.

Parameters
[in]scrGraphic screen reference number. If it is < 0 the desktop size (resolution) is returned.
[out]psA vector of six integers to return screen left position, top position, width and height including border and width and height of the drawing area, in this order. If the desktop is selected, the two first values will be 0, third and fifth will be equal, as well as fourth and sixth.
[in,out]hIf this parameter is not null, a handle to the window is returned (so the type of h has to be adequate to hold it). If the desktop is selected this parameter is ignored.
Returns
A negative value in case of error, positive otherwise.

◆ mgsPoint()

int mgsPoint ( int  scr,
int  x,
int  y,
int  c 
)

A single pixel of the given color is drawn af the given coordinates if these are inside the screen. Nothing happens otherwise.

Parameters
[in]scrGraphic screen reference number.
[in]xHorizonal coordinate of the pixel.
[in]yVertical coordinate of the pixel.
[in]cColor of the pixel.
Returns
A negative value in case of error, positive otherwise.

◆ mgsGetColor()

int mgsGetColor ( int  scr,
int  x,
int  y 
)

A single pixel of the given color is drawn af the given coordinates if these are inside the screen. Nothing happens otherwise.

Parameters
[in]scrGraphic screen reference number.
[in]xHorizonal coordinate of the pixel.
[in]yVertical coordinate of the pixel.
Returns
A negative value in case of error, the color of the pixel otherwise.

◆ mgsLine()

int mgsLine ( int  scr,
int  sx,
int  sy,
int  ex,
int  ey,
int  w,
int  c 
)

A straight line of the given width and color is drawn from the start to the end point (this one always excluded). If either the origin or the end are out of the screen, the visible part of the line is drawn.

Parameters
[in]scrGraphic screen reference number.
[in]sxHorizonal coordinate of the start point.
[in]syVertical coordinate of the start point.
[in]exHorizonal coordinate of the end point.
[in]eyVertical coordinate of the end point.
[in]wWidth in pixels of the line.
[in]cColor of the line.
Returns
A negative value in case of error, positive otherwise.

◆ mgsEArc()

int mgsEArc ( int  scr,
int  cx,
int  cy,
int  rh,
int  rv,
int  sa,
int  ea,
int  w,
int  c 
)

This functions draws the arc of an ellipse defined by its center and horizonal and vertical radius. If both are equal a circular arc is drawn. The starting and ending counterclockwise angles of the arch are also given. Only the on screen part of the ellipse is drawn. The border color and width are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]cxHorizontal coordinate of the center of the ellipse.
[in]cyVertical coordinate of the center of the ellipse.
[in]rhHorizontal radius of the ellipse.
[in]rvVertical radius of the ellipse.
[in]saStarting angle, counted counterclocwise from the horizontal.
[in]eaEnding angle, counted counterclocwise from the horizontal. The drawn angle is the difference of both.
[in]wWidth in pixels of the border.
[in]cColor of the ellipse.
Returns
A negative value in case of error, positive otherwise.

◆ mgsRotatedEArc()

int mgsRotatedEArc ( int  scr,
int  cx,
int  cy,
int  rh,
int  rv,
int  sa,
int  ea,
int  a,
int  w,
int  c 
)

This functions draws the arc of an ellipse defined by its center and horizonal and vertical radius, rotated counterclockwise the given angle. If both are equal a circular arc is drawn. The starting and ending counterclockwise angles of the arc are also given. Only the on screen part of the ellipse is drawn. The border color and width are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]cxHorizontal coordinate of the center of the ellipse.
[in]cyVertical coordinate of the center of the ellipse.
[in]rhHorizontal radius of the ellipse.
[in]rvVertical radius of the ellipse.
[in]saStarting angle, counted counterclocwise from the horizontal.
[in]eaEnding angle, counted counterclocwise from the horizontal. The drawn angle is the difference of both.
[in]aSexagesimal rotation angle.
[in]wWidth in pixels of the border.
[in]cColor of the ellipse.
Returns
A negative value in case of error, positive otherwise.

◆ mgsDrawRectangle()

int mgsDrawRectangle ( int  scr,
int  l,
int  t,
int  r,
int  b,
int  w,
int  c 
)

This functions draws a rectangle defined by (l,t) and (r,b) as the coordinates of the top left and bottom right corner respectively. The function suceeds and draws the corresponding rectangle although the corners are not well defined (that is, bottom higher than top, left righter than right) or out of screen. A color and width are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]lLeftmost horizontal coordinate of the rectangle.
[in]tTop vertical coordinate of the rectangle.
[in]rRightmost horizontal coordinate of the rectangle.
[in]bBottom vertical coordinate of the rectangle.
[in]wWidth in pixels of the border.
[in]cColor of the rectangle.
Returns
A negative value in case of error, positive otherwise.

◆ mgsDrawEllipse()

int mgsDrawEllipse ( int  scr,
int  cx,
int  cy,
int  rh,
int  rv,
int  w,
int  c 
)

This functions draws an ellipse defined by its center and horizonal and vertical radius. If both are equal a circle is drawn. Only the on screen part of the ellipse is drawn. The border color and width are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]cxHorizontal coordinate of the center of the ellipse.
[in]cyVertical coordinate of the center of the ellipse.
[in]rhHorizontal radius of the ellipse.
[in]rvVertical radius of the ellipse.
[in]wWidth in pixels of the border.
[in]cColor of the ellipse.
Returns
A negative value in case of error, positive otherwise.

◆ mgsDrawRegPolygonCR()

int mgsDrawRegPolygonCR ( int  scr,
int  ns,
int  cx,
int  cy,
int  r,
int  w,
int  c 
)

This functions draws a regular polygon defined by its center, radius of the circumscribed circumference and number of vertex. The polygon is drawn so that one vertex is placed at the vertical coordinate of the center and to its right. Only the on screen part of the polygon is drawn. The border color and width are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]nsNumber of sides (and vertex) of the polygon.
[in]cxHorizontal coordinate of the center of the polygon.
[in]cyVertical coordinate of the center of the polygon.
[in]rRadius of the polygon.
[in]wWidth in pixels of the border.
[in]cColor of the polygon.
Returns
A negative value in case of error, positive otherwise.

◆ mgsDrawRegPolygonVC()

int mgsDrawRegPolygonVC ( int  scr,
int  ns,
int  vx,
int  vy,
int  cx,
int  cy,
int  w,
int  c 
)

This functions draws a regular polygon defined by its center, coordinates of one vertice and number of vertex. Only the on screen part of the polygon is drawn. The border color and width are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]nsNumber of sides (and vertex) of the polygon.
[in]vxHorizontal coordinate of the given vertice.
[in]vyVertical coordinate of the given vertice.
[in]cxHorizontal coordinate of the center of the polygon.
[in]cyVertical coordinate of the center of the polygon.
[in]wWidth in pixels of the border.
[in]cColor of the polygon.
Returns
A negative value in case of error, positive otherwise.

◆ mgsDrawPolygon()

int mgsDrawPolygon ( int  scr,
int  ns,
int *  vx,
int  w,
int  c 
)

This functions draws a polygon defined by its number of vertex and the coordinates of all of them. These are placed on a vector of integers, holding on its even elements (0, 2, ...) the x coordinates and on its odd ones (1, 3, ...) the y coordinates. Only the on screen part of the polygon is drawn. A border color and width are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]nsNumber of sides (and vertex) of the polygon.
[in]vxVector of 2 * ns integers. Each pair of integers hold the x and y coordinates of a vertice.
[in]wWidth in pixels of the border.
[in]cColor of the polygon.
Returns
A negative value in case of error, positive otherwise.

◆ mgsDrawStarCR()

int mgsDrawStarCR ( int  scr,
int  ns,
int  cx,
int  cy,
int  er,
int  ir,
int  w,
int  c 
)

This functions draws a star defined by its center, inner and outer radius and number of points. The outer radius is the distance from the center to the points, while the inner is the distance from the center to the nodes. The star is drawn so that one point is placed at the vertical coordinate of the center and to its right. It is not required that the inner radius be less than the outer, but none of them can be 0. Only the on screen part of the star is drawn. A border color and width are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]nsNumber of points of the star.
[in]cxHorizontal coordinate of the center of the star.
[in]cyVertical coordinate of the center of the star.
[in]erOuter radius of the star.
[in]irInner radius of the star.
[in]wWidth in pixels of the border.
[in]cColor of the polygon.
Returns
A negative value in case of error, positive otherwise.

◆ mgsDrawStarVC()

int mgsDrawStarVC ( int  scr,
int  ns,
int  vx,
int  vy,
int  cx,
int  cy,
int  ir,
int  w,
int  c 
)

This functions draws a star defined by its center, coordinates of one point, inner radius and number of points. The inner radius can be longer than the distance from the center to the point, but none of them can be 0. Only the on screen part of the star is drawn. A border color and width are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]nsNumber of points of the star.
[in]vxHorizontal coordinate of the given point.
[in]vyVertical coordinate of the given point.
[in]cxHorizontal coordinate of the center of the star.
[in]cyVertical coordinate of the center of the star.
[in]irInner radius of the star.
[in]wWidth in pixels of the border.
[in]cColor of the polygon.
Returns
A negative value in case of error, positive otherwise.

◆ mgsDrawESector()

int mgsDrawESector ( int  scr,
int  cx,
int  cy,
int  rh,
int  rv,
int  sa,
int  ea,
int  w,
int  c 
)

This functions draws a sector of ellipse defined by its center and horizonal and vertical radius. If both are equal a circular sector is drawn. The starting and ending counterclockwise angles of the arch are also given. Only the on screen part of the sector is drawn. The border color and width are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]cxHorizontal coordinate of the center of the ellipse.
[in]cyVertical coordinate of the center of the ellipse.
[in]rhHorizontal radius of the ellipse.
[in]rvVertical radius of the ellipse.
[in]saStarting angle, counted counterclocwise from the horizontal.
[in]eaEnding angle, counted counterclocwise from the horizontal. The drawn angle is the difference of both.
[in]wWidth in pixels of the border.
[in]cColor of the ellipse.
Returns
A negative value in case of error, positive otherwise.

◆ mgsDrawESegment()

int mgsDrawESegment ( int  scr,
int  cx,
int  cy,
int  rh,
int  rv,
int  sa,
int  ea,
int  w,
int  c 
)

This functions draws a sement of ellipse defined by its center and horizonal and vertical radius. If both are equal a circular segment is drawn. The starting and ending counterclockwise angles of the arch are also given. Only the on screen part of the sement is drawn. The border color and width are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]cxHorizontal coordinate of the center of the ellipse.
[in]cyVertical coordinate of the center of the ellipse.
[in]rhHorizontal radius of the ellipse.
[in]rvVertical radius of the ellipse.
[in]saStarting angle, counted counterclocwise from the horizontal.
[in]eaEnding angle, counted counterclocwise from the horizontal. The drawn angle is the difference of both.
[in]wWidth in pixels of the border.
[in]cColor of the ellipse.
Returns
A negative value in case of error, positive otherwise.

◆ mgsDrawRotatedRectangle()

int mgsDrawRotatedRectangle ( int  scr,
int  l,
int  t,
int  r,
int  b,
int  a,
int  w,
int  c 
)

This functions draws a rectangle defined by (l,t) and (r,b) as the coordinates of the top left and bottom right corner respectively, rotated counterclockwise the given angle. The rotation point is the calculated center of the rectangle, so the l and t coordinates do not determine in general any point on the rotated figure. The function suceeds and draws the corresponding rectangle although the corners are not well defined (that is, bottom higher than top, left righter than right) or out of screen. A color and width are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]lLeftmost horizontal coordinate of the rectangle.
[in]tTop vertical coordinate of the rectangle.
[in]rRightmost horizontal coordinate of the rectangle.
[in]bBottom vertical coordinate of the rectangle.
[in]aSexagesimal rotation angle.
[in]wWidth in pixels of the border.
[in]cColor of the rectangle.
Returns
A negative value in case of error, positive otherwise.

◆ mgsDrawRotatedEllipse()

int mgsDrawRotatedEllipse ( int  scr,
int  cx,
int  cy,
int  rh,
int  rv,
int  a,
int  w,
int  c 
)

This functions draws an ellipse defined by its center and horizonal and vertical radius, rotated counterclockwise the given angle. If both are equal a circle is drawn. Only the on screen part of the ellipse is drawn. The border color and width are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]cxHorizontal coordinate of the center of the ellipse.
[in]cyVertical coordinate of the center of the ellipse.
[in]rhHorizontal radius of the ellipse.
[in]rvVertical radius of the ellipse.
[in]aSexagesimal rotation angle.
[in]wWidth in pixels of the border.
[in]cColor of the ellipse.
Returns
A negative value in case of error, positive otherwise.

◆ mgsDrawRotatedRegPolygonCR()

int mgsDrawRotatedRegPolygonCR ( int  scr,
int  ns,
int  cx,
int  cy,
int  r,
int  a,
int  w,
int  c 
)

This functions draws a regular polygon defined by its center, radius of the circumscribed circumference and number of vertex, rotated counterclockwise the given angle. The polygon is calculated so that one vertex is placed at the vertical coordinate of the center and to its right, then rotated counterclockwise the given angle. Only the on screen part of the polygon is drawn. The border color and width are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]nsNumber of sides (and vertex) of the polygon.
[in]cxHorizontal coordinate of the center of the polygon.
[in]cyVertical coordinate of the center of the polygon.
[in]rRadius of the polygon.
[in]aSexagesimal rotation angle.
[in]wWidth in pixels of the border.
[in]cColor of the polygon.
Returns
A negative value in case of error, positive otherwise.

◆ mgsDrawRotatedPolygon()

int mgsDrawRotatedPolygon ( int  scr,
int  ns,
int *  vx,
int  cx,
int  cy,
int  a,
int  w,
int  c 
)

This functions draws a polygon defined by its number of vertex and the coordinates of all of them. These are placed on a vector of integers, holding on its even elements (0, 2, ...) the x coordinates and on its odd ones (1, 3, ...) the y coordinates. The polygon is rotated counterclockwise the given angle around the given arbitrary point. Only the on screen part of the polygon is drawn. A border color and width are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]nsNumber of sides (and vertex) of the polygon.
[in]vxVector of 2 * ns integers. Each pair of integers hold the x and y coordinates of a vertice.
[in]cxHorizontal coordinate of the rotation point.
[in]cyVertical coordinate of the rotation point.
[in]aSexagesimal rotation angle.
[in]wWidth in pixels of the border.
[in]cColor of the polygon.
Returns
A negative value in case of error, positive otherwise.

◆ mgsDrawRotatedStarCR()

int mgsDrawRotatedStarCR ( int  scr,
int  ns,
int  cx,
int  cy,
int  er,
int  ir,
int  a,
int  w,
int  c 
)

This functions draws a star defined by its center, inner and outer radius and number of points. The outer radius is the distance from the center to the points, while the inner is the distance from the center to the nodes. The star is drawn so that one point is placed at the vertical coordinate of the center and to its right. It is not required that the inner radius be less than the outer, but none of them can be 0. Only the on screen part of the star is drawn. A border color and width are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]nsNumber of points of the star.
[in]cxHorizontal coordinate of the center of the star.
[in]cyVertical coordinate of the center of the star.
[in]erOuter radius of the star.
[in]irInner radius of the star.
[in]aSexagesimal rotation angle.
[in]wWidth in pixels of the border.
[in]cColor of the polygon.
Returns
A negative value in case of error, positive otherwise.

◆ mgsDrawRotatedESector()

int mgsDrawRotatedESector ( int  scr,
int  cx,
int  cy,
int  rh,
int  rv,
int  sa,
int  ea,
int  a,
int  w,
int  c 
)

This functions draws a sector of ellipse defined by its center and horizonal and vertical radius, rotated counterclockwise the given angle. If both are equal a circular sector is drawn. The starting and ending counterclockwise angles of the arch are also given. Only the on screen part of the sector is drawn. The border color and width are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]cxHorizontal coordinate of the center of the ellipse.
[in]cyVertical coordinate of the center of the ellipse.
[in]rhHorizontal radius of the ellipse.
[in]rvVertical radius of the ellipse.
[in]saStarting angle, counted counterclocwise from the horizontal.
[in]eaEnding angle, counted counterclocwise from the horizontal. The drawn angle is the difference of both.
[in]aSexagesimal rotation angle.
[in]wWidth in pixels of the border.
[in]cColor of the ellipse.
Returns
A negative value in case of error, positive otherwise.

◆ mgsDrawRotatedESegment()

int mgsDrawRotatedESegment ( int  scr,
int  cx,
int  cy,
int  rh,
int  rv,
int  sa,
int  ea,
int  a,
int  w,
int  c 
)

This functions draws a segment of ellipse defined by its center and horizonal and vertical radius, rotated counterclockwise the given angle. If both radius are equal a circular segment is drawn. The starting and ending counterclockwise angles of the arch are also given. Only the on screen part of the sement is drawn. The border color and width are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]cxHorizontal coordinate of the center of the ellipse.
[in]cyVertical coordinate of the center of the ellipse.
[in]rhHorizontal radius of the ellipse.
[in]rvVertical radius of the ellipse.
[in]saStarting angle, counted counterclocwise from the horizontal.
[in]eaEnding angle, counted counterclocwise from the horizontal. The drawn angle is the difference of both.
[in]aSexagesimal rotation angle.
[in]wWidth in pixels of the border.
[in]cColor of the ellipse.
Returns
A negative value in case of error, positive otherwise.

◆ mgsBorderedRectangle()

int mgsBorderedRectangle ( int  scr,
int  l,
int  t,
int  r,
int  b,
int  fc,
int  bw,
int  bc 
)

This functions draws a rectangle defined by (l,t) and (r,b) as the coordinates of the top left and bottom right corner respectively. The function suceeds and draws the corresponding rectangle although the corners are not well defined (that is, bottom higher than top, left righter than right) or out of screen. A border color and width and a fill color are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]lLeftmost horizontal coordinate of the rectangle.
[in]tTop vertical coordinate of the rectangle.
[in]rRightmost horizontal coordinate of the rectangle.
[in]bBottom vertical coordinate of the rectangle.
[in]fcFill color of the rectangle.
[in]bwWidth in pixels of the border.
[in]bcColor of the border.
Returns
A negative value in case of error, positive otherwise.

◆ mgsBorderedEllipse()

int mgsBorderedEllipse ( int  scr,
int  cx,
int  cy,
int  rh,
int  rv,
int  fc,
int  bw,
int  bc 
)

This functions draws an ellipse defined by its center and horizonal and vertical radius. If both are equal a circle is drawn. Only the on screen part of the ellipse is drawn. A border color and width and a fill color are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]cxHorizontal coordinate of the center of the ellipse.
[in]cyVertical coordinate of the center of the ellipse.
[in]rhHorizontal radius of the ellipse.
[in]rvVertical radius of the ellipse.
[in]fcFill color of the ellipse.
[in]bwWidth in pixels of the border.
[in]bcColor of the border.
Returns
A negative value in case of error, positive otherwise.

◆ mgsBorderedRegPolygonCR()

int mgsBorderedRegPolygonCR ( int  scr,
int  ns,
int  cx,
int  cy,
int  r,
int  fc,
int  bw,
int  bc 
)

This functions draws a regular polygon defined by its center, radius of the circumscribed circumference and number of vertex. The polygon is drawn so that one vertex is placed at the vertical coordinate of the center and to its right. Only the on screen part of the polygon is drawn. A border color and width and a fill color are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]nsNumber of sides (and vertex) of the polygon.
[in]cxHorizontal coordinate of the center of the polygon.
[in]cyVertical coordinate of the center of the polygon.
[in]rRadius of the polygon.
[in]fcFill color of the polygon.
[in]bwWidth in pixels of the border.
[in]bcColor of the border.
Returns
A negative value in case of error, positive otherwise.

◆ mgsBorderedRegPolygonVC()

int mgsBorderedRegPolygonVC ( int  scr,
int  ns,
int  vx,
int  vy,
int  cx,
int  cy,
int  fc,
int  bw,
int  bc 
)

This functions draws a regular polygon defined by its center, coordinates of one vertice and number of vertex. Only the on screen part of the polygon is drawn. A border color and width and a fill color are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]nsNumber of sides (and vertex) of the polygon.
[in]vxHorizontal coordinate of the given vertice.
[in]vyVertical coordinate of the given vertice.
[in]cxHorizontal coordinate of the center of the polygon.
[in]cyVertical coordinate of the center of the polygon.
[in]fcFill color of the polygon.
[in]bwWidth in pixels of the border.
[in]bcColor of the border.
Returns
A negative value in case of error, positive otherwise.

◆ mgsBorderedPolygon()

int mgsBorderedPolygon ( int  scr,
int  ns,
int *  vx,
int  fc,
int  bw,
int  bc 
)

This functions draws a polygon defined by its number of vertex and the coordinates of all of them. These are placed on a vector of integers, holding on its even elements (0, 2, ...) the x coordinates and on its odd ones (1, 3, ...) the y coordinates. Only the on screen part of the polygon is drawn. A border color and width and a fill color are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]nsNumber of sides (and vertex) of the polygon.
[in]vxVector of 2 * ns integers. Each pair of integers hold the x and y coordinates of a vertice.
[in]fcFill color of the polygon.
[in]bwWidth in pixels of the border.
[in]bcColor of the border.
Returns
A negative value in case of error, positive otherwise.

◆ mgsBorderedStarCR()

int mgsBorderedStarCR ( int  scr,
int  ns,
int  cx,
int  cy,
int  er,
int  ir,
int  fc,
int  bw,
int  bc 
)

This functions draws a star defined by its center, inner and outer radius and number of points. The outer radius is the distance from the center to the points, while the inner is the distance from the center to the nodes. The star is drawn so that one point is placed at the vertical coordinate of the center and to its right. It is not required that the inner radius be less than the outer, but none of them can be 0. Only the on screen part of the star is drawn. A border color and width and a fill color are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]nsNumber of points of the star.
[in]cxHorizontal coordinate of the center of the star.
[in]cyVertical coordinate of the center of the star.
[in]erOuter radius of the star.
[in]irInner radius of the star.
[in]fcFill color of the star.
[in]bwWidth in pixels of the border.
[in]bcColor of the border.
Returns
A negative value in case of error, positive otherwise.

◆ mgsBorderedStarVC()

int mgsBorderedStarVC ( int  scr,
int  ns,
int  vx,
int  vy,
int  cx,
int  cy,
int  ir,
int  fc,
int  bw,
int  bc 
)

This functions draws a star defined by its center, coordinates of one point, inner radius and number of points. The inner radius can be longer than the distance from the center to the point, but none of them can be 0. Only the on screen part of the star is drawn. A border color and width and a fill color are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]nsNumber of points of the star.
[in]vxHorizontal coordinate of the given point.
[in]vyVertical coordinate of the given point.
[in]cxHorizontal coordinate of the center of the star.
[in]cyVertical coordinate of the center of the star.
[in]irInner radius of the star.
[in]fcFill color of the star.
[in]bwWidth in pixels of the border.
[in]bcColor of the border.
Returns
A negative value in case of error, positive otherwise.

◆ mgsBorderedESector()

int mgsBorderedESector ( int  scr,
int  cx,
int  cy,
int  rh,
int  rv,
int  sa,
int  ea,
int  fc,
int  bw,
int  bc 
)

This functions draws a sector of ellipse defined by its center and horizonal and vertical radius. If both are equal a circular sector is drawn. The starting and ending counterclockwise angles of the arch are also given. Only the on screen part of the sector is drawn. A border color and width and a fill color are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]cxHorizontal coordinate of the center of the ellipse.
[in]cyVertical coordinate of the center of the ellipse.
[in]rhHorizontal radius of the ellipse.
[in]rvVertical radius of the ellipse.
[in]saStarting angle, counted counterclocwise from the horizontal.
[in]eaEnding angle, counted counterclocwise from the horizontal. The drawn angle is the difference of both.
[in]fcFill color of the sector.
[in]bwWidth in pixels of the border.
[in]bcColor of the border.
Returns
A negative value in case of error, positive otherwise.

◆ mgsBorderedESegment()

int mgsBorderedESegment ( int  scr,
int  cx,
int  cy,
int  rh,
int  rv,
int  sa,
int  ea,
int  fc,
int  bw,
int  bc 
)

This functions draws a segment of ellipse defined by its center and horizonal and vertical radius. If both are equal a circular segment is drawn. The starting and ending counterclockwise angles of the arch are also given. Only the on screen part of the sement is drawn. A border color and width and a fill color are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]cxHorizontal coordinate of the center of the ellipse.
[in]cyVertical coordinate of the center of the ellipse.
[in]rhHorizontal radius of the ellipse.
[in]rvVertical radius of the ellipse.
[in]saStarting angle, counted counterclocwise from the horizontal.
[in]eaEnding angle, counted counterclocwise from the horizontal. The drawn angle is the difference of both.
[in]fcFill color of the segment.
[in]bwWidth in pixels of the border.
[in]bcColor of the border.
Returns
A negative value in case of error, positive otherwise.

◆ mgsRotatedBorderedRectangle()

int mgsRotatedBorderedRectangle ( int  scr,
int  l,
int  t,
int  r,
int  b,
int  a,
int  fc,
int  bw,
int  bc 
)

This functions draws a rectangle defined by (l,t) and (r,b) as the coordinates of the top left and bottom right corner respectively, rotated counterclockwise the given angle. The rotation point is the calculated center of the rectangle, so the l and t coordinates do not determine in general any point on the rotated figure. The function suceeds and draws the corresponding rectangle although the corners are not well defined (that is, bottom higher than top, left righter than right) or out of screen. A border color and width and a fill color are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]lLeftmost horizontal coordinate of the rectangle.
[in]tTop vertical coordinate of the rectangle.
[in]rRightmost horizontal coordinate of the rectangle.
[in]bBottom vertical coordinate of the rectangle.
[in]aSexagesimal rotation angle.
[in]fcFill color of the rectangle.
[in]bwWidth in pixels of the border.
[in]bcColor of the border.
Returns
A negative value in case of error, positive otherwise.

◆ mgsRotatedBorderedEllipse()

int mgsRotatedBorderedEllipse ( int  scr,
int  cx,
int  cy,
int  rh,
int  rv,
int  a,
int  fc,
int  bw,
int  bc 
)

This functions draws an ellipse defined by its center and horizonal and vertical radius, rotated counterclockwise the given angle. If both radius are equal a circle is drawn. Only the on screen part of the ellipse is drawn. A border color and width and a fill color are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]cxHorizontal coordinate of the center of the ellipse.
[in]cyVertical coordinate of the center of the ellipse.
[in]rhHorizontal radius of the ellipse.
[in]rvVertical radius of the ellipse.
[in]aSexagesimal rotation angle.
[in]fcFill color of the ellipse.
[in]bwWidth in pixels of the border.
[in]bcColor of the border.
Returns
A negative value in case of error, positive otherwise.

◆ mgsRotatedBorderedRegPolygonCR()

int mgsRotatedBorderedRegPolygonCR ( int  scr,
int  ns,
int  cx,
int  cy,
int  r,
int  a,
int  fc,
int  bw,
int  bc 
)

This functions draws a regular polygon defined by its center, radius of the circumscribed circumference and number of vertex. The polygon is calculated so that one vertex is placed at the vertical coordinate of the center and to its right, then rotated counterclockwise the given angle. Only the on screen part of the polygon is drawn. A border color and width and a fill color are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]nsNumber of sides (and vertex) of the polygon.
[in]cxHorizontal coordinate of the center of the polygon.
[in]cyVertical coordinate of the center of the polygon.
[in]rRadius of the polygon.
[in]aSexagesimal rotation angle.
[in]fcFill color of the polygon.
[in]bwWidth in pixels of the border.
[in]bcColor of the border.
Returns
A negative value in case of error, positive otherwise.

◆ mgsRotatedBorderedPolygon()

int mgsRotatedBorderedPolygon ( int  scr,
int  ns,
int *  vx,
int  cx,
int  cy,
int  a,
int  fc,
int  bw,
int  bc 
)

This functions draws a polygon defined by its number of vertex and the coordinates of all of them. These are placed on a vector of integers, holding on its even elements (0, 2, ...) the x coordinates and on its odd ones (1, 3, ...) the y coordinates. The polygon is rotated counterclockwise the given angle around the given arbitrary point. Only the on screen part of the polygon is drawn. A border color and width and a fill color are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]nsNumber of sides (and vertex) of the polygon.
[in]vxVector of 2 * ns integers. Each pair of integers hold the x and y coordinates of a vertice.
[in]cxHorizontal coordinate of the rotation point.
[in]cyVertical coordinate of the rotation point.
[in]aSexagesimal rotation angle.
[in]fcFill color of the polygon.
[in]bwWidth in pixels of the border.
[in]bcColor of the border.
Returns
A negative value in case of error, positive otherwise.

◆ mgsRotatedBorderedStarCR()

int mgsRotatedBorderedStarCR ( int  scr,
int  ns,
int  cx,
int  cy,
int  er,
int  ir,
int  a,
int  fc,
int  bw,
int  bc 
)

This functions draws a star defined by its center, inner and outer radius and number of points. The outer radius is the distance from the center to the points, while the inner is the distance from the center to the nodes. The star is calculated so that one point is placed at the vertical coordinate of the center and to its right. Then it is rotated counterclockwise the given angle. It is not required that the inner radius be less than the outer, but none of them can be 0. Only the on screen part of the star is drawn. A border color and width and a fill color are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]nsNumber of points of the star.
[in]cxHorizontal coordinate of the center of the star.
[in]cyVertical coordinate of the center of the star.
[in]erOuter radius of the star.
[in]irInner radius of the star.
[in]aSexagesimal rotation angle.
[in]fcFill color of the star.
[in]bwWidth in pixels of the border.
[in]bcColor of the border.
Returns
A negative value in case of error, positive otherwise.

◆ mgsRotatedBorderedESector()

int mgsRotatedBorderedESector ( int  scr,
int  cx,
int  cy,
int  rh,
int  rv,
int  sa,
int  ea,
int  a,
int  fc,
int  bw,
int  bc 
)

This functions draws a sector of ellipse defined by its center and horizonal and vertical radius. If both are equal a circular sector is drawn. The starting and ending counterclockwise angles of the arch are also given. The sector is then rotated counterclockwise the given angle. Only the on screen part of the sector is drawn. A border color and width and a fill color are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]cxHorizontal coordinate of the center of the ellipse.
[in]cyVertical coordinate of the center of the ellipse.
[in]rhHorizontal radius of the ellipse.
[in]rvVertical radius of the ellipse.
[in]saStarting angle, counted counterclocwise from the horizontal.
[in]eaEnding angle, counted counterclocwise from the horizontal. The drawn angle is the difference of both.
[in]aSexagesimal rotation angle.
[in]fcFill color of the sector.
[in]bwWidth in pixels of the border.
[in]bcColor of the border.
Returns
A negative value in case of error, positive otherwise.

◆ mgsRotatedBorderedESegment()

int mgsRotatedBorderedESegment ( int  scr,
int  cx,
int  cy,
int  rh,
int  rv,
int  sa,
int  ea,
int  a,
int  fc,
int  bw,
int  bc 
)

This functions draws a segment of ellipse defined by its center and horizonal and vertical radius. If both are equal a circular segment is drawn. The starting and ending counterclockwise angles of the arch are also given. The segment is then rotated counterclockwise the given angle. Only the on screen part of the sement is drawn. A border color and width and a fill color are also provided and applied.

Parameters
[in]scrGraphic screen reference number.
[in]cxHorizontal coordinate of the center of the ellipse.
[in]cyVertical coordinate of the center of the ellipse.
[in]rhHorizontal radius of the ellipse.
[in]rvVertical radius of the ellipse.
[in]saStarting angle, counted counterclocwise from the horizontal.
[in]eaEnding angle, counted counterclocwise from the horizontal. The drawn angle is the difference of both.
[in]aSexagesimal rotation angle.
[in]fcFill color of the segment.
[in]bwWidth in pixels of the border.
[in]bcColor of the border.
Returns
A negative value in case of error, positive otherwise.

◆ mgsLoadImage()

int mgsLoadImage ( char *  name)

Loads an image from the given file and stores in one of the image slots of the system. The image can then be displayed on the screen in the different modes the image handling functions provide. The functions assumes the color of the upper left corner of the image to be transparent.

Parameters
[in]nameThe file containing the image.
Returns
The function returns a 0 or positive integer that references the created image, or a negative value if an error occurred.

◆ mgsSetImportTColor()

int mgsSetImportTColor ( unsigned int  c)

Currently MGS lib does not support alpha channel nor real transparent pixels in images. When loading an image file that supports transparent pixels, these are converted to the importTColor. This function sets the value for this color.

Parameters
[in]cThe substitution color.
Returns
The previous importTColor.

◆ mgsMakeImage()

int mgsMakeImage ( int  scr,
int  ox,
int  oy,
int  w,
int  h 
)

Copies the contents of a rectangular region of a screen in one of the image slots of the system. The image can then be displayed on the screen in the different modes the image handling functions provide. The functions assumes the color of the upper left corner of the image to be transparent.

Parameters
[in]scrSource graphic screen reference number.
[in]oxHorizontal coordinate on screen of the origin left top corner.
[in]oyVertical coordinate on screen of the origin left top corner.
[in]wWidth of the rectangular region. Cannot go out of the original screen.
[in]hHeight of the rectangular region. Cannot go out of the original screen.
Returns
The function returns a 0 or positive integer that references the created image, or a negative value if an error occurred.

◆ mgsImageWidth()

int mgsImageWidth ( int  img)

Returns the width in pixels of a previously loaded .BMP image

Parameters
[in]imgImage reference number.
Returns
The image width in pixels or a negative value in case of error.

◆ mgsImageHeight()

int mgsImageHeight ( int  img)

Returns the height in pixels of a previously loaded .BMP image

Parameters
[in]imgImage reference number.
Returns
The image height in pixels or a negative value in case of error.

◆ mgsDeleteImage()

int mgsDeleteImage ( int  img)

This functions deletes from the system the image whose reference number is given, releasing all associated resources. The reference number and image slot are released for further use.

Parameters
[in]imgImage reference number.
Returns
A negative value in case of error, positive otherwise.

◆ mgsDisplayImage()

int mgsDisplayImage ( int  scr,
int  img,
int  dx,
int  dy,
int  t 
)

Displays an existing image at the given position of the screen, keeping its width and height. If the transparent flag is set (noncero value) pixels having the color used as transparent (that of the upper left corner) are not displayed preserving the screen color under them

Parameters
[in]scrGraphic screen reference number.
[in]imgImage reference number.
[in]dxHorizontal coordinate on screen of the destination left top corner
[in]dyVertical coordinate on screen of the destination left top corner
[in]tTransparent flag. When noncero the image has transparent pixels
Returns
A negative value in case of error, positive otherwise.

◆ mgsDisplayRotatedImage()

int mgsDisplayRotatedImage ( int  scr,
int  img,
int  dx,
int  dy,
double  sx,
double  sy,
int  a,
int  t 
)

Displays an existing image at the given position of the screen, scaled on x and y and rotated. If the transparent flag is set (noncero value) pixels having the color used as transparent (that of the upper left corner) are not displayed preserving the screen color under them

Parameters
[in]scrGraphic screen reference number.
[in]imgImage reference number.
[in]dxHorizontal coordinate on screen of the destination left top corner
[in]dyVertical coordinate on screen of the destination left top corner
[in]sxHorizontal scale factor
[in]syVertical scale factor
[in]aRotation angle
[in]tTransparent flag. When noncero the image has transparent pixels
Returns
A negative value in case of error, positive otherwise.

◆ mgsSetFont()

int mgsSetFont ( int  scr,
int  sz,
int  tc,
int  bc 
)

Sets the size and color of the text and the color of the background to be used in later calls to display text. The background can be made transparent setting it to MGS_TRANSPARENT.

Parameters
[in]scrGraphic screen reference number.
[in]szSize of the font.
[in]tcText color.
[in]bcBackground color; transparent if using MGS_TRANSPARENT.
Returns
A negative value in case of error, positive otherwise.

◆ mgsSetFontType()

int mgsSetFontType ( int  scr,
int  sz,
int  a,
char *  fn,
int  s 
)

Sets the size and type of the text to be used in later calls to display text. The font is one of windows fonts, and can be set to be italic, underscored and striked out. Its weight -normal, bold, heavy...- can also be set.

Parameters
[in]scrGraphic screen reference number.
[in]szSize of the font.
[in]aRotation angle in degrees.
[in]fnPointer to a string containing the font name. If it is NULL the standard font is used.
[in]sStyle of the font. The three lower bits mean from 0 to 2 italic, underline and strikeout. The higher bits a weight ranging from 0 to 1000. The constants MGS_ITALIC, MGS_UNDERLINE and MGS_STRIKEOUT can be ored to form the lower three bits. MGS_LIGHT, MGS_BOLD and MGS_HEAVY are three predefined values for the weight that can also be ored.
Returns
A negative value in case of error, positive otherwise.

◆ mgsSetFontColor()

int mgsSetFontColor ( int  scr,
int  tc,
int  bc 
)

Sets the color of the text and the background to be used in later calls to display text. The background can be made transparent setting it to MGS_TRANSPARENT.

Parameters
[in]scrGraphic screen reference number.
[in]tcText color.
[in]bcBackground color; transparent if using MGS_TRANSPARENT.
Returns
A negative value in case of error, positive otherwise.

◆ mgsPuts()

int mgsPuts ( int  scr,
int  x,
int  y,
char *  str 
)

Prints the given screen at the given coordinates, that reference the top left corner of the text. Only the visible part of the text is shown.

Parameters
[in]scrGraphic screen reference number.
[in]xHorizontal coordinate of the left top point of the text.
[in]yVertical coordinate of the left top point of the text.
[in]strString to be displayed.
Returns
A negative value in case of error, positive otherwise.

◆ mgsPutsAligned()

int mgsPutsAligned ( int  scr,
int  mode,
int  l,
int  t,
int  r,
int  b,
char *  str 
)

Prints the given text according to the alignment mode and coordinates. If the flag MGS_TSCREEN is ored in mode, the coordinates are the whole screen, otherwise the rectangle formed by (l, t) and (r, b). Mode is formed oring three mutually exclusive modes per dimension to specify the alignment. MGS_TLEFT, MGS_TRIGHT and MGS_THCENTER for the horizontal and MGS_TTOP, MGS_TBOTTOM and MGS_TVCENTER for the vertical. The text is displayed outside the given rectangle unless the MGS_TCUT flag is ored in mode. In this case, the text is cut to fit in the rectangle. No boundary checks are perfored on the size of the text against the coordinates.

Parameters
[in]scrGraphic screen reference number.
[in]modeAlignment mode. See the description.
[in]lHorizontal coordinate of the top left point of the bounding rectangle.
[in]tVertical coordinate of the top left top point of the bounding rectangle.
[in]rHorizontal coordinate of the bottom right point of the bounding rectangle.
[in]bVertical coordinate of the bottom right top point of the bounding rectangle.
[in]strString to be displayed.
Returns
A negative value in case of error, positive otherwise.

◆ mgsTextSize()

int mgsTextSize ( int  scr,
char *  str,
int *  y 
)

Measures the width and height in pixels of a given string, according to the current font selected for the screen. The angle is considered to be horizontal, if the selected font is rotated, the correction has to be done outside this function.

Parameters
[in]scrGraphic screen reference number.
[in]strString to be measured.
[out]yPointer to the height in pixels of the text. This value is discarded if the pointer is NULL.
Returns
Width in pixels of the text or a negative value in case of error.

◆ mgsMouseButtons()

int mgsMouseButtons ( int  scr)

Each time a button is pressed or released when the cursor is over the given screen its state is recorded. When we call this function we get its current state, formed oring MGS_MOUSELEFT, MGS_MOUSERIGHT and MGS_MOUSECENTER if the corresponding button is pressed

Parameters
[in]scrGraphic screen reference number.
Returns
The state of the buttons. The bit mask assigned to each one is set if it is pressed.

◆ mgsMouseX()

int mgsMouseX ( int  scr)

Each time the cursor moves over the screen its position is tracked. This function returns its x coordinate if over the screen or the last it took before leaving

Parameters
[in]scrGraphic screen reference number.
Returns
The x coordinate of the cursor over the screen.

◆ mgsMouseY()

int mgsMouseY ( int  scr)

Each time the cursor moves over the screen its position is tracked. This function returns its y coordinate if over the screen or the last it took before leaving

Parameters
[in]scrGraphic screen reference number.
Returns
The y coordinate of the cursor over the screen.

◆ mgsMouseGlobal()

int mgsMouseGlobal ( int *  y)

This function returns the horizontal and vertical coordinates of the cursor over the full desktop. 0,0 is the upper left corner. If y is null only the horizontal is returned

Parameters
[out]yThe y coordinate of the cursor over the screen.
Returns
The x coordinate of the cursor over the screen.

◆ mgsMouseIn()

int mgsMouseIn ( int  scr)

This function returns 1 if the cursor is over the screen or 0 otherwise. Negative value in case of error

Parameters
[in]scrGraphic screen reference number.
Returns
1 if the cursor is over the screen, 0 otherwise.

◆ mgsMouseWheel()

int mgsMouseWheel ( int  scr,
unsigned char  res 
)

Returns the last ammount rotated using the central wheel of the mouse if the screen is selected . Positive means forward, and negative backwards -towards the user-. This value is not acumulative, but remains unchanged unless it is forced to be reset.

Parameters
[in]scrGraphic screen reference number.
[in]resA value other than 0 resets the stored value to 0.
Returns
The x coordinate of the cursor over the screen.

◆ mgsHandleMouse()

void mgsHandleMouse ( int  scr)

This function fills all the required data structures needed for the advanced mouse handling functions, according to the activity of the mouse on the screen. Has to be called once per frame or iteration if other advanced functions are to be used.

Parameters
[in]scrGraphic screen reference number.

◆ mgsMouseClicked()

unsigned char mgsMouseClicked ( int  scr,
unsigned char  b,
int  x0,
int  y0,
int  x1,
int  y1 
)

This function returns true if the user has clicked -pressed and released- the given mouse button on the rectangular region specified. The if the cursor moves out of the rectanble between press and release but both occur when it is over it, true is returned. If either press or release occur with the cursor out of the region, the return value is false. Specific macros exist to check only one of the mouse buttons.

Parameters
[in]scrGraphic screen reference number.
[in]bMouse button, one of _MLEFT, _MCENTER o _MRIGHT.
[in]x0Leftmost horizontal coordinate of the rectangular region.
[in]y0Top vertical coordinate of the rectangular region.
[in]x1Rightmost horizontal coordinate of the rectangular region.
[in]y1Bottom vertical coordinate of the rectangular region.
Returns
1 -true- if the user clicked on the rectagular region of scr with the given button, 0 -false- otherwise. Errors on screen or button number return 0.

◆ mgsMousePressed()

unsigned char mgsMousePressed ( int  scr,
unsigned char  b,
int  x0,
int  y0,
int  x1,
int  y1 
)

This function returns the pressed state of the button with regard to the rectangular region specified. It can be no pressed at all MGS_MNO, pressed and on the region MGS_MIN or pressed and out of the region MGS_MOUT. When pressed, the flag MGS_MNEW indicates that it has been recently pressed -according to the calls to mgsHandleMouse(). Specific macros exist to check only one of the mouse buttons.

Parameters
[in]scrGraphic screen reference number.
[in]bMouse button, one of _MLEFT, _MCENTER o _MRIGHT.
[in]x0Leftmost horizontal coordinate of the rectangular region.
[in]y0Top vertical coordinate of the rectangular region.
[in]x1Rightmost horizontal coordinate of the rectangular region.
[in]y1Bottom vertical coordinate of the rectangular region.
Returns
MGS_MNO if the button is not pressed or any error on screen or button number. MGS_MIN if it is pressed and on the rectangle; MGS_MOUT if it is pressed and out of the rectangle. The flag MGS_MNEW is ored with the value if it has been recently pressed.

◆ mgsMouseOver()

unsigned char mgsMouseOver ( int  scr,
int  x0,
int  y0,
int  x1,
int  y1 
)

This function returns true if the cursor is on the screen and over the given rectangle

Parameters
[in]scrGraphic screen reference number.
[in]x0Leftmost horizontal coordinate of the rectangular region.
[in]y0Top vertical coordinate of the rectangular region.
[in]x1Rightmost horizontal coordinate of the rectangular region.
[in]y1Bottom vertical coordinate of the rectangular region.
Returns
Not 0 -true- if the cursor is over the rectagular region of the screen 0 -false- otherwise. Errors on screen number return 0.

◆ mgsKeyPressed()

unsigned char mgsKeyPressed ( int  keyCode)

Retruns 1 if the given key is pressed, 0 otherwise. While the mouse input functions are per screen, this one is system wise as the keyboard is not related to any specific window. When the key represents a printable character as its main function, its ASCII code is used as parameters, in capital form in case of letters. Else a predefinde constant is used, as MGS_KALT for the ALT key or MGS_KF5 for the F5 function key.

Parameters
[in]keyCodeThe code of the key to be checked.
Returns
1 if the key is pressed, 0 otherwise.

◆ mgsPlaySoundFile()

int mgsPlaySoundFile ( char *  fs,
int  mode 
)

This function plays a sound read from the given .wav file. If a previos sound is being it is cancelled, no mixing is performed. If the flag MGS_LOOP is used, the sound is played in a loop, else it is played to its end.

Parameters
[in]fsThe name of the sound file.
[in]modeMGS_LOOP to play the sound in a loop or 0 to play it once.
Returns
A negative value in case of error, positive otherwise.

◆ mgsSetFrameTime()

void mgsSetFrameTime ( int  ms)

This functions sets the current frame duration for synchronized animations.

Parameters
[in]msThe new frame duration in ms (> 4). The default frame time is 20ms (50 FPS).

◆ mgsWaitFrame()

void mgsWaitFrame ( void  )

This is the main synchronization function for animations. Whenever it is called it calculated the time lapse since it was previously called. If it is less than the frame time (as it should be) it sleeps the remaining frame time. This function also calculates some values to perform performance measurement using mgsPerformanceMeasure()

◆ mgsPerformanceMeasure()

double mgsPerformanceMeasure ( int  m)

This is an utility function to calculate the relation between the frame time and the processing time in the main loop. It can give mean absoulte milliseconds or relative % (when MGS_PMRELATIVE is ored) measure of the remaining or used (when MGS_PMUSED is ored) time always against the current frame duration. If the MGS_PMRESET flag is ored the accumulated values to calculate the mean are reset to 0.

Parameters
[in]mThe measure mode, ored of the flags above.
Returns
The measured free or used, absolute o relative time.

◆ mgsShowError()

void mgsShowError ( int  err,
char *  msg,
int  flags 
)

This functions displays information about the error whose code is passed as parameter. If it is a system error, also the Windows error number obtained with GetLsstError() is shown. Oring the MGS_EFWIN flag a windows message box is used, else a console message is displayed. In this last case, oring MGS_EFWAIT causes the system to wait for pressing the 'C' key.

Parameters
[in]errThe error code returned by the last call.
[in]msgAn additional user string to be displayed.
[in]flagsThe display mode, ored of the flags above.

◆ mgsVersionData()

struct mgsInfo mgsVersionData ( void  )

Retruns a mgsInfo structure holding the major and minor version numbers, the maximum and free number of screens, the maximun and free number of images, and the frame time. The mgsInfo strucuture is formed by 7 integers:

  • vMajor: Version major number
  • vMinor: Version minor number
  • maxScr: Maximum number of screens
  • freeScr: Current number of free screens
  • maxImg: Maximum number of images
  • freeImg: Current number of free images
  • frmTime: Current frame duration in ms
    Returns
    A mgsInfo structure with these values.