Python Forum
drawing moving circle on line with python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
drawing moving circle on line with python
#1
hi how are u
i can draw circle and draw line but i cant how to draw moving circle on line .please help me.
Reply
#2
With pygame it would look something like this:
import pygame

SCREEN = pygame.display.set_mode ((600, 400))
circle_x = 50
step = .4

while True :
	for event in pygame.event.get () :
		if event.type == pygame.QUIT :
			quit ()

	SCREEN.fill ((0, 0, 0))
	pygame.draw.rect (SCREEN, (0, 0, 250), (50, 200, 500, 10))
	circle_x += step
	if circle_x > 500 or circle_x < 50 :
		step = -step 
	pygame.draw.ellipse (SCREEN, (255, 0, 0), (circle_x, 150, 50, 50))
	pygame.display.update ()
Or are you using tkinter or turtle or what ?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to plot seaborn heatmap on top of a background circle SriRajesh 0 1,426 Jul-09-2022, 04:00 AM
Last Post: SriRajesh
  multi-line CMD in one-line python kucingkembar 5 4,002 Jan-01-2022, 12:45 PM
Last Post: kucingkembar
  Moving to AWS with Python nigelwright7557 3 1,747 Dec-20-2021, 09:16 PM
Last Post: nigelwright7557
  Program to move a dot towards a circle center plumberpy 10 4,229 Dec-03-2021, 12:20 PM
Last Post: BashBedlam
  Python Networkx: Visualize an edge weight with a bubble/circle uvw 0 2,015 Sep-01-2021, 06:26 AM
Last Post: uvw
  Draw circle from GPS coords, and get GPX file? Winfried 0 2,187 Mar-29-2021, 07:19 PM
Last Post: Winfried
  Moving large amount of data between MySql and Sql Server using Python ste80adr 4 3,440 Apr-24-2020, 01:24 PM
Last Post: Jeff900
  Pyplot and circle Reldaing 0 1,492 Apr-01-2020, 10:44 AM
Last Post: Reldaing
  Python convert multi line into single line formatted string karthidec 2 9,463 Dec-23-2019, 12:46 PM
Last Post: karthidec
  calculate circle sector Bloody_geek 2 2,295 Sep-11-2019, 08:54 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020