예제 #1
0
        private static void SaveToBmp(List <Circle3D> projected)
        {
            int        size  = 2000;
            Bitmap     image = new Bitmap(size, size);
            double     b     = 5.0;
            ImageSpace i     = new ImageSpace(size, size);

            i.XMin = -b;
            i.XMax = b;
            i.YMin = -b;
            i.YMax = b;

            float scale = 0.5f;

            using (Graphics g = Graphics.FromImage(image))
            {
                for (int m = 0; m < projected.Count; m++)
                {
                    using (Pen p = new Pen(projected[m].Color, scale * 3.0f))
                    {
                        Circle c = projected[m].ToFlatCircle();
                        if (c.IsLine)
                        {
                            DrawUtils.DrawLine(-c.P2 * 25, c.P2 * 25, g, i, p);                                 // XXX - not general.
                        }
                        else
                        {
                            DrawUtils.DrawCircle(c, g, i, p);
                        }
                    }
                }
            }

            image.Save("outerCircles.png");
        }
예제 #2
0
    public static void DrawGrid(Texture2D texture, int tileWidth, int tileHeight, Color color)
    {
        for (int y = 0; y < texture.height; y += tileHeight)
        {
            DrawUtils.DrawLine(texture, 0, y, texture.width, y, color);
        }

        for (int x = 0; x < texture.width; x += tileWidth)
        {
            DrawUtils.DrawLine(texture, x, 0, x, texture.height, color);
        }
    }
예제 #3
0
        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 );
                                 */
                            }
        }
예제 #4
0
    void DrawWireframe(Rect rectangle, Material material)
    {
        float xMin = rectangle.xMin;
        float yMin = rectangle.yMin;
        float xMax = rectangle.xMax;
        float yMax = rectangle.yMax;

        Vector2 p1 = new Vector2(xMin, yMax);
        Vector2 p2 = new Vector2(xMax, yMax);
        Vector2 p3 = new Vector2(xMax, yMin);
        Vector2 p4 = new Vector2(xMin, yMin);

        DrawUtils.DrawLine(p1, p2, material);
        DrawUtils.DrawLine(p2, p3, material);
        DrawUtils.DrawLine(p3, p4, material);
        DrawUtils.DrawLine(p4, p1, material);
    }
예제 #5
0
 static int DrawLine(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 4);
         UnityEngine.Vector3 arg0 = ToLua.ToVector3(L, 1);
         UnityEngine.Vector3 arg1 = ToLua.ToVector3(L, 2);
         UnityEngine.Color   arg2 = ToLua.ToColor(L, 3);
         float arg3 = (float)LuaDLL.luaL_checknumber(L, 4);
         DrawUtils.DrawLine(arg0, arg1, arg2, arg3);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #6
0
 public static void DrawSquare(Texture2D texture, int x, int y, int width, int height, Color color, bool filled = false)
 {
     if (filled)
     {
         Color[] colors = new Color[width * height];
         for (int i = 0; i < colors.Length; i++)
         {
             colors[i] = color;
         }
         texture.SetPixels(x, y, width, height, colors);
     }
     else
     {
         DrawUtils.DrawLine(texture, x, y, x + width, y, color);
         DrawUtils.DrawLine(texture, x, y, x, y + height, color);
         DrawUtils.DrawLine(texture, x, y + height, x + width, y + height, color);
         DrawUtils.DrawLine(texture, x + width, y, x + width, y + height, color);
     }
 }