예제 #1
0
        public override void MouseUp(int x, int y)
        {
            if (currentSelectedPath != null)
            {
                this.currentSelectedPath.FillColor = ColorRGBA.Black;
            }
            this.currentSelectedPath = null;
            if (EditMode == Samples.EditMode.Select)
            {
                return;
            }

            if (currentBrushPath != null)
            {
                //1. close current path


                switch (currentBrushPath.BrushMode)
                {
                case SmoothBrushMode.CutBrush:
                {
                    currentBrushPath.MakeSmoothPath();
                    if (myBrushPathList.Count > 0)
                    {
                        //1. remove
                        myBrushPathList.RemoveAt(myBrushPathList.Count - 1);
                        //

                        if (myBrushPathList.Count > 0)
                        {
                            var lastPath = myBrushPathList[myBrushPathList.Count - 1];
                            //do path clip***
                            var paths = PixelFarm.Agg.VertexSource.VxsClipper.CombinePaths(new VertexStoreSnap(lastPath.Vxs),
                                                                                           new VertexStoreSnap(currentBrushPath.Vxs), VertexSource.VxsClipperType.Difference,
                                                                                           false);
                            myBrushPathList.RemoveAt(myBrushPathList.Count - 1);
                            MyBrushPath newBrushPath = new MyBrushPath();
                            newBrushPath.BrushMode   = lastPath.BrushMode;
                            newBrushPath.StrokeColor = lastPath.StrokeColor;
                            newBrushPath.FillColor   = lastPath.FillColor;
                            newBrushPath.SetVxs(paths[0]);
                            myBrushPathList.Add(newBrushPath);
                        }
                    }
                }
                break;

                case SmoothBrushMode.SolidBrush:
                {
                    //create close point
                    currentBrushPath.AddPointAtLast(x, y);
                    currentBrushPath.MakeSmoothPath();
                }
                break;
                }
                currentBrushPath = null;
            }

            base.MouseUp(x, y);
        }
예제 #2
0
 public override void MouseDrag(int x, int y)
 {
     //find diff
     Vector newPoint = new Vector(x, y);
     //find distance
     Vector oldPoint = new Vector(latestMousePoint.x, latestMousePoint.y);
     var delta = (newPoint - oldPoint) / 2; // 2,4 etc
     //midpoint
     var midPoint = (newPoint + oldPoint) / 2;
     //find angle
     var topPoint = delta;//create top point
     var bottomPoint = delta; //bottom point
     topPoint.Rotate(90);
     bottomPoint.Rotate(-90);
     var newTopPoint = midPoint + topPoint;
     var newBottomPoint = midPoint + bottomPoint;
     //bottom point
     currentBrushPath.AddPointAtFirst((int)newBottomPoint.X, (int)newBottomPoint.Y);
     currentBrushPath.AddPointAtLast((int)newTopPoint.X, (int)newTopPoint.Y);
     latestMousePoint = new Point(x, y);
 }
예제 #3
0
        public override void MouseUp(int x, int y)
        {
            if (currentSelectedPath != null)
            {
                this.currentSelectedPath.FillColor = Drawing.Color.Black;
            }
            this.currentSelectedPath = null;
            if (EditMode == Samples.EditMode.Select)
            {
                return;
            }

            if (currentBrushPath != null)
            {
                //1. close current path


                switch (currentBrushPath.BrushMode)
                {
                case SmoothBrushMode.CutBrush:
                {
                    currentBrushPath.MakeSmoothPath();
                    if (myBrushPathList.Count > 0)
                    {
                        //1. remove
                        myBrushPathList.RemoveAt(myBrushPathList.Count - 1);
                        //

                        if (myBrushPathList.Count > 0)
                        {
                            int j = myBrushPathList.Count - 1;
                            for (int i = j; i >= 0; --i)
                            {
                                //cut each path
                                var lastPath = myBrushPathList[i];
                                //do path clip***
                                List <VertexStore> paths = PixelFarm.Agg.VertexSource.VxsClipper.CombinePaths(new VertexStoreSnap(lastPath.Vxs),
                                                                                                              new VertexStoreSnap(currentBrushPath.Vxs), VertexSource.VxsClipperType.Difference,
                                                                                                              true);

                                myBrushPathList.RemoveAt(i);

                                if (i == j)
                                {
                                    //the last one
                                    for (int s = paths.Count - 1; s >= 0; --s)
                                    {
                                        MyBrushPath newBrushPath = new MyBrushPath();
                                        newBrushPath.BrushMode   = lastPath.BrushMode;
                                        newBrushPath.StrokeColor = lastPath.StrokeColor;
                                        newBrushPath.FillColor   = lastPath.FillColor;
                                        newBrushPath.SetVxs(paths[s]);
                                        myBrushPathList.Add(newBrushPath);         //add last
                                    }
                                }
                                else
                                {
                                    for (int s = paths.Count - 1; s >= 0; --s)
                                    {
                                        MyBrushPath newBrushPath = new MyBrushPath();
                                        newBrushPath.BrushMode   = lastPath.BrushMode;
                                        newBrushPath.StrokeColor = lastPath.StrokeColor;
                                        newBrushPath.FillColor   = lastPath.FillColor;
                                        newBrushPath.SetVxs(paths[s]);
                                        myBrushPathList.Insert(i, newBrushPath);
                                    }
                                }
                            }
                        }
                    }
                }
                break;

                case SmoothBrushMode.SolidBrush:
                {
                    //create close point
                    currentBrushPath.AddPointAtLast(x, y);
                    currentBrushPath.MakeSmoothPath();
                }
                break;
                }
                currentBrushPath = null;
            }

            base.MouseUp(x, y);
        }