Pretty simple really. Elegant code only 17 lines. study/copy this code and study how the variables change. Don't let the triple nested for loop confuse you, thats mostly to fill in the grid row by row, with changes to the rgb values only happening at the end of each row for the gradient effect.