public static void DrawFilledCircle( Circle c, Graphics g, ImageSpace i, Brush b ) { Rectangle? rect = Rect( c, i ); if( rect == null ) return; g.FillEllipse( b, rect.Value ); }
public static void GenImage() { int size = 1000; Bitmap image = new Bitmap( size, size ); ImageSpace i = new ImageSpace( size, size ); double b = 1.1; i.XMin = -b; i.XMax = b; i.YMin = -b; i.YMax = b; Vector3D cen = HoneycombPaper.CellCenBall; cen = H3Models.BallToUHS( cen ); Sphere[] simplex = Simplex( ref cen ); Sphere inSphere = InSphere( simplex ); using( Graphics g = Graphics.FromImage( image ) ) foreach( int[] reflections in AllCells() ) { Sphere clone = inSphere.Clone(); foreach( int r in reflections ) clone.Reflect( simplex[r] ); Sphere ball = new Sphere(); Circle3D inSphereIdealBall = ball.Intersection( clone ); Circle3D inSphereIdealUHS = H3Models.BallToUHS( inSphereIdealBall ); Circle inSphereIdeal = new Circle { Center = inSphereIdealUHS.Center, Radius = inSphereIdealUHS.Radius }; using( Brush brush = new SolidBrush( Color.Blue ) ) DrawUtils.DrawFilledCircle( inSphereIdeal, g, i, brush ); } image.Save( "threefifty.png", ImageFormat.Png ); }
public static void DrawCircle( Circle c, Graphics g, ImageSpace i, Pen p ) { Rectangle? rect = Rect( c, i ); if( rect == null ) return; g.DrawEllipse( p, rect.Value ); }
static public void DrawTriangle(Mesh.Triangle triangle, Graphics g, ImageSpace i) { using (Pen pen = new Pen(Color.Black, 1.0f)) { g.DrawLine(pen, VecToPoint(triangle.a, i), VecToPoint(triangle.b, i)); g.DrawLine(pen, VecToPoint(triangle.b, i), VecToPoint(triangle.c, i)); g.DrawLine(pen, VecToPoint(triangle.c, i), VecToPoint(triangle.a, i)); } }
public static void DrawTriangle( Mesh.Triangle triangle, Graphics g, ImageSpace i ) { using( Pen pen = new Pen( Color.Black, 1.0f ) ) { g.DrawLine( pen, VecToPoint( triangle.a, i ), VecToPoint( triangle.b, i ) ); g.DrawLine( pen, VecToPoint( triangle.b, i ), VecToPoint( triangle.c, i ) ); g.DrawLine( pen, VecToPoint( triangle.c, i ), VecToPoint( triangle.a, i ) ); } }
static public void DrawFilledCircle(Circle c, Graphics g, ImageSpace i, Brush b) { Rectangle?rect = Rect(c, i); if (rect == null) { return; } g.FillEllipse(b, rect.Value); }
static public void DrawCircle(Circle c, Graphics g, ImageSpace i, Pen p) { Rectangle?rect = Rect(c, i); if (rect == null) { return; } g.DrawEllipse(p, rect.Value); }
private static Rectangle? Rect( Circle c, ImageSpace i ) { if( double.IsInfinity( c.Radius ) ) return null; Vector3D upperLeft = i.Pixel( new Vector3D( c.Center.X - c.Radius, c.Center.Y + c.Radius, 0 ) ); double width = i.Width( c.Radius * 2 ); double height = i.Height( c.Radius * 2 ); Rectangle rect = new Rectangle( (int)upperLeft.X, (int)upperLeft.Y, (int)width, (int)height ); return rect; }
static private Rectangle?Rect(Circle c, ImageSpace i) { if (double.IsInfinity(c.Radius)) { return(null); } Vector3D upperLeft = i.Pixel(new Vector3D(c.Center.X - c.Radius, c.Center.Y + c.Radius, 0)); double width = i.Width(c.Radius * 2); double height = i.Height(c.Radius * 2); Rectangle rect = new Rectangle((int)upperLeft.X, (int)upperLeft.Y, (int)width, (int)height); return(rect); }
static public void DrawCircle(Circle c, Graphics g, ImageSpace i) { if (double.IsInfinity(c.Radius)) { return; } Vector3D upperLeft = i.Pixel(new Vector3D(c.Center.X - c.Radius, c.Center.Y + c.Radius, 0)); double width = i.Width(c.Radius * 2); double height = i.Height(c.Radius * 2); Rectangle rect = new Rectangle((int)upperLeft.X, (int)upperLeft.Y, (int)width, (int)height); using (Pen pen = new Pen(Color.Black, 1.0f)) g.DrawEllipse(pen, rect); }
private void DrawMirrors( Bitmap image, Settings settings ) { double b = settings.Bounds; ImageSpace i = new ImageSpace( settings.Width, settings.Height ); i.XMin = -b; i.XMax = b; i.YMin = -b; i.YMax = b; float scale = 2; List<Sphere> toDraw = new List<Sphere>(); toDraw.AddRange( settings.Mirrors ); toDraw.Add( AlteredFacetForTrueApparent2DTilings( settings.Mirrors ) ); using( Graphics g = Graphics.FromImage( image ) ) using( Pen p = new Pen( Color.Red, scale * 3.0f ) ) //using( Pen p2 = new Pen( Color.FromArgb( 255, 255, 214, 0 ), 3.0f ) ) using( Pen p2 = new Pen( Color.Orange, scale * 3.0f ) ) using( Pen p3 = new Pen( Color.Orange, scale * 3.0f ) ) for( int m=0; m<toDraw.Count; m++ ) { Sphere s = toDraw[m]; Circle c = H3Models.UHS.IdealCircle( s ); // XXX - not correct if( c.IsLine ) { DrawUtils.DrawLine( -c.P2*25, c.P2*25, g, i, p ); // XXX - not general. } else { Sphere temp = H3Models.BallToUHS( s ); DrawUtils.DrawCircle( new Circle { Center = temp.Center, Radius = temp.Radius }, g, i, m == 0 ? p2 : m == 4 ? p3 : p ); } /* // iii Circle c = new Circle(); c.Radius = Math.Sqrt( 2 ); c.Center = new Vector3D( 1, Math.Sqrt( 2 ) ); DrawUtils.DrawCircle( c, g, i, p ); c.Center = new Vector3D( -1, Math.Sqrt( 2 ) ); DrawUtils.DrawCircle( c, g, i, p ); c.Center = new Vector3D( Math.Sqrt( 2 ) - 1, 0 ); c.Radius = 2 - Math.Sqrt( 2 ); DrawUtils.DrawCircle( c, g, i, p ); DrawUtils.DrawLine( new Vector3D( -2, 0 ), new Vector3D( 2, 0 ), g, i, p ); */ } }
static private Point VecToPoint(Vector3D vec, ImageSpace i) { Vector3D temp = i.Pixel(vec); return(new Point((int)temp.X, (int)temp.Y)); }
private static Point VecToPoint( Vector3D vec, ImageSpace i ) { Vector3D temp = i.Pixel( vec ); return new Point( (int)temp.X, (int)temp.Y ); }
public static void DrawLine( Vector3D p1, Vector3D p2, Graphics g, ImageSpace i, Pen p ) { g.DrawLine( p, VecToPoint( p1, i ), VecToPoint( p2, i ) ); }
public static void DrawCircle( Circle c, Graphics g, ImageSpace i ) { using( Pen pen = new Pen( Color.Black, 1.0f ) ) DrawCircle( c, g, i, pen ); }
static public void DrawCircle(Circle c, Graphics g, ImageSpace i) { using (Pen pen = new Pen(Color.Black, 1.0f)) DrawCircle(c, g, i, pen); }
static public void DrawLine(Vector3D p1, Vector3D p2, Graphics g, ImageSpace i, Pen p) { g.DrawLine(p, VecToPoint(p1, i), VecToPoint(p2, i)); }