"""
Pulses. 

Software drawing instruments can follow a rhythm or abide by rules independent
of drawn gestures. This is a form of collaborative drawing in which the draftsperson
controls some aspects of the image and the software controls others.
"""

angle = 0


def setup():
    size(640, 360)
    background(102)
    noStroke()
    fill(0, 102)


def draw():
    # Draw only when mouse is pressed
    if mousePressed == True:
        angle += 5
        val = cos(radians(angle)) * 12.0
        for a in range(0, 360, 75):
            xoff = cos(radians(a)) * val
            yoff = sin(radians(a)) * val
            fill(0)
            ellipse(mouseX + xoff, mouseY + yoff, val, val)
        fill(255)
        ellipse(mouseX, mouseY, 2, 2)


@@ -4,17 +4,16 @@
 %0APulses.
- 
 %0A%0ASoftwa
@@ -244,21 +244,22 @@
 s.%0A%22%22%22%0A%0A
-angle
+offset
  = 0%0A%0A%0Ad
@@ -351,24 +351,42 @@
 def draw():%0A
+    global offset%0A
     # Draw o
@@ -448,21 +448,22 @@
         
-angle
+offset
  += 5%0A  
@@ -468,19 +468,22 @@
         
-val
+radius
  = cos(r
@@ -493,13 +493,14 @@
 ans(
-angle
+offset
 )) *
@@ -518,16 +518,20 @@
    for a
+ngle
  in rang
@@ -558,17 +558,17 @@
        x
-o
+O
 ff = cos
@@ -573,32 +573,39 @@
 os(radians(a
+ngle
 )) * 
-val
+radius
 %0A           
@@ -606,17 +606,17 @@
        y
-o
+O
 ff = sin
@@ -629,16 +629,23 @@
 ns(a
+ngle
 )) * 
-val
+radius
 %0A   
@@ -691,17 +691,17 @@
 useX + x
-o
+O
 ff, mous
@@ -710,21 +710,27 @@
  + y
-o
+O
 ff, 
-val, val
+radius, radius
 )%0A  
@@ -783,9 +783,8 @@
 , 2, 2)%0A
-%0A

Update for explicit globals.