brush problem in c#...
-
hello friends, how can i make a simple, soft and nice brush like that is in the microsoft paint? My solution was to draw consecutive circles in my mouse drag event and add them to the array list and then repaint all circles in the array list. but some of the events of mouse drag are missed and this make my brush dotted. i want to know how can i make it more smooth. please guide me. thanks
-
hello friends, how can i make a simple, soft and nice brush like that is in the microsoft paint? My solution was to draw consecutive circles in my mouse drag event and add them to the array list and then repaint all circles in the array list. but some of the events of mouse drag are missed and this make my brush dotted. i want to know how can i make it more smooth. please guide me. thanks
-
hello friends, how can i make a simple, soft and nice brush like that is in the microsoft paint? My solution was to draw consecutive circles in my mouse drag event and add them to the array list and then repaint all circles in the array list. but some of the events of mouse drag are missed and this make my brush dotted. i want to know how can i make it more smooth. please guide me. thanks
To see an example of joining the points, you can have a look at the PlotGraph() method of my Expression Plotter Control[^].
-
hello friends, how can i make a simple, soft and nice brush like that is in the microsoft paint? My solution was to draw consecutive circles in my mouse drag event and add them to the array list and then repaint all circles in the array list. but some of the events of mouse drag are missed and this make my brush dotted. i want to know how can i make it more smooth. please guide me. thanks
The best way to handle this situation is to use an interpolation function to create a curve that smoothly joins the input points of the mouse. The easiest pseudo sample is below, but you can expand it to use bicubic or any spline function.
void DrawPoint( double x, double y )
{
...paint single brush dab.
}void DrawLine( double x0, double y0, double x1, double y1, double spacing )
{
// get delta
double dx = x1-x0;
double dy = y1-y0;// Get length double dist = sqrt( dx \* dx + dy \* dy ); // Normalize dx \*= 1.0 / dist; dy \*= 1.0 / dist; // Travel down the line ( x0, y0 ) ( x1, y1 ) for ( double p = spacing; p <= dist; p+= spacing ) { // Draw a single point at spacing pixels apart. double px = x0 + p \* dx; double py = y0 + p \* dy; DrawPoint( px, py ); }
}
void MyPaintCode( )
{
for ( int i = 0; i < NumberofPoints; i++ ) {
// Draw lines between input points with 1 pixel spacing.
PaintLine( Input_x[ i ], Input_y[ i ], 1.0 );
}
}