예제 #1
0
        //--------------------------------------------------------------------
        public void GenerateColors(ColorRGBA[] outputColors, int startIndex, int x, int y, int len)
        {
            m_interpolator.Begin(x + 0.5, y + 0.5, len);

            do
            {
                m_interpolator.GetCoord(out x, out y);
                float d = m_grValueCalculator.Calculate(x >> DOWN_SCALE_SHIFT,
                                                        y >> DOWN_SCALE_SHIFT,
                                                        m_d2);

                d = ((d - m_d1) * stepRatio);

                if (d < 0)
                {
                    d = 0;
                }
                if (d >= m_colorsProvider.GradientSteps)
                {
                    d = m_colorsProvider.GradientSteps - 1;
                }

                outputColors[startIndex++] = m_colorsProvider.GetColor((int)d);
                m_interpolator.Next();
            }while (--len != 0);
        }
예제 #2
0
        //--------------------------------------------------------------------
        public void GenerateColors(Color[] outputColors, int startIndex, int x, int y, int spanLen)
        {
            //set interpolation start point
            //spanLen => horizontal span len
#if COSMOS
#else
            _interpolator.Begin(_grad0X + _xoffset + x + 0.5, _grad0Y + _yoffset + y + 0.5, spanLen);
            int gradientSteps = _colorsProvider.GradientSteps;

            int scanline_x = x;

            do
            {
                //find actual x and y
                _interpolator.GetCoord(out x, out y);

                float d = _grValueCalculator.Calculate(x >> DOWN_SCALE_SHIFT,
                                                       y >> DOWN_SCALE_SHIFT,
                                                       _dist) * _stepRatio;
                if (d < 0)
                {
                    if (PartNo == 0)
                    {
                        d = 0;
                    }
                    else
                    {
                        //move to prev part
                        d = 0;

                        //move to next part
                        if (RequestGradientPart != null)
                        {
                            GradientSpanGen nextPart = RequestGradientPart(this.PartNo - 1);
                            if (nextPart != null)
                            {
                                //generate next part
                                nextPart.GenerateColors(outputColors, startIndex, scanline_x, y, spanLen);
                                return;
                            }
                        }
                        else
                        {
                            d = 0;
                        }
                    }
                }
                else if (d >= gradientSteps)
                {
                    if (IsLastPart)
                    {
                        d = gradientSteps - 1;
                    }
                    else
                    {
                        //move to next part
                        if (RequestGradientPart != null)
                        {
                            GradientSpanGen nextPart = RequestGradientPart(this.PartNo + 1);
                            if (nextPart != null)
                            {
                                //generate next part
                                nextPart.GenerateColors(outputColors, startIndex, scanline_x, y, spanLen);
                                return;
                            }
                        }
                        else
                        {
                            d = gradientSteps - 1;
                        }
                    }
                }
                else
                {
                    //
                }
                outputColors[startIndex++] = _colorsProvider.GetColor((int)d);
                _interpolator.Next();//**
                scanline_x++;
            }while (--spanLen != 0);
#endif
        }