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

        /**
         * @inheritDoc
         * @param x the x coordinate
         * @param y the y coordinate
         * @param singlePoint  single point
         * @return the color Value at given location.
         */
        public override int GetColorAt(int x, int y, bool singlePoint)
        {
            var p = new PointFP(x << SingleFP.DECIMAL_BITS,
                                y << SingleFP.DECIMAL_BITS);

            _nextPt.X = p.X + SingleFP.ONE;
            _nextPt.Y = p.Y;
            if (_finalMatrix != null)
            {
                p.Transform(_finalMatrix);
            }
            var xPos = (p.X >> SingleFP.DECIMAL_BITS) % _width;
            var yPos = (p.Y >> SingleFP.DECIMAL_BITS) % _height;

            if (xPos < 0)
            {
                xPos += _width;
            }
            if (yPos < 0)
            {
                yPos += _height;
            }


            return(_textureBuffer[(xPos + yPos * _width)]);
        }
Ejemplo n.º 2
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 13JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * @inheritDoc
         * @return next color.
         */
        public override int GetNextColor()
        {
            var p = new PointFP(_nextPt);

            _nextPt.X += SingleFP.ONE;
            _nextPt.Y  = p.Y;

            if (_finalMatrix != null)
            {
                p.Transform(_finalMatrix);
            }
            var xPos = (p.X >> SingleFP.DECIMAL_BITS) % _width;
            var yPos = (p.Y >> SingleFP.DECIMAL_BITS) % _height;

            if (xPos < 0)
            {
                xPos += _width;
            }
            if (yPos < 0)
            {
                yPos += _height;
            }

            return(_textureBuffer[xPos + yPos * _width]);
        }
Ejemplo n.º 3
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 13JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         *
         * @param point
         */
        public override void MoveTo(PointFP point)
        {
            _transformedPoint = new PointFP(point);
            if (_transformMatrix != null)
            {
                _transformedPoint.Transform(_transformMatrix);
            }
            base.MoveTo(point);
        }
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 13JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * @inheritDoc
         * @param x the x coordinate
         * @param y the y coordinate
         * @param singlePoint
         * @return the color at given position.
         */
        public override int GetColorAt(int x, int y, bool singlePoint)
        {
            var p = new PointFP(x << SingleFP.DECIMAL_BITS,
                                y << SingleFP.DECIMAL_BITS);
            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.getWidth();
            //int height = bounds.getHeight();

            var v = p.X + _ffLength / 2;

            _ffCurrpos = (int)(((long)v << RATIO_BITS + SingleFP.DECIMAL_BITS)
                               / _ffLength);
            if (!singlePoint)
            {
                _ffDeltapos = (int)(((long)(p1.X - p.X)
                                     << RATIO_BITS + SingleFP.DECIMAL_BITS) / _ffLength);
            }
            int pos = _ffCurrpos >> SingleFP.DECIMAL_BITS;

            pos -= 512;

            //pos >>= Brush.XY_MAX_BITS - RATIO_BITS;

            switch (FillMode)
            {
            case REFLECT:
                pos = pos % (RATIO_MAX * 2);
                pos = pos < 0 ? pos + RATIO_MAX * 2 : pos;
                pos = (pos < RATIO_MAX) ? pos : RATIO_MAX * 2 - pos;
                break;

            case REPEAT:
                pos = pos % RATIO_MAX;
                pos = pos < 0 ? pos + RATIO_MAX : pos;
                break;

            case NO_CYCLE:
                pos = pos < 0 ? 0 : (pos > RATIO_MAX ? RATIO_MAX : pos);
                break;
            }

            return(_gradientColors[pos]);
        }
Ejemplo n.º 5
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 09NOV2008  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         *
         * @param point
         */
        public override void LineTo(PointFP point)
        {
            var pntTemp = new PointFP(point);

            _ffXmin = MathFP.Min(_ffXmin, CurrentPoint().X);
            _ffXmax = MathFP.Max(_ffXmax, point.X);
            _ffYmin = MathFP.Min(_ffYmin, CurrentPoint().Y);
            _ffYmax = MathFP.Max(_ffYmax, point.Y);

            if (_transformMatrix != null)
            {
                pntTemp.Transform(_transformMatrix);
            }

            Scanline(_transformedPoint.X, _transformedPoint.Y, pntTemp.X, pntTemp.Y);
            _transformedPoint = pntTemp;
            base.LineTo(point);
        }
Ejemplo n.º 6
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 09NOV2008  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * @inheritDoc
         * @param x the x coordinate
         * @param y the y coordinate
         * @param singlePoint
         * @return the color at given position.
         */
        public override int GetColorAt(int x, int y, bool singlePoint)
        {
            var p = new PointFP(x << SingleFP.DECIMAL_BITS,
                                y << SingleFP.DECIMAL_BITS);

            _nextPt.X = p.X + SingleFP.ONE;
            _nextPt.Y = p.Y;
            var newCenterPt = new PointFP(_centerPt);

            if (_finalMatrix != null)
            {
                p.Transform(_finalMatrix);
                //newCenterPt.transform(finalMatrix);
            }
            _ffCurrpos = MathFP.Div(PointFP.Distance(p.X - newCenterPt.X,
                                                     p.Y - newCenterPt.Y), _ffRadius);
            var pos = _ffCurrpos >> SingleFP.DECIMAL_BITS - RATIO_BITS;

            switch (FillMode)
            {
            case REFLECT:
                pos = pos % (RATIO_MAX * 2);
                pos = pos < 0 ? pos + RATIO_MAX * 2 : pos;
                pos = (pos < RATIO_MAX) ? pos : RATIO_MAX * 2 - pos;
                break;

            case REPEAT:
                pos = pos % RATIO_MAX;
                pos = pos < 0 ? pos + RATIO_MAX : pos;
                break;

            case NO_CYCLE:
                pos = pos < 0 ? 0 : (pos > RATIO_MAX ? RATIO_MAX : pos);
                break;
            }

            return(_gradientColors[pos]);
        }
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 13JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  *
  * @param point
  */
 public override void MoveTo(PointFP point)
 {
     _transformedPoint = new PointFP(point);
     if (_transformMatrix != null)
     {
         _transformedPoint.Transform(_transformMatrix);
     }
     base.MoveTo(point);
 }
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 09NOV2008  James Shen                 	          Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        /**
         *
         * @param point
         */
        public override void LineTo(PointFP point)
        {
            var pntTemp = new PointFP(point);

            _ffXmin = MathFP.Min(_ffXmin, CurrentPoint().X);
            _ffXmax = MathFP.Max(_ffXmax, point.X);
            _ffYmin = MathFP.Min(_ffYmin, CurrentPoint().Y);
            _ffYmax = MathFP.Max(_ffYmax, point.Y);

            if (_transformMatrix != null)
            {
                pntTemp.Transform(_transformMatrix);
            }

            Scanline(_transformedPoint.X, _transformedPoint.Y, pntTemp.X, pntTemp.Y);
            _transformedPoint = pntTemp;
            base.LineTo(point);
        }
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 13JUN2009  James Shen                 	          Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        /**
         * @inheritDoc
         * @return next color of the gradient brush.
         */
        public override int GetNextColor()
        {
            var p = new PointFP(_nextPt);
            _nextPt.X = p.X + SingleFP.ONE;
            _nextPt.Y = p.Y;
            var newCenterPt = new PointFP(_centerPt);
            if (_finalMatrix != null)
            {
                p.Transform(_finalMatrix);
                //newCenterPt.transform(finalMatrix);

            }
            _ffCurrpos = MathFP.Div(PointFP.Distance(p.X - newCenterPt.X,
                    p.Y - newCenterPt.Y), _ffRadius);
            var pos = _ffCurrpos >> SingleFP.DECIMAL_BITS - RATIO_BITS;

            switch (FillMode)
            {
                case REFLECT:
                    pos = pos % (RATIO_MAX * 2);
                    pos = pos < 0 ? pos + RATIO_MAX * 2 : pos;
                    pos = (pos < RATIO_MAX) ? pos : RATIO_MAX * 2 - pos;
                    break;
                case REPEAT:
                    pos = pos % RATIO_MAX;
                    pos = pos < 0 ? pos + RATIO_MAX : pos;
                    break;
                case NO_CYCLE:
                    pos = pos < 0 ? 0 : (pos > RATIO_MAX ? RATIO_MAX : pos);
                    break;
            }

            return _gradientColors[pos];
        }
Ejemplo n.º 10
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 13JUN2009  James Shen                 	          Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        /**
         * @inheritDoc
         * @param x the x coordinate
         * @param y the y coordinate
         * @param singlePoint  single point
         * @return the color Value at given location.
         */
        public override int GetColorAt(int x, int y, bool singlePoint)
        {
            var p = new PointFP(x << SingleFP.DECIMAL_BITS,
                    y << SingleFP.DECIMAL_BITS);
            _nextPt.X = p.X + SingleFP.ONE;
            _nextPt.Y = p.Y;
            if (_finalMatrix != null)
            {
                p.Transform(_finalMatrix);

            }
            var xPos = (p.X >> SingleFP.DECIMAL_BITS) % _width;
            var yPos = (p.Y >> SingleFP.DECIMAL_BITS) % _height;

            if (xPos < 0) xPos += _width;
            if (yPos < 0) yPos += _height;

            return _textureBuffer[(xPos + yPos * _width)];
        }
Ejemplo n.º 11
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 13JUN2009  James Shen                 	          Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        /**
         * @inheritDoc
         * @return next color.
         */
        public override int GetNextColor()
        {
            var p = new PointFP(_nextPt);

            _nextPt.X += SingleFP.ONE;
            _nextPt.Y = p.Y;

            if (_finalMatrix != null)
            {
                p.Transform(_finalMatrix);

            }
            var xPos = (p.X >> SingleFP.DECIMAL_BITS) % _width;
            var yPos = (p.Y >> SingleFP.DECIMAL_BITS) % _height;

            if (xPos < 0) xPos += _width;
            if (yPos < 0) yPos += _height;

            return _textureBuffer[xPos + yPos * _width];
        }
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 13JUN2009  James Shen                 	          Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        /**
         * @inheritDoc
         * @param x the x coordinate
         * @param y the y coordinate
         * @param singlePoint
         * @return the color at given position.
         */
        public override int GetColorAt(int x, int y, bool singlePoint)
        {
            var p = new PointFP(x << SingleFP.DECIMAL_BITS,
                    y << SingleFP.DECIMAL_BITS);
            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.getWidth();
            //int height = bounds.getHeight();

            var v = p.X + _ffLength / 2;
            _ffCurrpos = (int)(((long)v << RATIO_BITS + SingleFP.DECIMAL_BITS)
                    / _ffLength);
            if (!singlePoint)
            {
                _ffDeltapos = (int)(((long)(p1.X - p.X)
                        << RATIO_BITS + SingleFP.DECIMAL_BITS) / _ffLength);
            }
            int pos = _ffCurrpos >> SingleFP.DECIMAL_BITS;
            pos -= 512;

            //pos >>= Brush.XY_MAX_BITS - RATIO_BITS;

            switch (FillMode)
            {
                case REFLECT:
                    pos = pos % (RATIO_MAX * 2);
                    pos = pos < 0 ? pos + RATIO_MAX * 2 : pos;
                    pos = (pos < RATIO_MAX) ? pos : RATIO_MAX * 2 - pos;
                    break;
                case REPEAT:
                    pos = pos % RATIO_MAX;
                    pos = pos < 0 ? pos + RATIO_MAX : pos;
                    break;
                case NO_CYCLE:
                    pos = pos < 0 ? 0 : (pos > RATIO_MAX ? RATIO_MAX : pos);
                    break;
            }

            return _gradientColors[pos];
        }