The VCSSL Graphics library is one of the standard libraries for handling graphics in VCSSL.
In VCSSL, there are three standard libraries related to drawing: Graphics, Graphics2D, and Graphics3D.
Among them, the Graphics library provides management functions for drawing resources, while the Graphics2D and Graphics3D libraries provide the actual drawing functions.
To perform drawing, resources such as images, buffers, and streams are required.
In some, and probably many, languages, these are often treated as separate objects. In VCSSL, however, they are handled collectively as "graphics resources."
In other words, in VCSSL, both a buffer for rendering real-time 3DCG animation and a fixed image loaded from an image file are treated uniformly as "graphics resources."
The Graphics library provides management functions for these graphics resources, such as creation, disposal, input/output, and basic processing.
For example, to read the image file "input.png", make its black parts transparent, and export it as "output.png", write the following:
Functions are also provided for directly manipulating raster data (pixel arrays) to perform basic processing and drawing.
For more advanced drawing, use the Graphics2D and Graphics3D libraries together with this library.
- None -
- None -
| Name | newGraphics |
| Declaration | int newGraphics() |
| Description |
Creates a graphics resource and returns its unique identifier, called the graphics resource ID. The graphics resource created by this function holds an image of size 0 pixels. |
| Return | (int type) The graphics resource ID assigned to the created graphics resource. |
| Name | newGraphics |
| Declaration | int newGraphics( string filePath ) |
| Description |
Creates a graphics resource and returns its unique identifier, called the graphics resource ID. The graphics resource created by this function is pre-filled with an image loaded from an image file. |
| Parameters | (string type) filePath : The name or path of the image file. |
| Return | (int type) The graphics resource ID assigned to the created graphics resource. |
| Name | newGraphics |
| Declaration | int newGraphics( int red[ ][ ], int green[ ][ ], int blue[ ][ ], int alpha[ ][ ] ) |
| Description |
Creates a graphics resource and returns its unique identifier, called the graphics resource ID. The graphics resource created by this function is pre-filled with an image loaded from pixel arrays. |
| Parameters |
red[][] : The red component of pixels ([Y][X], 0 to 255). green[][] : The green component of pixels ([Y][X], 0 to 255). blue[][] : The blue component of pixels ([Y][X], 0 to 255). alpha[][] : The alpha component of pixels ([Y][X], 0 to 255). |
| Return | (int type) The graphics resource ID assigned to the created graphics resource. |
| Name | newGraphics |
| Declaration | int newGraphics( int rgba[ ][ ][ ] ) |
| Description |
Creates a graphics resource and returns its unique identifier, called the graphics resource ID. The graphics resource created by this function is pre-filled with an image loaded from a pixel array. |
| Parameters | rgba[][][] : The pixel color components ([Y][X][color-component index], where the color-component index is 0=red, 1=green, 2=blue, and 3=alpha, with each value ranging from 0 to 255). |
| Return | (int type) The graphics resource ID assigned to the created graphics resource. |
| Name | newGraphics |
| Declaration | int newGraphics( int baseGraphics, int fromRed, int fromGreen, int fromBlue, int fromAlpha, int toRed, int toGreen, int toBlue, int toAlpha ) |
| Description |
Creates a graphics resource and returns its unique identifier, called the graphics resource ID. The graphics resource created by this function is pre-filled with an image in which a specific color in another graphics resource has been converted to another color. |
| Parameters |
(int type) baseGraphics : The graphics resource ID of the source graphics resource holding the image to be converted. (int type) fromRed : The red component of the source color to convert (0 to 255). (int type) fromGreen : The green component of the source color to convert (0 to 255). (int type) fromBlue : The blue component of the source color to convert (0 to 255). (int type) fromAlpha : The alpha component of the source color to convert (0 to 255). (int type) toRed : The red component of the destination color (0 to 255). (int type) toGreen : The green component of the destination color (0 to 255). (int type) toBlue : The blue component of the destination color (0 to 255). (int type) toAlpha : The alpha component of the destination color (0 to 255). |
| Return | (int type) The graphics resource ID assigned to the created graphics resource. |
| Name | newGraphics |
| Declaration | int newGraphics( int baseGraphics, int fromColor[ ], int toColor[ ] ) |
| Description |
Creates a graphics resource and returns its unique identifier, called the graphics resource ID. The graphics resource created by this function is pre-filled with an image in which a specific color in another graphics resource has been converted to another color. |
| Parameters |
(int type) baseGraphics : The graphics resource ID of the source graphics resource holding the image to be converted. (int[] type) fromColor : The array storing the components of the source color to convert. (int[] type) toColor : The array storing the components of the destination color. |
| Return | (int type) The graphics resource ID assigned to the created graphics resource. |
| Name | newGraphics |
| Declaration | int newGraphics ( int baseGraphics, int width, int height, bool antialiasing ) |
| Description |
Creates a graphics resource and returns its unique identifier, called the graphics resource ID. The graphics resource created by this function is pre-filled with a resized version of another graphics resource. |
| Parameters |
(int type) baseGraphics : The graphics resource ID of the source graphics resource holding the original image. (int type) width : The width of the graphics resource to create. The original image is resized to this width. (int type) height : The height of the graphics resource to create. The original image is resized to this height. (bool type) antialiasing : Whether to smooth the resized result. If true is specified, the result becomes smoother, but processing time increases. |
| Return | (int type) The graphics resource ID assigned to the created graphics resource. |
| Name | newGraphics |
| Declaration | int newGraphics ( int baseGraphics, int cropX, int cropY, int cropWidth, int cropHeight ) |
| Description |
Creates a graphics resource and returns its unique identifier, called the graphics resource ID. The graphics resource created by this function is pre-filled with a cropped portion of another graphics resource. |
| Parameters |
(int type) baseGraphics : The graphics resource ID of the source graphics resource holding the original image. (int type) cropX : The X coordinate of the upper-left corner of the area to crop from the original image. (int type) cropY : The Y coordinate of the upper-left corner of the area to crop from the original image. (int type) cropWidth : The width of the area to crop from the original image. (int type) cropHeight : The height of the area to crop from the original image. |
| Return | (int type) The graphics resource ID assigned to the created graphics resource. |
| Name | deleteGraphics |
| Declaration | void deleteGraphics( int id ) |
| Description | Disposes a graphics resource. |
| Parameters | (int type) id : The ID of the target graphics resource. |
| Return | (void type) |
| Name | getGraphicsWidth |
| Declaration | int getGraphicsWidth( int id ) |
| Description | Returns the width, in pixels, of the image held by the graphics resource. |
| Parameters | (int type) id : The ID of the target graphics resource. |
| Return | (int type) The width, in pixels, of the target graphics resource. |
| Name | getGraphicsHeight |
| Declaration | int getGraphicsHeight( int id ) |
| Description | Returns the height, in pixels, of the image held by the graphics resource. |
| Parameters | (int type) id : The ID of the target graphics resource. |
| Return | (int type) The height, in pixels, of the target graphics resource. |
| Name | exportGraphics |
| Declaration | void exportGraphics( int id, string name, string format ) |
| Description | Outputs the image held by the graphics resource as an image file. |
| Parameters |
(int type) id : The ID of the target graphics resource. (string type) name : The output file name. (string type) format : The format of the output file. Specify "JPEG", "PNG", or "BMP". |
| Return | (void type) |
| Name | exportGraphics |
| Declaration | void exportGraphics( int id, string name, string format, double quality ) |
| Description | Outputs the image held by the graphics resource as an image file. |
| Parameters |
(int type) id : The ID of the target graphics resource. (string type) name : The output file name. (string type) format : The format of the output file. Specify "JPEG", "PNG", or "BMP". (double type) quality : The image quality (0.0 to 100.0). This is effective for JPEG. A larger value means higher quality. |
| Return | (void type) |
| Name | setGraphicsPixel |
| Declaration | void setGraphicsPixel( int id, int red[ ][ ], int green[ ][ ], int blue[ ][ ], int alpha[ ][ ] ) |
| Description | Replaces the image held by the graphics resource with the specified pixel arrays. |
| Parameters |
(int type) id : The ID of the target graphics resource. red[][] : The red component of pixels ([Y][X], 0 to 255). green[][] : The green component of pixels ([Y][X], 0 to 255). blue[][] : The blue component of pixels ([Y][X], 0 to 255). alpha[][] : The alpha component of pixels ([Y][X], 0 to 255). |
| Return | (void type) |
| Name | setGraphicsPixel |
| Declaration | void setGraphicsPixel( int id, int rgba[ ][ ][ ] ) |
| Description | Replaces the image held by the graphics resource with the specified pixel array. |
| Parameters |
(int type) id : The ID of the target graphics resource. rgba[][][] : The pixel color components ([Y][X][color-component index], where the color-component index is 0=red, 1=green, 2=blue, and 3=alpha, with each value ranging from 0 to 255). |
| Return | (void type) |
| Name | getGraphicsPixel |
| Declaration | int[ ][ ][ ] getGraphicsPixel( int id ) |
| Description | Returns an array storing all pixel color components of the image. |
| Parameters | (int type) id : The ID of the target graphics resource. |
| Return | (int[][][] type) The pixel color components ([Y][X][color-component index], where the color-component index is 0=red, 1=green, 2=blue, and 3=alpha, with each value ranging from 0 to 255). |
| Name | getGraphicsPixelRed |
| Declaration | int[ ][ ] getGraphicsPixelRed( int id ) |
| Description | Returns an array storing only the red component for all pixels of the image. |
| Parameters | (int type) id : The ID of the target graphics resource. |
| Return | (int[][] type) The red component of pixels ([Y][X], with values ranging from 0 to 255). |
| Name | getGraphicsPixelGreen |
| Declaration | int[ ][ ] getGraphicsPixelGreen( int id ) |
| Description | Returns an array storing only the green component for all pixels of the image. |
| Parameters | (int type) id : The ID of the target graphics resource. |
| Return | (int[][] type) The green component of pixels ([Y][X], with values ranging from 0 to 255). |
| Name | getGraphicsPixelBlue |
| Declaration | int[ ][ ] getGraphicsPixelBlue( int id ) |
| Description | Returns an array storing only the blue component for all pixels of the image. |
| Parameters | (int type) id : The ID of the target graphics resource. |
| Return | (int[][] type) The blue component of pixels ([Y][X], with values ranging from 0 to 255). |
| Name | getGraphicsPixelAlpha |
| Declaration | int[ ][ ] getGraphicsPixelAlpha( int id ) |
| Description | Returns an array storing only the alpha component for all pixels of the image. |
| Parameters | (int type) id : The ID of the target graphics resource. |
| Return | (int[][] type) The alpha component of pixels ([Y][X], with values ranging from 0 to 255). |