示例#1
0
 public MessageFrame(char c, ConsoleColor forcolor, ConsoleColor backcolor, Rect r, DrawPoint p) : this(c, r)
 {
     forColor       = forcolor;
     this.backcolor = backcolor;
     Pin            = p;
     Bounds         = r.OffsetPin(Pin);
 }
示例#2
0
 public void DrawLine(DrawPoint drawPoint)
 {
     if (initialized)
     {
         mainWindow.DrawLine(drawPoint);
     }
 }
示例#3
0
        public static List <DrawPoint> Find(DrawPoint start, List <DrawPoint> inner, DrawPoint finish)
        {
            if (inner.IsNullOrEmpty())
            {
                return new List <DrawPoint> {
                           start, finish
                }
            }
            ;

            if (inner.Count == 1)
            {
                return new List <DrawPoint> {
                           start, inner[0], finish
                }
            }
            ;

            var finder = inner.Count <= HeuristicPathFinder.MaxVertexes
                                ? (IPathFinder) new HeuristicPathFinder(start, inner, finish)
                                : new FastPathFinder(start, inner, finish);

            return(finder.Find());
        }
    }
}
示例#4
0
 /// <summary>
 /// Initiates a draw object
 /// </summary>
 /// <param name="width">Width of display</param>
 /// <param name="height">Height of display</param>
 /// <param name="StartBuffer">First buffer screen to display</param>
 /// <param name="Title">Title of console program</param>
 public Draw(int width, int height, DrawPoint[,] StartBuffer, string Title)
 {
     Console.CursorVisible = false;
     this.Width            = width;
     this.Height           = height;
     this.CurrDisplay      = DrawPoint.Const(' ', Color.White, new DrawPoint[width, height]);
     this.Buffer           = DrawPoint.CopyTo(StartBuffer, new DrawPoint[width, height]);
     this.SafeGaurdBuffer  = DrawPoint.CopyTo(StartBuffer, new DrawPoint[width, height]);
     if (Console.BufferHeight < Height)
     {
         Console.BufferHeight = Height;
     }
     if (Console.BufferWidth < Width)
     {
         Console.BufferWidth = Width;
     }
     if (Console.WindowHeight < Height)
     {
         Console.WindowHeight = Height;
     }
     if (Console.WindowWidth < Width)
     {
         Console.WindowWidth = Width;
     }
     Console.Title = Title;
 }
 /// <summary>
 /// Creates a New simple Frame
 /// </summary>
 /// <param name="c">The border character</param>
 /// <param name="r">The bounding box to draw to</param>
 /// <param name="forcolor">The color of the border</param>
 /// <param name="backcolor">The color of the background</param>
 /// <param name="p">The Relative pin direction</param>
 public Frame(char c, Rect r, ConsoleColor forcolor, ConsoleColor backcolor, DrawPoint p) : this(c, r)
 {
     this.forColor  = forcolor;
     this.backcolor = backcolor;
     Pin            = p;
     this.Bounds    = r.OffsetPin(this.Pin);
 }
示例#6
0
    //Draw a line when one point is selected and another is clicked
    public void DrawLine(GameObject obj2)
    {
        /*
         * LineRenderer lr = LineParent.AddComponent<LineRenderer>();
         * List<Vector3> pos = new List<Vector3>();
         * pos.Add(genVec3Pos(selected));
         * pos.Add(genVec3Pos(obj2));
         * lr.startWidth = 1f;
         * lr.endWidth = 1f;
         * lr.SetPositions(pos.ToArray());
         * lr.useWorldSpace = true;
         * lr.renderingLayerMask = 9;
         */
        DrawPoint selecteddp = selected.GetComponent <DrawPoint>();
        DrawPoint obj2dp     = obj2.GetComponent <DrawPoint>();

        if (selecteddp != null && obj2dp != null)
        {
            if (!selecteddp.connections.Contains(obj2))
            {
                createALine(selected, obj2);
                selected.GetComponent <DrawPoint>().connections.Add(obj2);
                obj2.GetComponent <DrawPoint>().connections.Add(selected);
            }
            else
            {
                //any code to fire if the connection already exists
            }
        }
        resetSelection();
    }
        private void Canvas_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            if (DrawHandler.GetInstance().CanDraw)
            {
                if (e.LeftButton == MouseButtonState.Pressed)
                {
                    Line line = new Line();

                    SolidColorBrush brush = new SolidColorBrush();
                    brush.Color = DrawHandler.GetInstance().Color;
                    line.Stroke = brush;

                    line.StrokeThickness = DrawHandler.GetInstance().LineThickness;
                    line.X1 = currentPoint.X;
                    line.Y1 = currentPoint.Y;
                    line.X2 = e.GetPosition(this).X;
                    line.Y2 = e.GetPosition(this).Y;

                    currentPoint = e.GetPosition(this);

                    DrawPoint drawpoint = DrawPoint.CreatePointFromLine(line, DrawHandler.GetInstance().Color);
                    this.connector.SendDrawPoint(drawpoint);

                    paintSurface.Children.Add(line);
                }
            }
        }
示例#8
0
        public override void OnReceive(Context context, Intent intent)
        {
            // Do stuff here
            var service = Mvx.Resolve <ISignatureService>() as DroidSignatureService;

            if (service != null)
            {
                var fileStore    = intent.GetStringExtra("fileStore");
                var pointsString = intent.GetStringArrayExtra("points");

                if (string.IsNullOrWhiteSpace(fileStore) || pointsString.Length == 0)
                {
                    service.Cancel();
                }
                else
                {
                    var points = pointsString.Select(i => DrawPoint.Parse(i));



                    service.Complete(new SignatureResult(
                                         false,
                                         () => new FileStream(fileStore, FileMode.Open, FileAccess.Read, FileShare.Read),
                                         points
                                         ));
                }
            }
            Android.App.Application.Context.UnregisterReceiver(this);
        }
示例#9
0
        private void InitializeOptions()
        {
            _points    = new List <Point>();
            ClientSize = new Size(1280, 800);

            var pen        = new Pen(Color.Black);
            var brushColor = Color.Black;
            var graphics   = CreateGraphics();

            //Иницилизация наших классов
            _drawLine       = new DrawLine(graphics, pen, brushColor);
            _drawRectangles = new DrawRectangle(graphics, pen, brushColor);
            _drawPoint      = new DrawPoint(CreateGraphics(), pen, brushColor);
            _drawCircle     = new DrawCircle(graphics, pen, brushColor);
            _drawTriangle   = new DrawTriangle(graphics, pen, brushColor);

            EventMainColor();
            EventBrushColor();

            mainColorButton.BackColor  = pen.Color;
            brushColorButton.BackColor = brushColor;

            _count = 0;

            PositionLabel.Location = new Point(this.Width - 125, this.Height - 70);

            TimerDraw.Start();
        }
        public List <DrawPoint> Find()
        {
            var pointGroups = inner.GroupBy(point => point.X).OrderBy(g => g.Key).Select(g => g.OrderBy(point => point.Y));

            if (string.CompareOrdinal(start.X, finish.X) > 0)
            {
                pointGroups = pointGroups.Reverse();
            }
            var res = new List <DrawPoint>(inner.Count + 2)
            {
                start
            };

            foreach (var group in pointGroups)
            {
                var g = group.ToList();
                if (g.Count == 1)
                {
                    res.Add(g.First());
                    continue;
                }

                if (DrawPoint.GetDistance(res.Last(), g.First()) > DrawPoint.GetDistance(res.Last(), g.Last()))
                {
                    g.Reverse();
                }
                res.AddRange(g);
            }

            res.Add(finish);
            return(res);
        }
示例#11
0
        /// <summary> Produces a color from the specified coordinates and colors. </summary>
        public Pixel Grade(Sample u, Sample v, Sample w, DrawPoint p)
        {
            int R = u.Color.R + v.Color.R + w.Color.R;
            int G = u.Color.G + v.Color.G + w.Color.G;
            int B = u.Color.B + v.Color.B + w.Color.B;

            return new Pixel((byte) (R/3), (byte) (G/3), (byte) (B/3));
        }
示例#12
0
 /// <summary> Produces a color from the specified coordinates and colors. </summary>
 public Pixel Grade(Sample u, Sample v, Sample w, DrawPoint p)
 {
     if (p.BarycentricCoordinates.U >= p.BarycentricCoordinates.V && p.BarycentricCoordinates.U >= p.BarycentricCoordinates.W)
         return u.Color;
     if (p.BarycentricCoordinates.V >= p.BarycentricCoordinates.W)
         return v.Color;
     return w.Color;
 }
示例#13
0
        public static PointF GetPointF(this DrawPoint drawpoint)
        {
            if (drawpoint.IsEmpty)
            {
                return(PointF.Empty);
            }

            return(new PointF(drawpoint.X, drawpoint.Y));
        }
示例#14
0
        public static CGPoint GetPointF(this DrawPoint drawpoint)
        {
            if (drawpoint.IsEmpty)
            {
                return(CGPoint.Empty);
            }

            return(new CGPoint(drawpoint.X, drawpoint.Y));
        }
示例#15
0
 /// <summary> Produces a color from the specified coordinates and colors. </summary>
 public Pixel Grade(Sample u, Sample v, Sample w, DrawPoint p)
 {
     int val = (p.Point.X + p.Point.Y) % 3;
     if (val == 0)
         return u.Color;
     if (val == 1)
         return v.Color;
     return w.Color;
 }
示例#16
0
 void SETUP(int ScreenWidth, int ScreenHeight, string GameName, bool LTRTTB_TTBLTR)
 {
     Camera                 = new Object("CAMERA", new Vector2(ScreenWidth, ScreenHeight), new Vector2(0, 0));
     DisplayBuffer          = DrawPoint.InitPoint(ScreenWidth, ScreenHeight);
     DisplayBuffer          = DrawPoint.Const(BackgroundChar, Background, DisplayBuffer);
     Renderer               = new Draw(ScreenWidth, ScreenHeight, DisplayBuffer, GameName);
     Renderer.LTRTTB_TTBLTR = LTRTTB_TTBLTR;
     Renderer.Start();
     AddObject(Camera);
 }
示例#17
0
    public void UpdateBuffer(DrawPoint[,] Buffer)
    {
        if (SafeGaurdBuffer != Buffer)
        {
            this.SafeGaurdBuffer = DrawPoint.CopyTo(Buffer, this.SafeGaurdBuffer);
            DrawScreen();
        }

        CurrFrames++;
    }
示例#18
0
    //NOTE: there are still some weird artifacts going on as if something is being rounded the wrong way --- no idea if this is still the case i hafta look into it - TODO
    //yes there are indeed still some artifacts around the 0 coordinate but that will hafta wait
    public void RenderScreen()
    {
        Vector2 localPos;
        Vector2 AdditionVector;
        Vector2 LastPos;

        GetCollision(Camera);
        DisplayBuffer = DrawPoint.Const(BackgroundChar, Background, DisplayBuffer);
        for (int i = 0; i < Camera.CollidingObjects.Count; i++)
        {
            if (Camera.CollidingObjects[i].Visible)
            {
                if (Camera.CollidingObjects[i].NAME != Camera.NAME && !Camera.CollidingObjects[i].TEXT_OBJ)
                {
                    LastPos  = Camera.CollidingObjects[i].GetPos() - 1;
                    localPos = Camera.LocalizePos(Camera.CollidingObjects[i]);
                    if (Camera.CollidingObjects[i].GetSize() > 1)
                    {
                        localPos -= Camera.CollidingObjects[i].GetSize() / 2;
                    }
                    for (int y = 0; y < Camera.CollidingObjects[i].GetSize().y; y++)
                    {
                        AdditionVector = Vector2.Copy(localPos);
                        LastPos.y      = y + localPos.y - 1;
                        if (LastPos.y == ExMath.Round(y + localPos.y))
                        {
                            AdditionVector.y++;
                        }
                        for (int x = 0; x < Camera.CollidingObjects[i].GetSize().x; x++)
                        {
                            LastPos.x = x + localPos.x - 1;
                            if (LastPos.x == ExMath.Round(x + localPos.x))
                            {
                                AdditionVector.x++;
                            }
                            DisplayBuffer = DrawPoint.InsertAsMiddle(DisplayBuffer, (int)ExMath.Round(x + AdditionVector.x), (int)ExMath.Round(y + AdditionVector.y), '#', Camera.CollidingObjects[i].Color);
                        }
                    }
                }
                else if (Camera.CollidingObjects[i].TEXT_OBJ)
                {
                    localPos = Camera.LocalizePos(Camera.CollidingObjects[i]);
                    string[] TEXT = Camera.CollidingObjects[i].Text.Split("\r\n");
                    for (int y = 0; y < TEXT.Length; y++)
                    {
                        for (int x = 0; x < TEXT[y].Length; x++)
                        {
                            DisplayBuffer = DrawPoint.InsertAsMiddle(DisplayBuffer, (int)ExMath.Round(x + localPos.x), (int)ExMath.Round(localPos.y - y), TEXT[y][x], Camera.CollidingObjects[i].Color);
                        }
                    }
                }
            }
        }
        Renderer.UpdateBuffer(DisplayBuffer);
    }
示例#19
0
 public void AddPoint(DrawPoint drawPoint, long sender)
 {
     foreach (KeyValuePair <long, IServerStreamWriter <DrawPoint> > kvp in receivers)
     {
         if (kvp.Key == sender)
         {
             continue;
         }
         kvp.Value.WriteAsync(drawPoint);
     }
 }
示例#20
0
 public static DrawPoint[,] InitPoint(int width, int height)
 {
     DrawPoint[,] Out = new DrawPoint[width, height];
     for (int y = 0; y < height; y++)
     {
         for (int x = 0; x < width; x++)
         {
             Out[x, y] = new DrawPoint();
         }
     }
     return(Out);
 }
示例#21
0
        public static BinaryPatch GeneratePatch(Dictionary <int, int> newSpells)
        {
            for (int i = 0; i < DrawPoint.OriginalData.Length; i++)
            {
                var drawPoint = new DrawPoint(DrawPoint.OriginalData[i]);
                if (newSpells.ContainsKey(i))
                {
                    drawPoint.Spell = (DrawPoint.Magic)newSpells[i];
                }
                DrawPoint.UpdatedDrawPoints[i + 1] = drawPoint;
            }

            return(new BinaryPatch(DrawPoint.DrawPointDefsLocation, DrawPoint.OriginalData, DrawPoint.EncodeAll()));
        }
示例#22
0
        /// <summary> Produces a color from the specified coordinates and colors. </summary>
        public Pixel Grade(Sample u, Sample v, Sample w, DrawPoint p)
        {
            int uSum = u.Color.R + u.Color.G + u.Color.B;
            int vSum = v.Color.R + v.Color.G + v.Color.B;
            int wSum = w.Color.R + w.Color.G + w.Color.B;

            if (uSum > vSum && uSum > wSum)
            {
                return u.Color;
            }
            else if (vSum > wSum)
                return v.Color;
            else
                return w.Color;
        }
示例#23
0
 public static DrawPoint[,] Const(char Char, Color Color, DrawPoint[,] Buffer)
 {
     for (int y = 0; y < Buffer.GetLength(1); y++)
     {
         for (int x = 0; x < Buffer.GetLength(0); x++)
         {
             if (Buffer[x, y] == null)
             {
                 Buffer[x, y] = new DrawPoint();
             }
             Buffer[x, y].DisplayChar  = Char;
             Buffer[x, y].DisplayColor = Color;
         }
     }
     return(Buffer);
 }
示例#24
0
 //FUNCTIONS
 public static DrawPoint[,] CopyTo(DrawPoint[,] ObjToCopy, DrawPoint[,] ObjToTransferTo)
 {
     for (int y = 0; y < ObjToCopy.GetLength(1); y++)
     {
         for (int x = 0; x < ObjToCopy.GetLength(0); x++)
         {
             if (ObjToTransferTo[x, y] == null)
             {
                 ObjToTransferTo[x, y] = new DrawPoint();
             }
             ObjToTransferTo[x, y].DisplayChar  = ObjToCopy[x, y].DisplayChar;
             ObjToTransferTo[x, y].DisplayColor = ObjToCopy[x, y].DisplayColor;
         }
     }
     return(ObjToTransferTo);
 }
示例#25
0
 public bool SetPoint(ImageCtl drawArea, string value)
 {
     try
     {
         string[]  s  = value.Split(';');
         DrawPoint dp = new DrawPoint(Convert.ToInt32(s[0]), Convert.ToInt32(s[1]));
         dp.ID = Convert.ToInt32(s[2]);
         drawArea.GraphicsList.UnselectAll();
         drawArea.GraphicsList.Add(dp);
         drawArea.Capture = true;
         drawArea.Refresh();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
        public void DrawLine(DrawPoint drawPoint)
        {
            Application.Current.Dispatcher.Invoke(new Action(() => {
                Line line             = new Line();
                SolidColorBrush brush = new SolidColorBrush();

                brush.Color = drawPoint.Color;
                line.Stroke = brush;

                line.StrokeThickness = drawPoint.Thickness;
                line.X1 = drawPoint.X1;
                line.X2 = drawPoint.X2;
                line.Y1 = drawPoint.Y1;
                line.Y2 = drawPoint.Y2;

                paintSurface.Children.Add(line);
            }));
        }
示例#27
0
        /// <summary> Produces a color from the specified coordinates and colors. </summary>
        public Pixel Grade(Sample u, Sample v, Sample w, DrawPoint p)
        {
            if (p.BarycentricCoordinates.U >= 0.9)
                return u.Color;
            if (p.BarycentricCoordinates.V >= 0.9)
                return v.Color;
            if (p.BarycentricCoordinates.W >= 0.9)
                return w.Color;

            int valU = (int)(p.Point.X + p.Point.Y + p.BarycentricCoordinates.U + r.Next(0, 4)) % 4;
            int valV = (int)(p.Point.X + p.Point.Y + p.BarycentricCoordinates.V + r.Next(0, 4)) % 4;
            int valW = (int)(p.Point.X + p.Point.Y + p.BarycentricCoordinates.W + r.Next(0, 4)) % 4;

            if (p.BarycentricCoordinates.U >= p.BarycentricCoordinates.V && p.BarycentricCoordinates.U >= p.BarycentricCoordinates.W)
                return ditherFurther(u.Color, v.Color, w.Color, valU);
            if (p.BarycentricCoordinates.V >= p.BarycentricCoordinates.W)
                return ditherFurther(v.Color, w.Color, w.Color, valV);

            return ditherFurther(w.Color, v.Color, u.Color, valW);
        }
示例#28
0
 private void OnPointChanged(object sender, DrawPoint e)
 {
     if (e.Y >= y || e.Y < 0)
     {
         return;
     }
     if (e.ColorNumber != 0)
     {
         tetrisFieldRectangles[e.Y][e.X].Stroke = new SolidColorBrush(Color.FromRgb(31, 31, 31));
         tetrisFieldRectangles[e.Y][e.X].Fill   = new ImageBrush
         {
             ImageSource = colorsDictionary[e.ColorNumber]
         };
     }
     else
     {
         tetrisFieldRectangles[e.Y][e.X].Stroke = new SolidColorBrush(tetrisFieldBackgroundColor);
         tetrisFieldRectangles[e.Y][e.X].Fill   = new SolidColorBrush(tetrisFieldBackgroundColor);
     }
 }
        private int[] GetTree()
        {
            var dist   = new int[VertexCount];
            var parent = new int[VertexCount];
            var used   = new bool[VertexCount];

            parent[0] = int.MaxValue;
            for (var i = 1; i < dist.Length; ++i)
            {
                dist[i]   = int.MaxValue;
                parent[i] = int.MaxValue;
            }

            for (var t = 0; t < VertexCount; ++t)
            {
                var current = 0;
                for (var i = 0; i < VertexCount; ++i)
                {
                    if (used[current] || !used[i] && dist[current] > dist[i])
                    {
                        current = i;
                    }
                }
                used[current] = true;
                for (var i = 0; i < VertexCount; ++i)
                {
                    if (used[i])
                    {
                        continue;
                    }
                    var d = DrawPoint.GetDistance(GetPoint(current), GetPoint(i));
                    if (d < dist[i])
                    {
                        dist[i]   = d;
                        parent[i] = current;
                    }
                }
            }

            return(parent);
        }
        public static void GetExtra(this Intent intent, Expression <Func <IEnumerable <DrawPoint> > > property)
        {
            GetToProperty(property, (p, d) => {
                var list = intent.GetStringArrayExtra(p);

                if (list != null && list.Count() > 0)
                {
#if DEBUG
                    Android.Util.Log.Info("Signature", "Has list " + list.Count());
#endif
                    return(list.Select(i => DrawPoint.Parse(i)));
                }
                else
                {
#if DEBUG
                    Android.Util.Log.Info("Signature", "No points");
#endif
                    return(null);
                }
            });
        }
示例#31
0
        private void panel1_MouseMove(object sender, MouseEventArgs e)
        {
            if (IsDown)
            {
                gs.FillEllipse(Br, e.X, e.Y, 2, 2);
                gs.Flush();
                gs.Save();

                gs2.FillEllipse(Br, e.X, e.Y, 2, 2);
                gs2.Flush();
                gs2.Save();

                DrawPoint tmp = new DrawPoint()
                {
                    X     = e.X,
                    Y     = e.Y,
                    Color = Br.Color.ToArgb()
                };

                Client.SendDataToALL(BufferFormat.FormatFCA(tmp));
            }
        }
示例#32
0
    void DrawScreen()
    {
        Buffer = DrawPoint.CopyTo(SafeGaurdBuffer, Buffer);
        switch (LTRTTB_TTBLTR)
        {
        case false:
            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    if ((Buffer[x, y].DisplayChar != CurrDisplay[x, y].DisplayChar) || (Buffer[x, y].DisplayColor != CurrDisplay[x, y].DisplayColor) || ForceDraw)
                    {
                        DrawToPoint(x, y);
                    }
                    ;
                }
            }
            break;

        case true:
            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    if ((Buffer[x, y].DisplayChar != CurrDisplay[x, y].DisplayChar) || (Buffer[x, y].DisplayColor != CurrDisplay[x, y].DisplayColor) || ForceDraw)
                    {
                        DrawToPoint(x, y);
                    }
                }
            }
            break;
        }

        Console.SetCursorPosition(0, 0);
        ForceDraw   = false;
        CurrDisplay = DrawPoint.CopyTo(Buffer, CurrDisplay);
    }
示例#33
0
        /// <summary>
        /// 在对应的DrawArea上画点或矩形
        /// </summary>
        /// <param name="drawArea">绘画的区域</param>
        /// <param name="x">矩形或点的x</param>
        /// <param name="y">矩形或点的y</param>
        /// <param name="width">宽度</param>
        /// <param name="height">高度</param>
        /// <param name="color">颜色</param>
        /// <param name="isRectangle">是否是矩形</param>
        private void Draw(DrawArea drawArea, Color color, int x, int y, int width = 2, int height = 2, bool isRectangle = false)
        {
            DrawObject o;

            if (isRectangle)
            {
                o = new DrawRectangle(x, y, width, height, Color.Red, Color.Green, drawArea.DrawFilled, drawArea.LineWidth);
            }
            else
            {
                o = new DrawPoint(x, y, color, drawArea.LineWidth);
            }

            int al = drawArea.TheLayers.ActiveLayerIndex;

            drawArea.TheLayers[al].Graphics.UnselectAll();

            o.Selected = true;
            o.Dirty    = true;
            o.ID       = DrawObject.sCurrentDrawObjectId++;

            drawArea.TheLayers[al].Graphics.Add(o);
            drawArea.Invalidate();
        }
示例#34
0
 /// <summary> Produces a color from the specified coordinates and colors. </summary>
 public Pixel Grade(Sample u, Sample v, Sample w, DrawPoint p)
 {
     return u.Color;
 }
示例#35
0
 private static bool BadState(DrawPoint p1, DrawPoint p2, DrawPoint p3)
 => Equals(p1.X, p2.X, p3.X) && InOrder(p1.Y, p2.Y, p3.Y) ||
 Equals(p1.Y, p2.Y, p3.Y) && InOrder(p1.X, p2.X, p3.X);
示例#36
0
 private static bool IsCorrectPoint(DrawPoint point)
 => point != null && AddPointHandler.IsCorrentCoordinate(point.X) && AddPointHandler.IsCorrentCoordinate(point.Y);