Esempio n. 1
0
 /// <summary>
 /// Draws this shape using the given modulating color and transform.
 /// </summary>
 public void Draw(Render Render, Color4 Color, Transform Transform)
 {
     Render.Vertex(Transform * Destination.TopLeft, Source.TopLeft, Color);
     Render.Vertex(Transform * Destination.BottomLeft, Source.BottomLeft, Color);
     Render.Vertex(Transform * Destination.BottomRight, Source.BottomRight, Color);
     Render.Vertex(Transform * Destination.TopRight, Source.TopRight, Color);
 }
Esempio n. 2
0
 /// <summary>
 /// Draws this shape using the given scale and offset.
 /// </summary>
 public void Draw(Render Render, Color4 Color, Vector Offset, double Scale)
 {
     Render.Vertex(Destination.TopLeft * Scale + Offset, Source.TopLeft, Color);
     Render.Vertex(Destination.BottomLeft * Scale + Offset, Source.BottomLeft, Color);
     Render.Vertex(Destination.BottomRight * Scale + Offset, Source.BottomRight, Color);
     Render.Vertex(Destination.TopRight * Scale + Offset, Source.TopRight, Color);
 }
Esempio n. 3
0
        /// <summary>
        /// Draws an arrow connecting two points.
        /// </summary>
        public static void DrawArrow(Render Render, Color4 Color, Vector A, Vector B, double Width)
        {
            Vector dif = B - A;
            double len = dif.Length;
            Vector dir = dif / len;
            double linelen = len - ArrowSegment.Destination.Top * Width;

            LineSegment.Draw(Render, Color, new Transform(A, -dir.Cross * Width, dir * linelen));
            ArrowSegment.Draw(Render, Color, new Transform(A + dir * linelen, -dir.Cross * Width, dir * Width));
        }
Esempio n. 4
0
 /// <summary>
 /// Draws a digit of the given size to the given point.
 /// </summary>
 public static void DrawDigit(Render Render, uint Digit, Color4 Color, Vector Center, double Size)
 {
     Digits[Digit].Draw(Render, Color, Center, Size);
 }
Esempio n. 5
0
 /// <summary>
 /// Draws a circle.
 /// </summary>
 public static void DrawCircle(Render Render, Color4 Color, Vector Center, double Radius)
 {
     Circle.Draw(Render, Color, Center, Radius * 2.0);
 }
Esempio n. 6
0
 /// <summary>
 /// Draws an arrow starting at a given point going in the given direction for the given length.
 /// </summary>
 public static void DrawArrow(Render Render, Color4 Color, Vector Start, Vector Direction, double Length, double Width)
 {
     double linelen = Length - ArrowSegment.Destination.Top * Width;
     LineSegment.Draw(Render, Color, new Transform(Start, -Direction.Cross * Width, Direction * linelen));
     ArrowSegment.Draw(Render, Color, new Transform(Start + Direction * linelen, -Direction.Cross * Width, Direction * Width));
 }
Esempio n. 7
0
 /// <summary>
 /// Ends a drawing context.
 /// </summary>
 public static void End(Render Render)
 {
     Render.Finish();
 }
Esempio n. 8
0
 /// <summary>
 /// Starts a drawing context using the atlas texture.
 /// </summary>
 public static void Begin(out Render Render)
 {
     Hailstone.Texture.Bind(Atlas.Texture);
     Render = Render.Create(BeginMode.Quads);
 }
Esempio n. 9
0
        /// <summary>
        /// Draws a stone along with its "Next" link.
        /// </summary>
        public static void DrawStone(Render Render, Stone Stone, double Extent)
        {
            Color4 fillcolor;
            Color4 bordercolor;
            Color4 linecolor;
            Color4 highlightcolor;
            double numbersize = Settings.Current.StoneNumberSize;
            uint selection = Stone.GetSelectionIndex(Stone);
            if (selection != uint.MaxValue)
            {
                selection = (uint)Stone.Selection.Length - selection;
                float glow = (float)Math.Sin((Stone.SelectionPulsePhase + selection / Settings.Current.StonePulseLength) * Math.PI * 2.0) * 0.5f + 0.5f;

                fillcolor = Settings.Current.StoneFillColor.GetSelected(glow);
                bordercolor = Settings.Current.StoneBorderColor.GetSelected(glow);
                highlightcolor = Settings.Current.StoneHighlightColor.GetSelected(glow);
                linecolor = (selection != 0) ? bordercolor : Settings.Current.StoneBorderColor.GetUnselected();
                if (selection != 0 && Stone.Next != null && Stone.Next != Stone)
                {
                    Vector markerpos = Stone.Position + (Stone.Next.Position - Stone.Position).Normal.Cross * (Stone.Radius + 0.5);
                    Atlas.DrawNumber(Render, selection, new Color4(1.0f, 0.4f, 0.4f, 0.7f), markerpos, numbersize, numbersize);
                }
            }
            else
            {
                fillcolor = Settings.Current.StoneFillColor.GetUnselected();
                bordercolor = Settings.Current.StoneBorderColor.GetUnselected();
                highlightcolor = Settings.Current.StoneHighlightColor.GetUnselected();
                linecolor = bordercolor;
            }

            double size = Math.Max(1.0, Extent * 0.01);
            float light = (float)Math.Max(0.0, Math.Min(1.0, (Extent - 50.0) / 100.0));
            fillcolor = fillcolor.Mix(light, highlightcolor);
            Atlas.DrawFilledCircle(Render, fillcolor, Stone.Position, Stone.Radius * size);

            if (Extent < 120.0)
            {
                if (Stone.Next != null && Stone.Next != Stone)
                {
                    Vector dif = Stone.Next.Position - Stone.Position;
                    double len = dif.Length;
                    Vector dir = dif / len;
                    Vector start = Stone.Position + dir * Stone.Radius;
                    double linklen = len - Stone.Radius - Stone.Next.Radius;
                    if (linklen > 0.0)
                    {
                        double linkwidth = Settings.Current.LinkWidth;
                        if (linklen >= Settings.Current.LinkMinimumArrowLength)
                            Atlas.DrawArrow(Render, linecolor, start, dir, linklen, linkwidth);
                        else
                            Atlas.DrawLine(Render, linecolor, start, dir, linklen, linkwidth);
                    }
                }
                Atlas.DrawCircle(Render, bordercolor, Stone.Position, Stone.Radius);
                Atlas.DrawNumber(Render, Stone.Entry.Value, (Color4)Settings.Current.StoneNumberColor, Stone.Position, numbersize, numbersize * 0.8);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Draws a number to the given point.
        /// </summary>
        public static void DrawNumber(Render Render, uint Number, Color4 Color, Vector Center, double Size, double Spacing)
        {
            List<uint> digits = new List<uint>(5);
            if (Number == 0)
                digits.Add(0);
            else
                while (Number > 0)
                {
                    digits.Add(Number % 10);
                    Number /= 10;
                }

            double offset = (Spacing * (digits.Count - 1)) / 2.0;
            foreach (uint digit in digits)
            {
                DrawDigit(Render, digit, Color, new Vector(Center.X + offset, Center.Y), Size);
                offset -= Spacing;
            }
        }
Esempio n. 11
0
 /// <summary>
 /// Draws a line starting at a given point going in the given direction for the given length.
 /// </summary>
 public static void DrawLine(Render Render, Color4 Color, Vector Start, Vector Direction, double Length, double Width)
 {
     LineSegment.Draw(Render, Color, new Transform(Start, -Direction.Cross * Width, Direction * Length));
 }
Esempio n. 12
0
 /// <summary>
 /// Draws a line connecting two points.
 /// </summary>
 public static void DrawLine(Render Render, Color4 Color, Vector A, Vector B, double Width)
 {
     Vector dif = B - A;
     double len = dif.Length;
     Vector dir = dif / len;
     LineSegment.Draw(Render, Color, new Transform(A, -dir.Cross * Width, dif));
 }
Esempio n. 13
0
 /// <summary>
 /// Draws all the stones in the given zone.
 /// </summary>
 private void _DrawZone(Render Render, List<Stone> Zone, double Extent, List<Stone> Selected)
 {
     foreach (Stone stone in Zone)
     {
         if (Stone.GetSelectionIndex(stone) != uint.MaxValue)
             Selected.Add(stone);
         else
             Atlas.DrawStone(Render, stone, Extent);
     }
 }