コード例 #1
0
ファイル: GraphAnalyzer.cs プロジェクト: rudi-c/htn-stylus
        private void fillBar(double _x1, double _y1, double _x2, double _y2)
        {
            const double dist = 14, stdev = 4, fillGap = 0.05;
            double       x1         = Math.Min(_x1, _x2),
                         x2         = Math.Max(_x1, _x2),
                         y1         = Math.Min(_y1, _y2),
                         y2         = Math.Max(_y1, _y2);
            double d                = x1 + y1 + dist;
            StylusPointCollection r = new StylusPointCollection();
            //r.Add(new StylusPoint(x1, y1));
            bool side = false;

            while (d < x2 + y2 - dist)
            {
                if (side = !side)
                {
                    double x1_ = x1 + (x2 - x1) * Math.Abs(InkUtils.stdNorm() * fillGap);
                    double y2_ = y2 - (y2 - y1) * Math.Abs(InkUtils.stdNorm() * fillGap);
                    if (d - x1_ < y2_)
                    {
                        r.Add(new StylusPoint(x1_, d - x1_));
                    }
                    else
                    {
                        r.Add(new StylusPoint(d - y2_, y2_));
                    }
                }
                else
                {
                    double x2_ = x2 - (x2 - x1) * Math.Abs(InkUtils.stdNorm() * fillGap);
                    double y1_ = y1 + (y2 - y1) * Math.Abs(InkUtils.stdNorm() * fillGap);
                    if (d - x2_ > y1_)
                    {
                        r.Add(new StylusPoint(x2_, d - x2_));
                    }
                    else
                    {
                        r.Add(new StylusPoint(d - y1_, y1_));
                    }
                    d += Math.Abs(InkUtils.stdNorm() * stdev + dist);
                }
            }
            Stroke s = new Stroke(InkUtils.xkcd(r));

            s.DrawingAttributes.Color = colGen.nextColor();
            addStroke(s);
        }