import java.awt.*;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.StreamTokenizer;

public class Main
extends Frame{
	Color[][] image;
	public static void main(String [] args){
		new Main();
	}
	
	public Main(){
		image = loadPPM();
		
	/*	dx = 1;
		tab = new int[platki][2];
		for(int i=0; i<tab.length; i++){
			tab[i][0] = (int)(Math.random() * 640);
			tab[i][1] = (int)(Math.random() * 480);
		}
	*/	
		setSize( 640, 480);
		setVisible(true);
		
		addWindowListener(
			new WindowAdapter(){
				public void windowClosing(WindowEvent evt){
					System.exit(0);
				}
			}
		);
		
	}
	public void paint(Graphics g){
	
		for(int i=0; i < image.length; i++){
			for( int j=0; j < image[i].length; j++){
				g.setColor(image[i][j]);
				g.drawLine(50 + j, 50 + i, 50 + j, 50 + i);
			}
		}
	
	}
		
	
		public static Color[][] loadPPM(){
			try {
				FileReader fr = new FileReader("C:\\Users\\DELL\\Downloads\\Snow.ppm");
				StreamTokenizer st = new StreamTokenizer(fr);
				
				st.nextToken();
				st.nextToken();
				st.nextToken();
				st.nextToken();
				st.nextToken();
				st.nextToken();
				int sze = (int)st.nval;
				st.nextToken();
				int wys = (int)st.nval;
				st.nextToken();
				
				Color data[][] = new Color[wys][sze];
				
				for(int i=0; i<data.length; i++){
					for(int j=0; j<data[i].length; j++){
						st.nextToken();
						int r = (int)st.nval;
						st.nextToken();
						int g = (int)st.nval;
						st.nextToken();
						int b = (int)st.nval;
						data[i][j] = new Color(r, g, b);
					}
				}
				return data;
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			} catch (IOException ex){
				ex.printStackTrace();
			}	
			return null;
		}
		
		
		
		
		
		
		
		
		
	}
	
	
	
	
	
	
	
	
	
	
	
	
