[ Prev | Index | Next ]
Japanese English

Creating a Display Screen

Once you've drawn something to graphics resource, it won't mean much unless you display it on the screen or save it to a file.

In this section, we'll cover how to output the rendered image to the screen.

Creating a Display Window

To make use of 2D graphics in a running program, you'll need a screen to display the graphics data you've drawn.

For this, you can use functions from the "GUI" library to create a display window.

Creating a Window

To create a window, use the "newWindow" function from the GUI library.

- Function Format -
int newWindow( int x, int y, int width, int height, string title )

Arguments:

  • x, y: Coordinates of the top-left corner of the window.
  • width, height: Size of the window.
  • title: The title text to be shown in the window's title bar.

When you call this function, a window will be created and its assigned component ID will be returned as an int. A component ID is a unique identifier assigned to any GUI component.

Creating an Image Label

To display the contents of graphics data within a window, youfll need to create a GUI component called an **image label**. This can be done using the "newImageLabel" function.

- Function Format -
int newImageLabel ( int x, int y, int width, int height, int graphicsID )

Arguments:

  • x, y: Coordinates of the top-left corner of the image label.
  • width, height: Size of the image label.
  • grarphicsID: The ID of the graphics data you want to display.

This function returns the component ID of the image label that is created.

Repainting the Screen

To reflect changes in your GUI, you need to repaint the affected components.

If you change the contents of the graphics resource, for example, the GUI components that display it -- such as image labels or windows -- will not update automatically. You must explicitly request a repaint to update the screen.

To do this, use the paintComponent function.

- Function Format -
void paintComponent ( int componentID )

Arguments:

  • componentID: The component ID of the GUI element you want to repaint (e.g., the value returned by "newWindow" or "newImageLabel" functions).

Whenever you finish drawing 2D graphics, make sure to call this function to update the screen properly.

Example Program


import Graphics;
import Graphics2D;
import GUI;

// Create graphics resource
int graphicsID = newGraphics( );

// Create a renderer
int rendererID = newGraphics2DRenderer( 800, 600, graphicsID );

// Create a window (800x600) titled "Hello, 2DCG!"
int windowID = newWindow( 0, 0, 800, 600, " Hello , 2DCG ! " );

// Create an image label to show the graphics resource
int labelID = newImageLabel( 0, 0, 800, 600, graphicsID );

// Mount the image label onto the window
mountComponent( labelID, windowID );

// Paint the GUI components
paintComponent( labelID );
paintComponent( windowID );
Sample.vcssl

When you run this program, a window titled "Hello, 2DCG!" with a size of 800~600 will appear. The window will display the graphics content, but since nothing has been drawn yet, the screen will just show a blank area.

Execution Result
Note: The designs of the window shown in this image is schematic representations. The actual appearance may vary depending on the runtime environment.



Sponsored Link



Japanese English
Index
News From RINEARN
* VCSSL is developed by RINEARN.

VCSSL 3.4.52 Released: Enhanced Integration with External Programs and More
2025-05-25 - This update introduces enhancements to the external program integration features (e.g., for running C-language executables). Several other improvements and fixes are also included. Details inside.

Released: Latest Version of VCSSL with Fixes for Behavioral Changes on Java 24
2025-04-22 - VCSSL 3.4.50 released with a fix for a subtle behavioral change in absolute path resolution on network drives, introduced in Java 24. Details inside.

Released the Latest Versions of RINEARN Graph and VCSSL - Now Supporting Customizable Tick Positions and Labels!
2024-11-24 - Starting with this update, a new "MANUAL" tick mode is now supported, allowing users to freely specify the positions and labels of ticks on the graph. We'll explain the details and how to use it.

Released Exevalator 2.2: Now Compatible with TypeScript and Usable in Web Browsers
2024-10-22 - The open-source expression evaluation library, Exevalator, has been updated to version 2.2. It now supports TypeScript and can be used for evaluating expressions directly in web browsers. Explains the details.

Behind the Scenes of Creating an Assistant AI (Part 1: Fundamental Knowledge)
2024-10-07 - The first part of a series on how to create an Assistant AI. In this article, we introduce the essential knowledge you need to grasp before building an Assistant AI. What exactly is an LLM-based AI? What is RAG? And more.

Launching an Assistant AI to Support Software Usage!
2024-09-20 - We've launched an Assistant AI that answers questions about how to use RINEARN software and helps with certain tasks. Anyone with a ChatGPT account can use it for free. We'll explain how to use it.

Software Updates: Command Expansion in RINEARN Graph, and English Support in VCSSL
2024-02-05 - We updated our apps. This updates include "Enhancing the Command-Line Features of RINEARN Graph" and "Adding English Support to VCSSL." Dives into each of them!

Inside the Repetitive Execution Speedup Impremented in Vnano Ver.1.1
2024-01-17 - Delves into the update in Vnano 1.1 from a developer's viewpoint, providing detailed insights into the specific improvements made to the internal structure of the script engine.