示例#1
0
        private void DrawStrokePart(StrokePart part, Graphics graphics, Pen pen1, Pen pen2)
        {
            Vector2f topLeft = new Vector2f(10, 10);
            Vector2f scale   = new Vector2f(0.01f, 0.01f);

            if (allStrokes.Count > 0)
            {
                KanjiMatcher.CalcResize(allStrokes, matchedTemplate, out topLeft, out scale);
            }

            graphics.DrawLine(pen1,
                              new PointF(topLeft.X + part.StartPoint.X / scale.X, topLeft.Y + part.StartPoint.Y / scale.Y),
                              new PointF(topLeft.X + part.EndPoint.X / scale.X, topLeft.Y + part.EndPoint.Y / scale.Y));
            const int sections = 64;

            PointF[] roundPoints = new PointF[sections + 1];
            Vector2f delta       = part.EndPoint - part.StartPoint;
            Vector2f ortho       = new Vector2f(delta.Y, -delta.X);

            for (int i = 0; i <= sections; i++)
            {
                float    pos   = (float)i / sections;
                Vector2f point = part.GetGlobalFromProgress(pos);
                float    param = 1 - (2 * pos - 1) * (2 * pos - 1);
                point          = topLeft + new Vector2f(point.X / scale.X, point.Y / scale.Y);
                roundPoints[i] = new PointF(point.X, point.Y);
            }
            graphics.DrawLines(pen2, roundPoints);
        }