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); }
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); }