示例#1
0
 public Line(MutablePoint _start, MutablePoint _end, Color?_color)
 {
     initColor(_color);
     mutableStart   = _start;
     mutableEnd     = _end;
     isMutableStart = isMutableEnd = true;
 }
示例#2
0
 public Text(string _text, MutablePoint _center, float?_fontSize, Color?_color)
 {
     initNulls(_fontSize, _color);
     mutableCenter   = _center;
     text            = _text;
     isCenterMutable = true;
 }
示例#3
0
 public Line(MutablePoint _start, PointF _end, Color?_color)
 {
     initColor(_color);
     mutableStart   = _start;
     end            = _end;
     isMutableStart = true;
     isMutableEnd   = false;
 }
示例#4
0
 public Circle(PointF _center, float r, bool isFilled = false, bool isActive = false)
 {
     center        = _center;
     this.r        = r;
     this.isFilled = isFilled; this.isActive = isActive;
     mutableCenter = new MutablePoint(center);
     borderColor   = Color.Black; fillColor = Color.Green; activeColor = Color.Red;
     isDragging    = false;
 }
示例#5
0
 public Circle(Circle other)
 {
     center        = other.center;
     r             = other.r;
     isFilled      = other.isFilled;
     mutableCenter = other.mutableCenter;
     borderColor   = other.borderColor;
     isDragging    = other.isDragging;
 }
示例#6
0
        static public Line getLineBetween(Circle from, Circle to)
        {
            //bool needToSwap = false;
            //if (from.Center.X > to.Center.X)
            //{
            //    needToSwap = true;
            //    Swap<Circle>(ref from, ref to);
            //}
            MutablePoint mutableStart = new MutablePoint(() =>
            {
                bool needToSwap = false;
                Circle _from    = new Circle(from), _to = new Circle(to);
                if (from.Center.X >= to.Center.X)
                {
                    needToSwap = true;
                    Swap <Circle>(ref _from, ref _to);
                    if (from.Center.X == to.Center.X)
                    {
                        //Console.WriteLine("equals");
                        _to.Center.X += 0.02f;
                    }
                }
                float devidor = (_to.MutableCenter.value.X - _from.MutableCenter.value.X);
                float ang1    = (float)Math.Atan((_to.MutableCenter.value.Y - _from.MutableCenter.value.Y) / (devidor == 0?0.0001f:devidor)),
                ang2          = (float)Math.PI + ang1;
                return(needToSwap?_to.calcPointOnCircle(ang2):_from.calcPointOnCircle(ang1));
            }),
            mutableEnd = new MutablePoint(() =>
            {
                bool needToSwap = false;
                Circle _from    = new Circle(from), _to = new Circle(to);
                if (from.Center.X >= to.Center.X)
                {
                    needToSwap = true;
                    Swap <Circle>(ref _from, ref _to);
                    if (from.Center.X == to.Center.X)
                    {
                        //Console.WriteLine("equals");
                        _to.Center.X += 0.02f;
                    }
                }
                float devidor = (_to.MutableCenter.value.X - _from.MutableCenter.value.X);
                float ang1    = (float)Math.Atan((_to.MutableCenter.value.Y - _from.MutableCenter.value.Y) / (devidor == 0?0.0001f:devidor)),
                ang2          = (float)Math.PI + ang1;
                return(!needToSwap ? _to.calcPointOnCircle(ang2) : _from.calcPointOnCircle(ang1));
            });

            //if (needToSwap)
            //{
            //    Swap<MutablePoint>(ref mutableStart, ref mutableEnd);
            //}
            Line edge = new Line(mutableStart, mutableEnd, Color.Black);

            return(edge);
        }
示例#7
0
 public MutablePoint(MutablePoint _target, Func <PointF> _func)
 {
     target = _target;
     func   = _func;
     mode   = "dynamic_offset";
 }
示例#8
0
 public MutablePoint(MutablePoint _target, PointF fix_offset)
 {
     target = _target;
     offset = fix_offset;
     mode   = "fix_offset";
 }