Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 140239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:34:44+00:00 2026-05-11T07:34:44+00:00

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

  • 0

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.jpg

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T07:34:45+00:00Added an answer on May 11, 2026 at 7:34 am

    Why not do both?

    Draw a circle at each endpoint and a line between the two.

    EDIT rofl, just couldn’t stop myself.

    Actually, you don’t want to use pygame.draw.line because it cheats. It fills a 1 pixel wide row or column (depending on angle of attack) of pixels. If you do go at a roughly perpendicular angle, 0 deg or 90 deg, this isn’t an issue, but at 45’s, you’ll notice a sort of string bean effect.

    The only solution is to draw a circle at every pixel’s distance. Here…

    import pygame, random  screen = pygame.display.set_mode((800,600))  draw_on = False last_pos = (0, 0) color = (255, 128, 0) radius = 10  def roundline(srf, color, start, end, radius=1):     dx = end[0]-start[0]     dy = end[1]-start[1]     distance = max(abs(dx), abs(dy))     for i in range(distance):         x = int( start[0]+float(i)/distance*dx)         y = int( start[1]+float(i)/distance*dy)         pygame.draw.circle(srf, color, (x, y), radius)  try:     while True:         e = pygame.event.wait()         if e.type == pygame.QUIT:             raise StopIteration         if e.type == pygame.MOUSEBUTTONDOWN:             color = (random.randrange(256), random.randrange(256), random.randrange(256))             pygame.draw.circle(screen, color, e.pos, radius)             draw_on = True         if e.type == pygame.MOUSEBUTTONUP:             draw_on = False         if e.type == pygame.MOUSEMOTION:             if draw_on:                 pygame.draw.circle(screen, color, e.pos, radius)                 roundline(screen, color, e.pos, last_pos,  radius)             last_pos = e.pos         pygame.display.flip()  except StopIteration:     pass  pygame.quit() 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I see there are two ways to create update query in Hibernate. First you
There are two ways to do this the way I see it without flash.
There are two ways to implement overloads. The first one is to do everything
As far as I can see there are two ways, both with their drawbacks.
I have following fiddle: http://jsfiddle.net/BFSH4/ As you see there are two issues: The h1
As I see it there are two different types of logging: User-focused logs, like
table user: |id|name|employee_priority_id|user_priority_id| table priority: |id|name| As you can see, there are two foreign
When I concatenate the following two unicode characters I see both but there is
Is there a best (see below) way to append two byte arrays in C#?
Click here to see what I mean.. What could prevent these two from sitting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.