3

ダイアログ ボックスを使用してゲームを構築しています。ファイナル ファンタジー シリーズ (ファイナル ファンタジー 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);
    }
}

私が探しているのは次のとおりです。

  • 4方向グラデーションカラー(実装済み)
  • 角丸長方形
  • グラデーションのあるボーダー

どんな助けでも大歓迎です。

この質問で長方形を見つけました。

4

1 に答える 1