public void Display( PngEncoder surface, IEnumerable<MapPoint> mapPoints ) { if( surface == null ) throw new ArgumentNullException( "surface" ); if( mapPoints == null ) throw new ArgumentNullException( "mapPoints" ); List<Point> points = new List<Point>(); foreach( MapPoint entry in mapPoints ) { points.Add( transform.Transform( new Point( entry.X, entry.Y ) ) ); } for( int y = 1; y < Height - 1; y++ ) { int rowStart = surface.GetRowStart( y ); for( int x = 1; x < Width - 1; x++ ) { //foreach( Point entry in points ) //{ // int px = ( int ) entry.X; // int py = ( int ) entry.Y; // if( x == px && y == py ) // { // surface.SetPixelAtRowStart( x, rowStart, PixelColor.R, PixelColor.G, PixelColor.B, PixelColor.A ); // break; // } //} if(x == y) surface.SetPixelAtRowStart( x, rowStart, PixelColor.R, PixelColor.G, PixelColor.B, PixelColor.A ); } } }
public void Display( PngEncoder surface, IEnumerable<MapPoint> mapPoints ) { if( surface == null ) throw new ArgumentNullException( "surface" ); if( mapPoints == null ) throw new ArgumentNullException( "mapPoints" ); //List<Point> points = new List<Point>(); //foreach( MapPoint entry in mapPoints ) //{ // points.Add( transform.Transform( new Point( entry.X, entry.Y ) ) ); //} byte[,] transparencies = new byte[Width, Height]; foreach( MapPoint point in mapPoints ) { Point p = transform.Transform(new Point(point.X, point.Y)); transparencies[Math.Max(Math.Min((int)p.X, Width-1), 0), Math.Max(Math.Min((int)p.Y, Height-1), 0)] = (Byte)255; } for( int y = 1; y < Height - 1; y++ ) { int rowStart = surface.GetRowStart( y ); for( int x = 1; x < Width - 1; x++ ) { //surface.SetPixelAtRowStart( x, rowStart, PixelColor.R, PixelColor.G, PixelColor.B, PixelColor.A ); surface.SetPixelAtRowStart( x, rowStart, PixelColor.R, PixelColor.G, PixelColor.B, transparencies[x, y] ); } } }
public void Display( PngEncoder surface, Color baseColor ) { for( int y = 1; y < _height - 1; y++ ) { int rowStart = surface.GetRowStart( y ); for( int x = 1; x < _width - 1; x++ ) { int xoffset = _buffer1[ x - 1, y ] - _buffer1[ x + 1, y ]; int yoffset = _buffer1[ x, y - 1 ] - _buffer1[ x, y + 1 ]; int shading = ( xoffset - yoffset ) / 2; xoffset = ( int ) ( xoffset / 35.0 ); yoffset = ( int ) ( yoffset / 35.0 ); int xnew = x + xoffset; if( xnew < 0 ) xnew = 0; if( xnew >= _width ) xnew = _width - 1; int ynew = y + yoffset; if( ynew < 0 ) ynew = 0; if( ynew >= _height ) ynew = _height - 1; byte tred = baseColor.R; byte tgreen = baseColor.G; byte tblue = baseColor.B; if( shading < 0 ) shading = 0; if( shading > 255 ) shading = 255; tred = Saturate( tred + shading ); tgreen = Saturate( tgreen + shading ); tblue = Saturate( tblue + shading ); surface.SetPixelAtRowStart( x, rowStart, tred, tgreen, tblue, Saturate( shading * 12) ); } } }
public RainDropPngRenderer( int width, int height ) { encoder = new PngEncoder( width, height ); renderer = new RainDropRenderer( width, height ); }
public PixelPngRenderer( int width, int height, IEnumerable<MapPoint> mapPoints ) { encoder = new PngEncoder( width, height ); renderer = new PixelRenderer( width, height ); MapPoints = mapPoints; }