1 """
2 spiral.pyde python mode sketch
3 features fairly extreme recursion for
4 python hence we try increase limit
5 but it doesn't work so we capture error
6 """
7 MAX_RECURSION = 1000
8
9
10 def setup():
11 """
12 processing setup
13 """
14 size(400, 400)
15 translate(100, 330)
16 rotate(0.3)
17 fill(255, 0, 0, 0)
18 background(0)
19 noStroke()
20 smooth()
21 fill(255, 0, 0, 20) # transparency makes for almost '3d' look
22 import sys # increase recursion limit or sketch will fail
23 sys.setrecursionlimit(MAX_RECURSION)
24 try: # handle potential index error
25 shell(-0.008, 1.5, 25)
26 except RuntimeError:
27 print "Sketch exceeds set recursion limit"
28 else:
29 pass # Sketch finishes before recursion limit is reached
30
31
32 def shell(rot, disp, sz):
33 """
34 Recursive shell shape limited by sz
35 """
36 REDUCE = 0.999
37 MIN_SIZE = 0.8 # about right for processing
38 if (sz > MIN_SIZE):
39 sz *= REDUCE
40 disp *= REDUCE
41 translate(disp, 0)
42 rotate(rot)
43 ellipse(disp, 0, sz, sz)
44 return shell(rot, disp, sz) # recursive call
45 else:
46 return # break recursive loop on size
47
To get python syntax highlighting in jEdit with the *.pyde file add the following to the mode catalog:-
1 <?xml version="1.0"?>
2 <!DOCTYPE MODES SYSTEM "catalog.dtd">
3
4 <MODES>
5
6 <!-- Add lines like the following, one for each edit mode you add: -->
7 <!-- <MODE NAME="foo" FILE="foo.xml" FILE_NAME_GLOB="*.foo" /> -->
8
9 <MODE NAME="processing.py" FILE="python.xml" FILE_NAME_GLOB="*.pyde" />
10 </MODES>