Exemplo n.º 1
0
        private void  AddLineCap(PointFP p1, PointFP p2, int lineCap)
        {
            if (lineCap == PenFP.LINECAP_BUTT || p1.Equals(p2))
            {
                return;
            }
            int dx  = p2.X - p1.X;
            int dy  = p2.Y - p1.Y;
            int len = PointFP.Distance(dx, dy);

            PointFP[] cap = lineCap == PenFP.LINECAP_ROUND?GraphicsPathFP.roundCap:GraphicsPathFP.squareCap;

            dx = MathFP.Mul(ff_rad, MathFP.Div(dx, len));
            dy = MathFP.Mul(ff_rad, MathFP.Div(dy, len));

            MatrixFP m = new MatrixFP(dx, dx, dy, -dy, p2.X, p2.Y);

            outline.AddMoveTo(new PointFP(0, GraphicsPathFP.One).Transform(m));
            for (int i = 0; i < cap.Length; i++)
            {
                outline.AddLineTo(new PointFP(cap[i]).Transform(m));
            }
            outline.AddLineTo(new PointFP(0, -GraphicsPathFP.One).Transform(m));
            outline.AddClose();
        }
Exemplo n.º 2
0
        public override int GetColorAt(int x, int y, bool singlePoint)
        {
            int     pos;
            PointFP p  = new PointFP(x << SingleFP.DecimalBits, y << SingleFP.DecimalBits);
            PointFP p1 = null;

            if (!singlePoint)
            {
                p1 = new PointFP(p.X + SingleFP.One, p.Y);
            }
            if (finalMatrix != null)
            {
                p.Transform(finalMatrix);
                if (!singlePoint)
                {
                    p1.Transform(finalMatrix);
                }
            }
            int width  = bounds.Width;
            int height = bounds.Height;

            if (type == LINEAR_GRADIENT)
            {
                int v = p.X + ff_length / 2;
                if (v < 0)
                {
                    v = 0;
                }
                else if (v > ff_length - 1)
                {
                    v = ff_length - 1;
                }
                ff_currpos = (int)(((long)v << RATIO_BITS + SingleFP.DecimalBits) / ff_length);
                if (!singlePoint)
                {
                    ff_deltapos = (int)(((long)(p1.X - p.X) << RATIO_BITS + SingleFP.DecimalBits) / ff_length);
                }
                pos = ff_currpos >> SingleFP.DecimalBits;
            }
            else
            {
                ff_currpos = PointFP.Distance(p.X, p.Y);
                if (!singlePoint)
                {
                    ff_deltapos = PointFP.Distance(p1.X, p1.Y) - ff_currpos;
                }
                //if (ff_currpos > SingleFP.One - 1) pos = SingleFP.One - 1;
                pos = ff_currpos >> SingleFP.DecimalBits - RATIO_BITS;
            }
            //pos >>= BrushFP.XY_MAX_BITS - RATIO_BITS;
            pos = pos < 0?0:(pos > RATIO_MAX?RATIO_MAX:pos);
            return(gradientColors[pos]);
        }
Exemplo n.º 3
0
        public LineFP GetTailOutline(int ff_rad)
        {
            PointFP c = Center;
            PointFP p = new PointFP(P2.X - c.X, P2.Y - c.Y);

            p.Reset(p.Y, -p.X);
            int dis = PointFP.Distance(PointFP.Origin, p);

            if (dis == 0)
            {
                dis = 1;
            }
            p.Reset(MathFP.Div(MathFP.Mul(p.X, ff_rad), dis), MathFP.Div(MathFP.Mul(p.Y, ff_rad), dis));
            return(new LineFP(P2.X - p.X, P2.Y - p.Y, P2.X + p.X, P2.Y + p.Y));
        }
Exemplo n.º 4
0
        public GradientBrushFP(int ff_xmin, int ff_ymin, int ff_xmax, int ff_ymax, int ff_angle, int type)
        {
            bounds.Reset(ff_xmin, ff_ymin,
                         ff_xmax == ff_xmin ? ff_xmin + 1 : ff_xmax,
                         ff_ymax == ff_ymin ? ff_ymin + 1 : ff_ymax);
            matrix = new MatrixFP();
            matrix.Translate(-(ff_xmin + ff_xmax) / 2, -(ff_ymin + ff_ymax) / 2);
            matrix.Rotate(-ff_angle);
            this.type = type;
            if (type == RADIAL_GRADIENT)
            {
                matrix.Scale(MathFP.Div(SingleFP.One, bounds.Width), MathFP.Div(SingleFP.One, bounds.Height));
            }
            int ff_ang = MathFP.Atan(MathFP.Div(bounds.Height, bounds.Width == 0 ? 1 : bounds.Width));
            int ff_len = PointFP.Distance(bounds.Height, bounds.Width);

            ff_length = MathFP.Mul(ff_len, MathFP.Max(
                                       MathFP.Abs(MathFP.Cos(ff_angle - ff_ang)),
                                       MathFP.Abs(MathFP.Cos(ff_angle + ff_ang))));
        }