This project has moved and is read-only. For the latest updates, please go here.

draw filled shapes in DirectXTK

Mar 14, 2013 at 3:38 PM
I want to draw Fill rectangle with selected color
is there any way to do so in DirectXTK
Mar 14, 2013 at 7:17 PM
The easiest way to do this is to create a 1x1 texture, set it to a single white pixel, then draw that with SpriteBatch, scaling and tinting to whatever size and color you want.

For more low level control, you could use PrimitiveBatch with a BasicEffect.
Mar 16, 2013 at 6:54 AM
Edited Mar 16, 2013 at 8:58 AM
Note if you are looking for more sophisticated shape drawing beyond quads and polygonal shapes, that's really the bailiwick Direct2D rather than Direct3D (which is primarily what DirectXTK is about).

Of course, without more information on your target platform it's hard to know what to recommend. For Windows Store apps or a Windows 8 only Win32 desktop app, Direct2D is a rational choice, particularly since it interoperates well with Direct3D. For Windows 7 and earlier, it's a little harder to get them to work together although I can be done. Windows phone 8 doesn't support Direct2D.
Mar 17, 2013 at 7:42 AM
thank you ShawnHargreaves and walbourn
i am working on Windows Phone 8 project , i don't want to draw sophisticated shapes ,
i just want to draw filled rectangle,
i tried using texture , fore example if i want to draw rectangle(200100) create texture(200100) and draw it using spirit patch , but is this effective method
and can i draw big number of rectangles without killing the performance .
Mar 18, 2013 at 4:18 AM
There is no need to create a 200x100 texture. Just make a single 1x1 texture, and scale it as necessary for whatever size rectangle you want to draw.
Mar 18, 2013 at 4:31 PM
Thank you very much ,
I can draw filled rectangles now.