PDA

View Full Version : MFC Question, "Brush" Question


Tocs1001
05-30-2006, 08:39 PM
Hey I'm back with a couple programming questions, I'm using c++ in Microsoft Visual Studio .NET 2003, and MFC.

I'm working on my map editor...
Screeny: http://home.fuse.net/Dragonstorm/MapEditor.jpg
Yes the map on the screen stinks, it was a File->Load Test....

First Question.....
With the Dialog Builder how do I set the Min and Max Values of a Slider Control? :rolleyes: I looked through books, I could do it in code, but I was hoping there was a way to do it in the editor....Less to keep track of If i decide to change how it's going to work...

Second Question.....
I have a linear array [Size of image * Size of Image] to hold the height data because you cant create a 2D array with char *map = new char [Size][Size];

'Size' being a variable I'm trying to write the Brush tool to paint with right now and how would I go about finding the pixels to modify if I knew the diameter of the Brush's circle? I want the user to use the "Tool Box" to select the brush width and use a circle with that diameter to paint on my map, I can get the X,Y of the mouse simple but how do i find the points around it?

HopeDagger
05-31-2006, 03:24 AM
I have a linear array [Size of image * Size of Image] to hold the height data because you cant create a 2D array with char *map = new char [Size][Size];

'Size' being a variable

Sure you can:


char **map = new char[Size];
for(int a=0; a < Size; a++)
map[a] = new char[Size];


This makes it significantly easier to find exact coordinates in the array.

I'm trying to write the Brush tool to paint with right now and how would I go about finding the pixels to modify if I knew the diameter of the Brush's circle? I want the user to use the "Tool Box" to select the brush width and use a circle with that diameter to paint on my map, I can get the X,Y of the mouse simple but how do i find the points around it?

There's a few good ways to do this. Since I'm no adept at circle-drawing, I refer you to Google instead. Plenty of good material on circle drawing algorithms. :)

Tocs1001
05-31-2006, 10:59 AM
an array in an array.....nifty....., I guess i'll try google i was wondering if anyone had any neat tricks for it ;) thanks hope I might rewrite to the array in an array thing..

odie5533
06-11-2006, 05:57 AM
If you want plain circles, try looking for Bresenham's circle algorithm. Very fast, and very efficient.

punkerdan85
06-17-2006, 10:19 PM
How can you put a character array at each element of a character array when each element is supposed to be a single character?