Search code examples
c#xnadrawpaintbrush

XNA Basic Paint program


I started a very basic XNA 4.0 program where I load a small red image of a dot in through the Content loader. The red dot is 10x10 and is rounded at the edges to make it look rounded. I am drawing it on-screen and updating its X and Y positions to that of the X and Y position of the Mouse. So basically it's a custom red cursor.

Now my question is: How would I go about using this cursor as a brush? When I click the left mouse button I want it to paint onto a blank Texture2D background that is the size of the current screen. It would function just like a paint brush in MSPAINT.

I imagine I would need an array of Vector2 points that holds the points that the mouse has moved over, and for each of these points when the update occurs it paints the dot on the background Texture2D?

It's probably not very efficient but it was all I could think of at the time.

I've also read into changing color data of Texture2Ds but alas have had no luck.


Solution

  • For those of you who are interested in how i managed to "paint" onscreen the whole code repository can be found here https://thefoofighter@github.com/thefoofighter/paint.git

    Its certainly best way to approach my problem but it does what i need it to do and since i dont need to worry about optimization with the bigger program im porting this into i havent tried making it better.

    There is a readme with the above Git that provides more information on changes and optimizations.