Skip to content

Commit

Permalink
pylint convex.py
Browse files Browse the repository at this point in the history
    Addresses BruceSherwood#76
  • Loading branch information
GadgetSteve committed Dec 1, 2015
1 parent b8b7117 commit 7c02d2f
Showing 1 changed file with 37 additions and 31 deletions.
68 changes: 37 additions & 31 deletions site-packages/visual/examples/convex.py
Original file line number Diff line number Diff line change
@@ -1,54 +1,60 @@
from visual import *
#!/usr/bin/env python
#coding:utf-8
""" Example of drawing and modifying shapes."""
from __future__ import print_function, division
import visual as vp
from random import uniform

print(__doc__)
# David Scherer

scene.range = 3

a = convex(color=(0.5,0,0))
b = convex(color=(0,0.5,0))
c = convex(color=(0,0,0.5))
d = convex(color=(0.5,0,0.5))
e = convex(color=(0.5,0.5,0))
f = convex(color=(0,0.5,0.5))
vp.scene.range = 3
PI = vp.pi
A = vp.convex(color=(0.5, 0, 0))
B = vp.convex(color=(0, 0.5, 0))
C = vp.convex(color=(0, 0, 0.5))
D = vp.convex(color=(0.5, 0, 0.5))
E = vp.convex(color=(0.5, 0.5, 0))
F = vp.convex(color=(0, 0.5, 0.5))

# circle
t = arange(0,2*pi,0.1)
e.pos = transpose( (sin(t), cos(t)+2, 0*t) )
T = vp.arange(0, 2*PI, 0.1)
E.pos = vp.transpose((vp.sin(T), vp.cos(T)+2, 0*T))

# triangle
t = arange(0,2*pi,2*pi/3)
f.pos = transpose( (sin(t)-2, cos(t)+2, 0*t) )
T = vp.arange(0, 2*PI, 2*PI/3)
F.pos = vp.transpose((vp.sin(T)-2, vp.cos(T)+2, 0*T))

# disk
for t in arange(0,2*pi,0.1):
a.append(pos = (cos(t),0,sin(t)))
a.append(pos = (cos(t),0.2,sin(t)))
for T in vp.arange(0, 2*PI, 0.1):
A.append(pos=(vp.cos(T), 0, vp.sin(T)))
A.append(pos=(vp.cos(T), 0.2, vp.sin(T)))

# box
for i in range(8):
p = vector((i/4)%2 - 2.5, (i/2)%2 - 0.5, (i)%2 - 0.5)
b.append(pos=p)
P = vp.vector((i/4)%2 - 2.5, (i/2)%2 - 0.5, (i)%2 - 0.5)
B.append(pos=P)

# random sphere
L = []
for i in range(1000):
L.append(vector(2,0) + norm(vector(uniform(-1,1),uniform(-1,1),uniform(-1,1))))
c.pos = L
L.append(vp.vector(2, 0) + vp.norm(vp.vector(
uniform(-1, 1), uniform(-1, 1), uniform(-1, 1))))
C.pos = L

# lat/long sphere
L = []
for t in arange(0,2*pi,0.2):
for s in arange(0,pi,0.1):
L.append((cos(t)*sin(s)+2, sin(t)*sin(s)+2, cos(s)))
d.pos = L
for T in vp.arange(0, 2*PI, 0.2):
for s in vp.arange(0, PI, 0.1):
L.append((vp.cos(T)*vp.sin(s)+2, vp.sin(T)*vp.sin(s)+2, vp.cos(s)))
D.pos = L

# modify the disk
p = a
p.color = (p.color[0]*2, p.color[1]*2, p.color[2]*2)
P = A
P.color = (P.color[0]*2, P.color[1]*2, P.color[2]*2)
while 1:
rate(10)
if scene.mouse.clicked:
c = scene.mouse.getclick()
p.append(pos=c.pos)
p.pos[-1] = scene.mouse.pos
vp.rate(10)
if vp.scene.mouse.clicked:
C = vp.scene.mouse.getclick()
P.append(pos=C.pos)
P.pos[-1] = vp.scene.mouse.pos

0 comments on commit 7c02d2f

Please sign in to comment.