Création de la classe Disque

master
Yohann Dedy 2018-08-30 18:59:36 +02:00
parent fea05a965e
commit 8cb3726df0
2 changed files with 41 additions and 1 deletions

32
disque.py Normal file
View File

@ -0,0 +1,32 @@
class Disque():
def __init__(self,centre,diam):
self.c = centre
self.d = diam
self.nbPart = 900
def display(self):
noStroke()
ellipse(self.c.x,
self.c.y,
self.d,self.d)
for i in range(0,self.nbPart):
pos = self.posInCir()
fill(110)
stroke(255)
ellipse(pos.x, pos.y, 10,10)
def populate(self):
return
def posInCir(self):
posX = random(width)
posY = random(height)
pos = PVector(posX, posY)
dist = self.c.dist(pos)
if(dist > self.d/2):
return self.posInCir()
else:
return pos

View File

@ -1,5 +1,6 @@
# palette https://coolors.co/c0caad-9da9a0-654c4f-b26e63-cec075
from datetime import datetime
from disque import Disque
def posInCir(diam,center):
posX = random(width)
@ -13,6 +14,11 @@ def posInCir(diam,center):
else:
return pos
posDisque = PVector(123,300)
global test
test = Disque(posDisque,250)
cerDiam = 500
size(650, 650)
center = PVector(width/2,height/2)
@ -22,7 +28,7 @@ noStroke()
fill('#b26e63')
ellipse(center.x,center.y,cerDiam,cerDiam)
for i in range(0,10000):
for i in range(0,1000):
fill('#654c4f')
stroke('#c0caad')
strokeWeight(1)
@ -35,5 +41,7 @@ for i in range(0,10000):
pos.y,
diam,diam)
test.display()
filename = datetime.now().strftime('%Y%m%d%H%M%S.tga')
#save(filename)