• 09-19-2010
TIMBERings
This is a paint like program, where on a click or drag, a circle with certain fills will appear.

I'm having issues with the Quadratic and Gaussian Brushes. Each provide me with a small dot, the QuadraticBush is about 20 pixels in diameter and the GaussianBrush is 1 pixel. Each start with a radius and flow of 128. These are the two functions that create the mask which stores the flow.

They are wrapped in a double for loop holding i as each row and j as each column.

Size is the width and height of the array.
Distance is the distance from the click location to each pixel in the mask.
Flow can be from 0 to 255 and represents the amount of color applied.
Rho is some constant for the Gaussian equation.

Code:

if( distance <= (double)radius )  {
if (distance < 1) {
} else {
m_mask[i*(size-1)+j] = m_flow / (distance * distance);
}
}
} else {
}

Gaussian:
Code:

if( distance <= (double)radius )  {
float base = 1 /(2 * PI * rho * rho);
float exponent = -1.0 * ((distance * distance) / (2.0 * rho * rho));
m_mask[i*(size-1)+j] = m_flow * base * exp(exponent);
}
} else {
}

This is a linear blur which works just fine. It goes from 100% inside and 0% outside.

Linear:
Code:

int count=0;
int arraysize = size * size;
double distance;
for(int i=0; i<size; i++) {
for(int j=0; j<size; j++) {
if( distance <= (double)radius )  {
} else {
}
}
}

Any help would be great.