Kearo Kai's profile picture

Published by

published
updated

Category: Web, HTML, Tech

Pythons Bubble line

#This program creates a line of bubbles

from graphics import *

from time import sleep

from random import randint

W, H = 400, 400

r = 10

# randint(0, 8 )

#NOTES::

    # how do we get two different coordinates 

    # we have x1, y1 and x2,y2 

    # make a for loop subtracting the delta counts

    #x1 = x1 +dx/10 

win = GraphWin('Bubbly', W, H, autoflush = False)

#win.setCoords(0, 0 , 100, 100)

win.setBackground('black')


p1 = win.getMouse()

p2 = win.getMouse()

x1, y1 = p1.getX(), p1.getY()

x2, y2 = p2.getX(), p2.getY()


dx, dy = x2- x1, y2 - y1

N = 10


bubble = Circle(p1, r)

bubble.setFill('lightblue')

bubble.draw(win)


xi, yi = x1 , y1 


for i in range(N):

    xi, yi = xi +dx/N, yi+ dy/N 

    pi =Point(xi + randint(-10, 10), yi + randint(-10,10) )

    bubble = Circle(pi, r)

    bubble.setFill('lightblue')

    bubble.draw(win)



        

win.getMouse()

win.close()

~~~~~~~~~~~~~~~~~~~~~~~~~~~~OR~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#This program creates a line of bubbles

from graphics import *

from time import sleep

from random import randint

W, H = 400, 400

r = 10

# randint(0, 8 )

#NOTES::

    # how do we get two different coordinates 

    # we have x1, y1 and x2,y2 

    # make a for loop subtracting the delta counts

    #x1 = x1 +dx/10 

win = GraphWin('Bubbly', W, H, autoflush = False)

#win.setCoords(0, 0 , 100, 100)

win.setBackground('black')


p1 = win.getMouse()

p2 = win.getMouse()

x1, y1 = p1.getX(), p1.getY()

x2, y2 = p2.getX(), p2.getY()


dx, dy = x2- x1, y2 - y1

N = 10


bubble = Circle(p1, r)

bubble.setFill('lightblue')

bubble.draw(win)


xi, yi = x1 , y1 


for i in range(N):

    xi, yi = xi +dx/N, yi+ dy/N 

    pi =Point(xi + randint(-10, 10), yi + randint(-10,10) )

    bubble = Circle(pi, r)

    bubble.setFill('lightblue')

    bubble.draw(win)



        

win.getMouse()

win.close()



0 Kudos

Comments

Displaying 0 of 0 comments ( View all | Add Comment )