Skip to main content

bouvard jean-christophe's Library tagged pygame   View Popular

04 Oct 09

How to create MS Paint clone with Python and pygame - Stack Overflow

As I see it, there are two ways to handle mouse events to draw a picture.

The first is to detect when the mouse moves and draw a line to where the mouse is, shown here. However, the problem with this is that with a large brush size, many gaps appear between each "line" that is not straight since it is using the line's stroke size to create thick lines.

The other way is to draw circles when the mouse moves as is shown here. The problem with this is that gaps appear between each circle if the mouse moves faster than the computer detects mouse input.

Here's a screenshot with my issues with both: http://imgur.com/32DXN

What is the best way to implement a brush like MS Paint's, with a decently-big brush size with no gaps in the stroke of the line or no gaps between each circle?

stackoverflow.com/...t-clone-with-python-and-pygame - Preview

pygame python paint mouse stroke

  • As I see it, there are two ways to handle mouse events to draw a picture.



    The first is to detect when the mouse moves and draw a line to where the mouse is, shown here. However, the problem with this is that with a large brush size, many gaps appear between each "line" that is not straight since it is using the line's stroke size to create thick lines.



    The other way is to draw circles when the mouse moves as is shown here. The problem with this is that gaps appear between each circle if the mouse moves faster than the computer detects mouse input.



    Here's a screenshot with my issues with both: http://imgur.com/32DXN



    What is the best way to implement a brush like MS Paint's, with a decently-big brush size with no gaps in the stroke of the line or no gaps between each circle?

Re: [pygame] sprite engine Top this!

  • # Redraw part of screen
    R = rect.clip(self.rect)
    i = R.collidelist(self.dirtyrects)
    if i > -1:
    # Add to existing dirty rectangle
    while i > -1:
    R.union_ip(self.dirtyrects[i])
    del self.dirtyrects[i]
    i = R.collidelist(self.dirtyrects)
    self.dirtyrects.append(R)
15 Jun 08

pygame Code Repository

  • Description: A function to display an inputbox and return the inputted text string.
1 - 20 of 25 Next ›
Showing 20 items per page

Diigo is about better ways to research, share and collaborate on information. Learn more »

Join Diigo