Skip to content

Commit

Permalink
MouseX position line added
Browse files Browse the repository at this point in the history
added a line from points to mouse position
  • Loading branch information
Wuradclan committed Feb 24, 2020
1 parent 2424208 commit aaa1af5
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 20 deletions.
29 changes: 26 additions & 3 deletions particules_sinus/particules_sinus.pyde
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import points
def setup():
size(1500,500)
frameRate(24)
global p,ps,s,x,y
d =25
d = 50
y = height/2
ps = []
s = sqrt(width**2+height**2)
Expand All @@ -14,6 +15,7 @@ def setup():
# if i%2 == 0:
# p = points.Points(i,i,d)
# else:
# #p = points.Points(i,-(height)+i,d)
# p = points.Points(i,height/2+i,d)
ps.append(p)

Expand All @@ -23,7 +25,7 @@ def draw():
background(0)
fill(255)
stroke(255)
strokeWeight(2)
strokeWeight(1)

global p,ps

Expand All @@ -33,19 +35,40 @@ def draw():

for i in range(len(ps)-1):
di= dit(ps[i],ps[j])
m = map(di,0,400,100,0)
m = map(di,50,400,100,0)
#print m
colorMode(HSB,360,100,100)
stroke(200,100-m,m,m)
line(ps[i].x,ps[i].y,ps[j].x,ps[j].y)

ps[j].movesin()
ps[j].draw_it()
# draw lines from each point to mouse position
for i in range(len(ps)):
dim = ditMouse(ps[i])
# for i in range(len(ps)-1):
#di= dit(ps[i],ps[j])
mm = map(dim,50,400,100,0)
#print m
colorMode(HSB,360,100,100)
if mousePressed:

stroke(33,100-mm,mm)
line(ps[i].x,ps[i].y,mouseX,mouseY)
else :
stroke(100,100-mm,mm,mm)
line(ps[i].x,ps[i].y,mouseX,mouseY)



def dit(a,b):
d = dist(a.x,a.y,b.x,b.y)
#print d
return d

def ditMouse(a):
d = dist(a.x,a.y,mouseX,mouseY)
#print d
return d


Binary file modified particules_sinus/points$py.class
Binary file not shown.
34 changes: 17 additions & 17 deletions particules_sinus/points.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,33 @@ def __init__(self,x,y,d):

self.x = x*d
self.y = y*d
self.sz = 10
self.sz = 6
# V for velocity vilocity x (-5, 5)
self.v_x = 1
self.v_y = 1
self.d = d
self.a = self.y


def move(self):
# Should move the particle according to its velocity.
#self.x += self.v_x
print("YY:",self.y)
di = height/2 - self.y
print(di)
v = float(map(di,0,height/2-40,1,1.5))
print("V :",v)
self.y += v
# Should wrap around the screen if off limits.
# if self.y <= 100:
# self.y += v
# if self.y >= 350:
# self.y -= v
pass
# def move(self):
# # Should move the particle according to its velocity.
# #self.x += self.v_x
# print("YY:",self.y)
# di = height/2 - self.y
# print(di)
# v = float(map(di,0,height/2-40,1,1.5))
# print("V :",v)
# self.y += v
# # Should wrap around the screen if off limits.
# # if self.y <= 100:
# # self.y += v
# # if self.y >= 350:
# # self.y -= v
# pass

def movesin(self):
# controle the speed y 1250 ideal
inc = TWO_PI/ 1250
inc = TWO_PI/ 500
if mousePressed:
inc = TWO_PI/100

Expand Down

0 comments on commit aaa1af5

Please sign in to comment.