!636 !629 // standard functions !658 // image classes import java.awt.*; import java.awt.image.*; import java.util.List; public class main { public static void main(String[] args) { JFrame frame = new JFrame("A JavaX Frame"); RGBImage image = new RGBImage(100, 100, Color.white); double splitPoint = random(); RGB col1 = new RGB(Color.green), col2 = new RGB(Color.blue); vsplit(image, splitPoint, col1, col2); ImageSurface panel = new ImageSurface(image); frame.add(panel); frame.setBounds(100, 100, 500, 400); frame.setVisible(true); exitOnFrameClose(frame); } static Random _random = new Random(); static double random() { return _random.nextInt(50001)/50000.0; } static void vsplit(RGBImage img, double splitPoint, RGB col1, RGB col2) { int w = img.getWidth(), h = img.getHeight(); for (int yy = 0; yy < h; yy++) for (int xx = 0; xx < w; xx++) { double x = ((double) xx)/(w-1); double y = ((double) yy)/(h-1); RGB col = y <= splitPoint ? col1 : col2; img.setPixel(xx, yy, col); } } }