Ejemplo n.º 1
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 13JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * rotate operation.
         * @param ff_ang
         * @return
         */
        public MatrixFP Rotate(int ffAng)
        {
            var ffSin = MathFP.Sin(ffAng);
            var ffCos = MathFP.Cos(ffAng);

            return(Multiply(new MatrixFP(ffCos, ffCos, ffSin, -ffSin, 0, 0)));
        }
Ejemplo n.º 2
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))));
        }
Ejemplo n.º 3
0
        public static GraphicsPathFP  CreateArc(int ff_xmin, int ff_ymin, int ff_xmax, int ff_ymax, int ff_startangle, int ff_sweepangle, bool closed, bool standalone)
        {
            if (ff_sweepangle < 0)
            {
                ff_startangle += ff_sweepangle;
                ff_sweepangle  = -ff_sweepangle;
            }
            int segments = MathFP.Round(MathFP.Div(4 * MathFP.Abs(ff_sweepangle), MathFP.PI)) >> SingleFP.DecimalBits;

            if (segments == 0)
            {
                segments = 1;
            }
            GraphicsPathFP path = new GraphicsPathFP();
            int            ff_darg = ff_sweepangle / segments;
            int            ff_arg = ff_startangle;
            int            ff_lastcos = MathFP.Cos(ff_startangle);
            int            ff_lastsin = MathFP.Sin(ff_startangle);
            int            ff_xc = (ff_xmin + ff_xmax) / 2;
            int            ff_yc = (ff_ymin + ff_ymax) / 2;
            int            ff_rx = (ff_xmax - ff_xmin) / 2;
            int            ff_ry = (ff_ymax - ff_ymin) / 2;
            int            ff_RXBETA = MathFP.Mul(17381, ff_rx);
            int            ff_RYBETA = MathFP.Mul(17381, ff_ry);
            int            ff_currcos, ff_currsin, ff_x1, ff_y1, ff_x2, ff_y2;

            if (closed)
            {
                path.AddMoveTo(new PointFP(ff_xc, ff_yc));
            }

            for (int i = 1; i <= segments; i++)
            {
                ff_arg     = i == segments?ff_startangle + ff_sweepangle:ff_arg + ff_darg;
                ff_currcos = MathFP.Cos(ff_arg);
                ff_currsin = MathFP.Sin(ff_arg);
                ff_x1      = ff_xc + MathFP.Mul(ff_rx, ff_lastcos);
                ff_y1      = ff_yc + MathFP.Mul(ff_ry, ff_lastsin);
                ff_x2      = ff_xc + MathFP.Mul(ff_rx, ff_currcos);
                ff_y2      = ff_yc + MathFP.Mul(ff_ry, ff_currsin);
                if (i == 1)
                {
                    if (closed)
                    {
                        path.AddLineTo(new PointFP(ff_x1, ff_y1));
                    }
                    else
                    if (standalone)
                    {
                        path.AddMoveTo(new PointFP(ff_x1, ff_y1));
                    }
                }

                path.AddCurveTo(
                    new PointFP(ff_x1 - MathFP.Mul(ff_RXBETA, ff_lastsin), ff_y1 + MathFP.Mul(ff_RYBETA, ff_lastcos)),
                    new PointFP(ff_x2 + MathFP.Mul(ff_RXBETA, ff_currsin), ff_y2 - MathFP.Mul(ff_RYBETA, ff_currcos)),
                    new PointFP(ff_x2, ff_y2));
                ff_lastcos = ff_currcos;
                ff_lastsin = ff_currsin;
            }
            if (closed)
            {
                path.AddClose();
            }
            return(path);
        }