Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Graphics
  4. brush problem in c#...

brush problem in c#...

Scheduled Pinned Locked Moved Graphics
questioncsharpdata-structureshelptutorial
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sajjad Izadi
    wrote on last edited by
    #1

    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

    O S D 3 Replies Last reply
    0
    • S Sajjad Izadi

      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

      O Offline
      O Offline
      oobimoo
      wrote on last edited by
      #2

      You can use a pen instead. First adjust the width of your pen. Then set StartCap and EndCap of the pen to LineCap.Round. Finally draw lines, instead of 'points', from the previous point to the current point, in the mouse move event.

      1 Reply Last reply
      0
      • S Sajjad Izadi

        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

        S Offline
        S Offline
        Syed Mehroz Alam
        wrote on last edited by
        #3

        To see an example of joining the points, you can have a look at the PlotGraph() method of my Expression Plotter Control[^].

        My Blog My Articles

        1 Reply Last reply
        0
        • S Sajjad Izadi

          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

          D Offline
          D Offline
          Dan 0
          wrote on last edited by
          #4

          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 );
          }
          }

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups