Color AdvColorPix(int count) { // all new and improved colour engine
            int c1;
            int c2;
            int r;
            int g;
            int b;
            int or; //old red
            int og;
            int ob;
            double dr;
            double dg;
            double db;
            String fg; //foreground colour
            String bg; //background colour
            ClrVal.clear();
            for (int i = 0; i <= (count / 255) - 1; i++) ClrVal.add(255);
            if (ClrVal.size() < ColorIndex.size()) ClrVal.add(count % 255);

            if (ClrVal.size() >= 2) {
                fg = String.valueOf(ColorIndex.get(ClrVal.size() - 2));
                or = Integer.valueOf(fg.substring(0, 3));
                og = Integer.valueOf(fg.substring(3, 6));
                ob = Integer.valueOf(fg.substring(6, 9));
                c2 = Integer.valueOf(String.valueOf(ClrVal.get(ClrVal.size() - 1)));
                bg = String.valueOf(ColorIndex.get(ClrVal.size() - 1));

                dr = ((Integer.valueOf(bg.substring(0, 3)) - Integer.valueOf(fg.substring(0, 3))) / 256.0);
                dg = ((Integer.valueOf(bg.substring(3, 6)) - Integer.valueOf(fg.substring(3, 6))) / 256.0);
                db = ((Integer.valueOf(bg.substring(6, 9)) - Integer.valueOf(fg.substring(6, 9))) / 256.0);
                r = (int) ((or) + (c2 * dr));
                g = (int) ((og) + (c2 * dg));
                b = (int) ((ob) + (c2 * db));

            } else {
                c1 = Integer.valueOf(String.valueOf(ClrVal.get(ClrVal.size() - 1)));
                fg = String.valueOf(ColorIndex.get(ClrVal.size() - 1));

                dr = (Integer.valueOf(fg.substring(0,3))/256.0);
                dg = (Integer.valueOf(fg.substring(3,6))/256.0);
                db = (Integer.valueOf(fg.substring(6,9))/256.0);
                r =(int)(c1 * dr);
                g =(int)(c1 * dg);
                b =(int)(c1 * db);
            }
            if (r > 255 || g > 255 || b > 255 || r < 0 || g < 0 || b < 0) {
                System.out.println(r + "," + g + "," + b);
                return Color.black;
            }else {
                return new Color(r, g, b);
            }
        }