XNA/FNA/MonoGame/KNI 创建指定尺寸纯色 Texture2D 效果

XNA/FNA/MonoGame/KNI 创建指定尺寸纯色 Texture2D 效果

我使用的是 FNA,对其它XNA系框架其实没有试过。

一、演示

image

二、代码

  public static Texture2D CreateSolidColorTexture2D(int width, int height, Color color)
  {
      var tex = new Texture2D(Nez.Core.GraphicsDevice, width, height);

      var colors = new Color[width * height];
      Array.Fill(colors, color, 0, width * height);
      tex.SetData(colors);

      return tex;
  }
posted @ 2025-07-05 20:54  fanbal  阅读(16)  评论(0)    收藏  举报