Exemplo n.º 1
0
        //
        private ArrayOfPoints createLoop(int num)
        {
            ArrayOfPoints a = new ArrayOfPoints();

            if (num < 2)
            {
                log("createLoop error num must >=2,now num:" + num);
            }
            double angle = (double)(num - 2) * Math.PI / (double)(num);
            //
            MyPoint p = new MyPoint(-1, 0);

            a.push(p);
            int i;

            for (i = 1; i < num; i++)
            {
                p = a[i - 1];
                a.push(rotateMyPoint(new MyPoint(-p.X, -p.Y), angle));
            }

            a[0] = new MyPoint(0, 0);
            for (i = 1; i < num; i++)
            {
                MyPoint tempP = a[i];
                a[i] = tempP.add(a[i - 1]);
            }
            return(a);
        }
Exemplo n.º 2
0
 private ArrayOfPoints arrayAdd(ArrayOfPoints arr, MyPoint adden)
 {
     for (int i = 0; i < arr.Length; i++)
     {
         MyPoint p = arr[i];
         arr[i] = p.add(adden);
     }
     return(arr);
 }
Exemplo n.º 3
0
        private ArrayOfPoints getCutLine(MyPoint from, MyPoint to, double cut)
        {
            ArrayOfPoints r      = new ArrayOfPoints(2);
            MyPoint       origin = from;
            MyPoint       dir    = to.sub(from);
            double        len    = dir.Length;

            if (len <= cut * 2)
            {
                r[0] = from;
                r[1] = from;
                return(r);
            }
            dir  = pointMulti(dir, 1 / len);
            from = origin.add(pointMulti(dir, cut));
            to   = origin.add(pointMulti(dir, len - cut));
            //
            r[0] = from;
            r[1] = to;
            return(r);
        }
Exemplo n.º 4
0
        private void drawStr(Graphics g, String str, MyPoint p, float fontSize, Color fontColor)
        {
            MyPoint offset = new MyPoint((float)(-fontSize * 0.05), (float)(-fontSize * 0.17));

            g.DrawString(str, new Font("宋体", fontSize), new SolidBrush(fontColor), p.add(new MyPoint(-fontSize / 2, -fontSize / 2)).add(offset).toPointF());
        }