public void mutate ( float amount ) { for ( int i = 0 ; i < numKnots ; i ++ ) { int rgb = yKnots [ i ] ; int r = ( ( rgb >> 16 ) & 0xff ) ; int g = ( ( rgb >> 8 ) & 0xff ) ; int b = ( rgb & 0xff ) ; r = PixelUtils . clamp ( ( int ) ( r + amount * 255 * ( Math . random ( ) - 0.5 ) ) ) ; g = PixelUtils . clamp ( ( int ) ( g + amount * 255 * ( Math . random ( ) - 0.5 ) ) ) ; b = PixelUtils . clamp ( ( int ) ( b + amount * 255 * ( Math . random ( ) - 0.5 ) ) ) ; yKnots [ i ] = 0xff000000 | ( r << 16 ) | ( g << 8 ) | b ; knotTypes [ i ] = RGB | SPLINE ; } sortKnots ( ) ; rebuildGradient ( ) ; }
Mutate the gradient .