protected override void OnMouseDown(int x, int y) { _latestBrushPathCache = null; _latestMousePoint = new PixelFarm.Agg.Imaging.Point(x, y); _points.Clear(); _myBrushPath = new PixelFarm.Agg.Samples.MyBrushPath(); _myBrushPath.FillColor = PixelFarm.Drawing.Color.Red; _points.Add(new System.Drawing.Point(x, y)); _myBrushPath.AddPointAtFirst(x, y); }
protected override void OnMouseMove(int x, int y) { _points.Add(new System.Drawing.Point(x, y)); //dragging //--------- //find diff Vector newPoint = new Vector(x, y); //find distance Vector oldPoint = new Vector(_latestMousePoint.x, _latestMousePoint.y); Vector delta = (newPoint - oldPoint) / 2; // 2,4 etc //midpoint Vector midPoint = (newPoint + oldPoint) / 2; delta = delta.NewLength(5); delta.Rotate(90); Vector newTopPoint = midPoint + delta; Vector newBottomPoint = midPoint - delta; //bottom point _myBrushPath.AddPointAtFirst((int)newBottomPoint.X, (int)newBottomPoint.Y); _myBrushPath.AddPointAtLast((int)newTopPoint.X, (int)newTopPoint.Y); _latestMousePoint = new PixelFarm.Agg.Imaging.Point(x, y); }