import Graphics; import Graphics2D; import GUI; // Create graphics data and renderer int graphicsID = newGraphics( ); int rendererID = newGraphics2DRenderer( 800, 500, graphicsID ); // Create display window int windowID = newWindow( 0, 0, 800, 500, "Hello 2DCG !" ); int labelID = newImageLabel( 0, 0, 800, 500, graphicsID ); mountComponent( labelID, windowID ); // Prepare pixel data arrays int red[ 500 ][ 800 ]; int green[ 500 ][ 800 ]; int blue[ 500 ][ 800 ]; int alpha[ 500 ][ 800 ]; // Set colors for each pixel for( int i=0; i<500; i++ ){ for( int j=0; j<800; j++ ){ // Red region: top-left area if( j < 500 && i < 300 ){ red[ i ][ j ] = 255; } else { red[ i ][ j ] = 0; } // Green region: central band if( 200 < j && j < 600 && 100 < i && i < 400 ){ green[ i ][ j ] = 255; } else { green[ i ][ j ] = 0; } // Blue region: bottom-right area if( 300 < j && 200 < i ){ blue[ i ][ j ] = 255; } else { blue[ i ][ j ] = 0; } // Fully opaque for all pixels alpha[ i ][ j ] = 255; } } // Apply pixel data to the renderer setPixel( rendererID, red, green, blue, alpha ); // Render GUI paintComponent( labelID ); paintComponent( windowID );