From a0401917a054414e76d35bfb698269eeb4430a52 Mon Sep 17 00:00:00 2001 From: snsd0805 Date: Sat, 20 Jun 2020 13:54:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E9=81=A0=E7=AB=AF=E7=B9=AA=E5=9C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- draw.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/draw.py b/draw.py index 881ad1f..a2c6ae1 100644 --- a/draw.py +++ b/draw.py @@ -12,9 +12,13 @@ def sendDraw(sock): clock= pygame.time.Clock() # 使系統鼠標圖標不可見 - pygame.mouse.set_visible(False) + #pygame.mouse.set_visible(False) + + dotPos = [] mouseFlag = False + screen.fill((255, 255, 255)) + pygame.display.update() while True: for event in pygame.event.get(): if event.type== pygame.QUIT: @@ -37,14 +41,18 @@ def sendDraw(sock): if event.type == pygame.MOUSEMOTION: print ('mouse is moving', pygame.mouse.get_pos()) if mouseFlag: + dotPos.append(pygame.mouse.get_pos()) sock.send("{}+".format(pygame.mouse.get_pos()).encode('utf-8')) + pygame.draw.circle(screen,black,pygame.mouse.get_pos(),5,0) - screen.fill((255, 255, 255)) + # 在鼠標周圍畫一個圓 - pos= (pygame.mouse.get_pos()[0], pygame.mouse.get_pos()[1]) - pygame.draw.circle(screen, black, pos, 10, 0) - + #for i in range(len(dotPos)-1): + # pygame.draw.line(screen,black,dotPos[i],dotPos[i+1],5) + #pos= (pygame.mouse.get_pos()[0], pygame.mouse.get_pos()[1]) + #pygame.draw.circle(screen, black, pos, 5, 0) + pygame.display.update() clock.tick(30) @@ -60,6 +68,8 @@ def receiveDraw(sock): screen= pygame.display.set_mode(size) clock= pygame.time.Clock() + screen.fill((255, 255, 255)) + pygame.display.update() print("draw start") while True: for event in pygame.event.get(): @@ -71,7 +81,7 @@ def receiveDraw(sock): #print((li)) for i in li: if i!="": - screen.fill((255, 255, 255)) + #screen.fill((255, 255, 255)) i = i.lstrip('(') i = i.rstrip(')') @@ -80,7 +90,7 @@ def receiveDraw(sock): # 在鼠標周圍畫一個圓 pos = (int(i[0]),int(i[1])) print(pos) - pygame.draw.circle(screen, black, pos, 10, 0) - + # pygame.draw.circle(screen, black, pos, 5, 0) + pygame.draw.circle(screen,black,pos,5,0) pygame.display.update()