Creates single color textures for drawing rectangles. More...
Static Public Member Functions | |
| static Texture2D | CreateColorTexture (GraphicsDevice graphicsDevice) |
| Creates single color textures for drawing rectangles. Default creares a 1x1 pixel black texture. | |
| static Texture2D | Create (GraphicsDevice graphicsDevice, Color color) |
| Creates single color textures for drawing rectangles. Creates a 1x1 pixel texture of the specified color. | |
| static Texture2D | Create (GraphicsDevice graphicsDevice, int width, int height, Color color) |
| Creates single color textures for drawing rectangles. Creates a texture of the specified color. | |
| static Color[] | TextureToColors (Texture2D texture) |
| Convert a texture into a 1-dimensionsional list of colors. | |
| static Color[,] | TextureToColorArray (Texture2D texture) |
| Convert a texture into a 2-dimensionsional color array. | |
Creates single color textures for drawing rectangles.
Definition at line 16 of file TextureHelpers.cs.
| static Texture2D NewGamePhysics.Utilities.TextureHelpers.Create | ( | GraphicsDevice | graphicsDevice, | |
| int | width, | |||
| int | height, | |||
| Color | color | |||
| ) | [static] |
Creates single color textures for drawing rectangles. Creates a texture of the specified color.
| graphicsDevice | The graphics device to use. | |
| width | The width of the texture. | |
| height | The height of the texture. | |
| color | The color to set the texture to. |
Definition at line 50 of file TextureHelpers.cs.
00051 { 00052 // create the rectangle texture without colors 00053 Texture2D texture = new Texture2D( 00054 graphicsDevice, 00055 width, 00056 height, 00057 1, 00058 TextureUsage.None, 00059 SurfaceFormat.Color); 00060 00061 // Create a color array for the pixels 00062 Color[] colors = new Color[width * height]; 00063 for (int i = 0; i < colors.Length; i++) 00064 { 00065 colors[i] = new Color(color.ToVector3()); 00066 } 00067 00068 // Set the color data for the texture 00069 texture.SetData(colors); 00070 00071 return texture; 00072 }
| static Texture2D NewGamePhysics.Utilities.TextureHelpers.Create | ( | GraphicsDevice | graphicsDevice, | |
| Color | color | |||
| ) | [static] |
Creates single color textures for drawing rectangles. Creates a 1x1 pixel texture of the specified color.
| graphicsDevice | The graphics device to use. | |
| color | The color to set the texture to. |
Definition at line 36 of file TextureHelpers.cs.
00037 { 00038 return Create(graphicsDevice, 1, 1, color); 00039 }
| static Texture2D NewGamePhysics.Utilities.TextureHelpers.CreateColorTexture | ( | GraphicsDevice | graphicsDevice | ) | [static] |
Creates single color textures for drawing rectangles. Default creares a 1x1 pixel black texture.
| graphicsDevice | The graphics device to use. |
Definition at line 24 of file TextureHelpers.cs.
00025 { 00026 return Create(graphicsDevice, 1, 1, new Color()); 00027 }
| static Color [,] NewGamePhysics.Utilities.TextureHelpers.TextureToColorArray | ( | Texture2D | texture | ) | [static] |
Convert a texture into a 2-dimensionsional color array.
| texture | The texture to convert. |
Definition at line 91 of file TextureHelpers.cs.
00092 { 00093 // Get colors as list 00094 Color[] color1D = TextureToColors(texture); 00095 00096 // Create new 2D array for colors 00097 Color[,] color2D = new Color[texture.Width, texture.Height]; 00098 00099 // Copy color from list to array 00100 int x=0; 00101 int y=0; 00102 foreach (Color color in color1D) 00103 { 00104 color2D[x, y] = color; 00105 x++; 00106 if (x > texture.Width) 00107 { 00108 y++; 00109 x = 0; 00110 } 00111 } 00112 00113 return color2D; 00114 }
| static Color [] NewGamePhysics.Utilities.TextureHelpers.TextureToColors | ( | Texture2D | texture | ) | [static] |
Convert a texture into a 1-dimensionsional list of colors.
| texture | The texture to convert. |
Definition at line 79 of file TextureHelpers.cs.
1.6.2