package bot;

import java.io.*;
import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
import java.awt.image.ColorConvertOp;
import java.awt.color.ColorSpace;

public class Functions {
	public static BufferedImage convertToGrayscale(BufferedImage source) { 
		BufferedImageOp op = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null); 
		return op.filter(source, null);
	}
	
	public static boolean inArray(String s, String[] arr) {
		for(String s1 : arr)
			if(s.equals(s1))
				return true;
		return false;
	}
	
	public static boolean inArray(int i, int[] arr) {
		for(int i1 : arr)
			if(i == i1)
				return true;
		return false;
	}
	
	public static String parseSleepWord(String s) {
		String letters = "abcdefghijklmnopqrstuvwxyz ";
		char[] arr = s.toCharArray();
		char[] arr1 = letters.toCharArray();
		boolean found;
		String r = "";
		for(int i = 0; i < s.length(); i++) {
			found = false;
			for(int i1 = 0; i1 < letters.length(); i1++)
				if(Character.toString(s.charAt(i)).toLowerCase().equals(Character.toString(letters.charAt(i1))))
					found = true;
			if(found)
				r += Character.toString(s.charAt(i));
		}
		return r;
	}
}