public Texture toGray() // converts this texture to gray { for (var i = width * height - 1; i >= 0; i--) { pixel[i] = ColorUtility.getGray(pixel[i]); } return(this); }