paint - Fastest way to fill pixels between two points with an ellipse-shaped brush? -


Say I'm making a raster-based paint program. My brush oval shape is that the user clicks the mouse to paint an area and then drags it. I now have two points: the points (where they clicked) and the dot (the first point came back from the mouse-drag). I have to fill all pixels coming within the brush area. What is the best way to do this?

My first method is to calculate the slope between two points and then increase from point A to pointB for each point in between, I search all the pixels within the oval range and again Turns on if they are in range but it seems inefficient, because pixels are often checked multiple times - often many times, because increments are much lower than the ellipse (think Wayne diagram).

Is that a better view? One which is more efficient and minimizes the number of pixels.

I can do something very similar now and you can tell what I'm doing: < / P>

  • The mouse moves and I get points (x, y) where the mouse
  • I use the Bresenheim algorithm to guess the lines from one mouse position to the other (I do not get an event to move the mouse for every pixel).
  • Then I have a proper spacing (20% of the brush) on the "stamp" (aka draw) on the line with the brush tip.

Because I do not know what programming language / framework you use, I can not give you the code :)


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -