Drawing command | Action |
---|---|
Cls | Clears the viewport |
Plot | Draws a single pixel |
DrawLine | Draws a line |
DrawRect | Draws a rectangle |
DrawOval | Draws an oval |
DrawPoly | Draws a polygon |
DrawText | Draws some text |
DrawImage | Draws an image |
DrawPixmap | Draws a pixmap |
Blend mode | Effect |
---|---|
SOLIDBLEND | Pixels overwrite existing backbuffer pixels |
MASKBLEND | Pixels are drawn only if their alpha component is greater than .5 |
ALPHABLEND | Pixels are alpha blended with existing backbuffer pixels |
LIGHTBLEND | Pixel colors are added to backbuffer pixel colors, giving a 'lighting' effect |
SHADEBLEND | Pixel colors are multiplied with backbuffer pixel colors, giving a 'shading' effect |
LockImage allows for direct Image pixel access and requires a corresponding call to UnlockImage when you have have finished reading or modifying the pixels. The DrawPixmap and GrabPixmap commands allow you to move pixels to and from the current graphic display's backbuffer.
The current Scale, Rotation, Origin and Handle settings are taken into account so coordinates for the collision commands acurately match their drawing counterparts DrawRect and DrawImage.
ResetCollisions is used
to clear any or all of the 32 collision layers provided.
Returns: Number of available graphics modes
Use GetGraphicsMode to obtain information about an individual graphics mode
GetGraphicsMode returns information about a�pecific graphics mode. mode should be
in the range 0 (inclusive) to the value returned by CountGraphicsModes (exclusive).
Returns: True if a matching graphics mode is found
A value of 0 for any of width, height, depth or hertz will cause that
parameter to be ignored.
Sets the current Max2D graphics mode. This command must be executed before any other Max2D commands.
width and height specify the size, in pixels, of the graphics mode, depth specifies the bit depth and hertz
specifies the refresh rate.
A depth value of 0 enables 'windowed mode'. This special mode is currently intended for
debugging purposes only and should not be used for release builds. Improved support for
windowed modes will be added shortly.
EndGraphics closes the current full screen 2D graphics display
created with the Graphics command.
Flip can only be used after a call to Graphics and must be executed to show the results of any drawing commands.
BlitzMax uses a double buffered graphics system where all drawing is done to a Back Buffer
and what is shown on the screen is known as the Front Buffer. Flip causes the buffers
to be swapped allowing for fast flicker free graphics animation.
Clears the back buffer to the current SetClsColor. The default ClsColor is Black.
After a Flip command the contents of the back buffer is undefined, most often containing
the contents of the last Front Buffer making a call to Cls() essential before calling
any drawing commands in order to create the next frame of graphics for display.
The red, green and blue parameters should be in the range of 0 to 255.
Sets the color of a rectangular area of pixels using the current drawing color defined with the SetColor command.
Other commands that affect the operation of DrawRect include SetHandle, SetScale,
SetRotation, SetOrigin, SetViewPort, SetBlend and SetAlpha.
DrawLine draws a line from x,y to x2,y2 with the current drawing color.
BlitzMax commands that affect the drawing of lines include SetLineWidth, SetColor, SetHandle,
SetScale, SetRotation, SetOrigin, SetViewPort, SetBlend and SetAlpha.
DrawOval draws an oval that fits in the rectangular area defined by x, y, width and height parameters.
BlitzMax commands that affect the drawing of ovals include SetColor, SetHandle,
SetScale, SetRotation, SetOrigin, SetViewPort, SetBlend and SetAlpha.
DrawPoly draws a polygon with corners defined by an array of x#,y# coordinate pairs.
BlitzMax commands that affect the drawing of polygons include SetColor, SetHandle,
SetScale, SetRotation, SetOrigin, SetViewPort, SetBlend and SetAlpha.
DrawText prints strings at position x,y of the graphics display using the current image font specified by the SetImageFont command.
Other commands that affect DrawText include SetColor, SetHandle,
SetScale, SetRotation, SetOrigin, SetViewPort, SetBlend and SetAlpha.
Drawing is affected by the current blend mode, color, scale and rotation.
If the blend mode is ALPHABLEND, then the image is also affected by the current alpha value.
Drawing is affected by the current blend mode, color, scale and rotation.
If the blend mode is ALPHABLEND, then the image is also affected by the current alpha value.
TileImage draws an image in a repeating, tiled pattern, filling the current viewport.
SetBlend controls how pixels are combined with existing pixels in the back buffer when drawing commands are used in BlitzMax.
blend should be one of:
Blend mode | Effect |
---|---|
SOLIDBLEND | Pixels overwrite existing backbuffer pixels |
MASKBLEND | Pixels are drawn only if their alpha component is greater than .5 |
ALPHABLEND | Pixels are alpha blended with existing backbuffer pixels |
LIGHTBLEND | Pixel colors are added to backbuffer pixel colors, giving a 'lighting' effect |
SHADEBLEND | Pixel colors are multiplied with backbuffer pixel colors, giving a 'shading' effect |
alpha should be in the range 0 to 1.
alpha controls the transparancy level when the ALPHABLEND blend mode is in effect.
The range from 0.0 to 1.0 allows a range of transparancy from completely transparent
to completely solid.
The current mask color is used to build an alpha mask when images are loaded or modified.
The red, green and blue parameters should be in the range of 0 to 255.
The current ViewPort defines an area within the back buffer that all drawing is clipped to. Any
regions of a DrawCommand that fall outside the current ViewPort are not drawn.
The current Origin is an x,y coordinate added to all drawing x,y coordinates after any rotation or scaling.
The drawing handle is a 2D offset added to the x,y location of all drawing commands. Unlike SetOrigin,
the drawing handle is added before rotation and scale are applied providing a local origin.
rotation is given in degrees and should be in the range 0 to 360.
scale_x and scale_y multiply the width and height of drawing
commands where 0.5 will half the size of the drawing and 2.0 is equivalent
to doubling the size.
SetTransform is a shortcut for setting both the rotation and
scale parameters in Max2D with a single function call.
Returns: An image font object
In order to DrawText in fonts other than the default system font use the SetImageFont
command with a font handle returned by the LoadImageFont command.
Returns: The width, in pixels, of text based on the current image font.
This command is useful for calculating horizontal alignment of text when using
the DrawText command.
Returns: The width, in pixels, of text based on the current image font.
This command is useful for calculating vertical alignment of text when using
the DrawText command.
Returns: A new image object
url can be either a string or an existing pixmap.
flags can be 0, -1, or any combination of:
Flags value | Effect |
---|---|
FILTEREDIMAGE | The image is smoothed when scaled or rotated |
DYNAMICIMAGE | The image can be modified using LockImage or GrabImage |
MASKEDIMAGE | The image is masked with the current mask color |
Returns: An image object
LoadAnimImage extracts multiple image frames from a single, larger image. url can be either a string or an
existing pixmap.
See LoadImage for valid flags values.
When auto midhandle mode is enabled, all images are automatically 'midhandled' (see MidHandleImage)
when they are created. If auto midhandle mode is disabled, images are handled by their top left corner.
Returns: The width, in pixels, of image
Returns: The height, in pixels, of image
Returns: A new image object
CreateImage creates an 'empty' image, which should be initialized using either GrabImage or LockImage
before being drawn.
Please refer to LoadImage for valid flags values. The flags value is always combined with DYNAMICIMAGE.
Returns: A pixmap representing the image contents
Locking an image allows you to directly access an image's pixels.
Only images created with the DYNAMICIMAGE flag can be locked.
Locked images must eventually be unlocked with UnlockImage before they can be drawn.
Unlocks an image previously locked with LockImage.
Copies pixels from the back buffer to an image frame.
Only images created with the DYNAMICIMAGE flag can be grabbed.
The collidemask specifies any layers to test for collision with.
The writemask specifies which if any collision layers the image is added to in it's currently transformed state.
The id specifies an object to be returned to future CollideImage calls when collisions occur.
The collidemask specifies any layers to test for collision with.
The writemask specifies which if any collision layers the image is added to in it's currently transformed state.
The id specifies an object to be returned to future CollideImage calls when collisions occur.
Returns: The width, in pixels, of the current Graphics mode
Returns: The height, in pixels, of the current Graphics mode
Returns: The width and height in pixels, the depth in bits and the frequency in hertz of the current Graphics mode.
Returns: Red, green and blue values in the range 0..255
Returns: Red, green and blue values in the range 0..255
Returns: the current alpha value in the range 0..1.0
Returns: 0 (SOLIDBLEND), 1 (MASKBLEND) ,2 (ALPHABLEND), 3 (LIGHTBLEND) or 4 (SHADEBLEND).
Returns: The horizontal and vertical position of the current origin
Returns: The horizontal and vertical position of the current drawing handle
Returns: The horizontal, vertical, width and height values of the current Viewport
Returns: The rotation in degrees
Returns: The rotation in degrees
Returns: The current font
Module | brl.max2d |
Version | 1.02 |
Author | Mark Sibly, Simon Armstrong |
License | Blitz Shared Source Code |
Copyright | Blitz Research Ltd |
Modserver | BRL |