public Sample ( float x, float y, bool wrap = true, bool useCosineInterpolation = false ) : Color4 | ||
x | float | value within range 0..1 |
y | float | value within range 0..1 |
wrap | bool | |
useCosineInterpolation | bool | |
return | Color4 |
/// <summary> /// /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="img"></param> public void Copy ( int offsetX, int offsetY, Image img ) { for (int x=0; x<img.Width; x++) { for (int y=0; y<img.Height; y++) { Write( offsetX + x, offsetY + y, img.Sample( x, y ) ); } } }
/// <summary> /// http://www.lighthouse3d.com/opengl/terrain/index.php3?particle /// </summary> /// <param name="iterations"></param> /// <param name="displace"></param> /// <returns></returns> public static Image ParticleDeposition ( int sizeX, int sizeY, int iterations, float displace ) { var rand = new Random(); var image = new Image( sizeX, sizeY ); int x = rand.Next() % sizeX; int y = rand.Next() % sizeY; var disp = new Color4( displace, displace, displace, displace ); for (int i=0; i<iterations; i++) { int dir = rand.Next(4); if (dir==0) x++; if (dir==1) x--; if (dir==2) y++; if (dir==3) y--; var value = image.Sample(x,y); image.Write( x,y, value + disp ); } return image; }