Esempio n. 1
0
        protected override void GetFillTexture()
        {
            XNAGradient gradient = Fill as XNAGradient;

            if (gradient == null)
            {
                return;
            }
            gradient.Dimensions = new Point(BoundingRectangle.Width, BoundingRectangle.Height);
            gradient.Update();
            pFillTexture = gradient.Texture;

            int height = pFillTexture.Height;
            int width  = pFillTexture.Width;

            float   halfPoint = (width - 1f) / 2f;
            Vector2 centre    = new Vector2(halfPoint, halfPoint);

            pFillTextureData = new Color[width * height];
            pFillTexture.GetData(pFillTextureData);
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    float lerp = MathHelper.Clamp(halfPoint - (Vector2.Distance(centre, new Vector2(x, y))) + 1, 0, 1);
                    pFillTextureData[x + (y * width)].A = (byte)(255f * lerp);
                }
            }
            pFillTexture.SetData(pFillTextureData);
        }
Esempio n. 2
0
        protected virtual void GetFillTexture()
        {
            XNAGradient gradient = pFill as XNAGradient;

            if (gradient == null)
            {
                return;
            }
            gradient.Dimensions = new Point(BoundingRectangle.Width, BoundingRectangle.Height);
            gradient.Update();
            pFillTexture = gradient.Texture;

            int height = pFillTexture.Height;
            int width  = pFillTexture.Width;

            pFillTextureData = new Color[width * height];
            pFillTexture.GetData(pFillTextureData);

            for (int y = 0; y < height; y++)
            {
                XNALine lastLine  = null;
                bool    paint     = false;
                bool    paintNext = false;
                for (int x = 0; x < width; x++)
                {
                    Vector2 point = new Vector2((float)x + BoundingRectangle.X, (float)y + BoundingRectangle.Y);
                    XNALine line  = IntersectingLine(point);
                    if (line != null)
                    {
                        if (line != lastLine)
                        {
                            paintNext = !paint;
                        }
                        lastLine = line;
                    }
                    if (!paint)
                    {
                        pFillTextureData[x + (y * width)].A = 0;
                    }
                    paint = paintNext;
                }
            }
            pFillTexture.SetData(pFillTextureData);
        }