我正在制作一个带有对话框的游戏,我希望能够按照《最终幻想》系列中非常相似的风格(类似于《最终幻想VII》)来自动生成对话框纹理。以下是目前为止我所拥有的代码片段:
我需要翻译的内容如下:
public class DialogBox
{
public Rectangle BoxArea { get; set; }
public List<Color> BoxColors { get; set; }
public List<Color> BorderColors { get; set; }
public int BorderThickness { get; set; }
public int BorderRadius { get; set; }
private Texture2D texture;
public void CreateBackdrop(ref GraphicsDevice graphics)
{
texture = new Texture2D(graphics,
BoxArea.Width,
BoxArea.Height,
true,
SurfaceFormat.Color);
Color[] color = new Color[texture.Width * texture.Height];
for(int x = 0; x < texture.Width; x++)
{
for(int y = 0; y < texture.Height; y++)
{
switch(BoxColors.Count)
{
case 4:
Color leftColor = Color.Lerp(BoxColor[0], BoxColor[1], (y / (texture.Height - 1)));
Color rightColor = Color.Lerp(BoxColor[2], BoxColor[3], (y / (texture.Height - 1)));
color[x + y * texture.Width] = Color.Lerp(leftColor,
RightColor,
(x / (texture.Width - 1)));
break;
case 2:
color[x + y * texture.Width] = Color.Lerp(BoxColors[0],
BoxColors[1],
(x / (texture.Width - 1)));
break;
default:
color[x + y * texture.Width];
break;
}
}
}
texture.SetData<Color>(color);
}
}
我需要翻译的内容如下:
我需要的是以下内容:
- 四向渐变颜色(已实现)
- 圆角矩形
- 渐变边框
任何帮助将不胜感激。
我通过这个问题找到了矩形的解决方法。