Skip to content

Commit 90684c8

Browse files
committed
adding some examples collected over time
1 parent 600b650 commit 90684c8

File tree

1 file changed

+176
-96
lines changed

1 file changed

+176
-96
lines changed

coffee/core/program-loader.coffee

Lines changed: 176 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -38,46 +38,7 @@ define [
3838
box
3939
"""
4040

41-
@programs.demos.cheeseAndOlivesDemo =
42-
submenu: "Basic"
43-
title: "Cheese and olives"
44-
code: """
45-
// 'Cheese and olives' by
46-
// Davina Tirvengadum
47-
// Mozilla festival 2012
48-
49-
background white
50-
scale .3
51-
move 0,-1
52-
fill yellow
53-
stroke black
54-
rotate
55-
strokeSize 3
56-
line 4
57-
box
58-
59-
rotate 2,3
60-
move 0,3
61-
scale .3
62-
fill black
63-
stroke black
64-
ball
65-
66-
rotate 3
67-
move 5
68-
scale 1
69-
fill green
70-
stroke green
71-
ball
72-
73-
rotate 1
74-
move -3
75-
scale 1
76-
fill yellow
77-
stroke yellow
78-
ball
79-
"""
80-
41+
8142
@programs.demos.simpleCubeDemo =
8243
submenu: "Basic"
8344
title: "Simple cube"
@@ -90,15 +51,6 @@ define [
9051
box
9152
"""
9253

93-
@programs.demos.webgltwocubesDemo =
94-
submenu: "WebGL"
95-
title: "WebGL: Two cubes"
96-
code: """
97-
background 155,255,255
98-
2 times
99-
▶rotate 0, 1, time/2
100-
▶box
101-
"""
10254

10355
@programs.demos.cubesAndSpikes =
10456
submenu: "Basic"
@@ -114,6 +66,124 @@ define [
11466
▶▶rotate 0,1,1
11567
▶▶box 0.01,0.01,1
11668
"""
69+
70+
@programs.demos.redthreadsDemo =
71+
submenu: "Basic"
72+
title: "Red threads"
73+
code: """
74+
scale 4.5
75+
background black
76+
stroke red
77+
noFill
78+
strokeSize 7
79+
2 times
80+
▶rotate time/20
81+
▶ball
82+
▶rotate 0,1,1
83+
▶ball
84+
"""
85+
86+
87+
@programs.demos.ringBall =
88+
submenu: "Complex"
89+
title: "Ring ball"
90+
code: """
91+
ringDetail = 45
92+
ambientLight 255
93+
noStroke
94+
fill orange
95+
background black
96+
rotate time /5
97+
scale 0.7
98+
9 times with i
99+
▶rotate time/5 + i
100+
▶for i in [0...ringDetail]
101+
▶▶rotate 0,0,2*Math.PI/(ringDetail)
102+
▶▶move 2,0,0
103+
▶▶▶rect 1,0.3+1/ringDetail
104+
"""
105+
106+
@programs.demos.crazyRibbon =
107+
submenu: "Complex"
108+
title: "Crazy ribbon"
109+
code: """
110+
noStroke
111+
fill red
112+
background black
113+
rotate time
114+
200 times with i
115+
▶rotate time * 2 + sin i
116+
▶▶move 2,0,0
117+
▶▶▶box 1,0.4, 0.07
118+
"""
119+
120+
@programs.demos.acidTown =
121+
submenu: "Complex"
122+
title: "Acid town"
123+
code: """
124+
absin = (x) -> 255*abs sin time*x
125+
animationStyle paintOver
126+
scale 3.5
127+
background black
128+
stroke (absin 1),(absin 2),(absin 3)
129+
noFill
130+
strokeSize 7
131+
2 times
132+
▶rotate time/20
133+
▶box
134+
"""
135+
136+
@programs.demos.theGrid =
137+
submenu: "Complex"
138+
title: "The grid"
139+
code: """
140+
background magenta
141+
gridSize = 4 * abs(wave 0.05)
142+
scale 1/(abs(gridSize)+2) // fit the screen
143+
pad = 1+abs(2*wave 0.5)
144+
ambientLight
145+
fill yellow,230
146+
rotate time
147+
// center everything
148+
move -(pad*gridSize/2)
149+
gridSize times with rows
150+
▶gridSize times with columns
151+
▶▶gridSize times with slices
152+
▶▶▶move pad*rows, pad*columns, pad*slices
153+
▶▶▶▶box
154+
"""
155+
156+
@programs.demos.tube =
157+
submenu: "Complex"
158+
title: "Tube"
159+
code: """
160+
background black
161+
rotate time/10
162+
move 0,-1.2,-1
163+
rotate 3.14/2,0,0
164+
scale 0.5
165+
noStroke
166+
8 times with j
167+
▶move 0,0.5,0
168+
▶31 times with i
169+
▶▶rotate 0,0.2,0
170+
▶▶r = ((i * 3) + time*12)%255
171+
▶▶g = ((i * 7) + (time*30+20)*7)%255
172+
▶▶b= ((j * 17) + (time*30+40)*3)%255
173+
▶▶fill r,g,b
174+
▶▶rect 0.3,0.3
175+
▶▶move 0.5,0,0
176+
"""
177+
178+
@programs.demos.webgltwocubesDemo =
179+
submenu: "WebGL"
180+
title: "WebGL: Two cubes"
181+
code: """
182+
background 155,255,255
183+
2 times
184+
▶rotate 0, 1, time/2
185+
▶box
186+
"""
117187

118188
@programs.demos.webglturbineDemo =
119189
submenu: "WebGL"
@@ -124,7 +194,20 @@ define [
124194
▶rotate time/100,1,time/100
125195
▶box
126196
"""
127-
197+
198+
@programs.demos.webgllavaDemo =
199+
submenu: "WebGL"
200+
title: "WebGL: Lava"
201+
code: """
202+
scale 4.5
203+
noStroke
204+
10 times with i
205+
▶rotate 1,time/400,2
206+
▶fill 255,0,200*abs(sin((i)))
207+
▶ball
208+
"""
209+
210+
128211
@programs.demos.webglzfightartDemo =
129212
submenu: "WebGL"
130213
title: "WebGL: Z-fight!"
@@ -133,13 +216,50 @@ define [
133216
// of your GPU!
134217
// Go Z-fighting, go!
135218
scale 5
219+
noStroke
136220
rotate
137221
fill red
138222
box
139223
rotate 0.000001
140224
fill yellow
141225
box
142226
"""
227+
228+
@programs.demos.webglaKnot =
229+
submenu: "WebGL"
230+
title: "WebGL: A knot"
231+
code: """
232+
turns = 2
233+
detail = 400
234+
speed = 0.4
235+
background black
236+
scale 0.9
237+
rotate 15,3,1
238+
for i in [0...detail]
239+
▶rotate 0,0,2*Math.PI/(detail)
240+
▶move 0.65
241+
▶▶rotate turns*i*Math.PI/(detail)+time*speed,0,0
242+
▶▶▶rect 1
243+
"""
244+
245+
@programs.demos.seaweeds =
246+
submenu: "Complex"
247+
title: "Seaweeds"
248+
code: """
249+
turns = 2
250+
detail = 100
251+
speed = 2
252+
background black
253+
scale 2
254+
rotate time/5
255+
4 times
256+
▶rotate 0,2,0
257+
▶for i in [0...detail]
258+
▶▶rotate 0,0,2*Math.PI/(detail)
259+
▶▶move 2,5,1
260+
▶▶▶rotate turns*i*Math.PI/(detail)+time*speed,0,0
261+
▶▶▶rect 1
262+
"""
143263

144264
@programs.demos.littleSpiralOfCubes =
145265
submenu: "Basic"
@@ -385,26 +505,10 @@ define [
385505
▶rotate 0,1,1
386506
▶ball -1.01
387507
"""
388-
389-
@programs.demos.webglredthreadsDemo =
390-
submenu: "WebGL"
391-
title: "WebGL: Red threads"
392-
code: """
393-
scale 10.5
394-
background black
395-
stroke red
396-
noFill
397-
strokeSize 7
398-
5 times
399-
▶rotate time/20
400-
▶ball
401-
▶rotate 0,1,1
402-
▶ball
403-
"""
404-
405-
@programs.demos.webglribbon =
406-
submenu: "WebGL"
407-
title: "WebGL: Ribbon"
508+
509+
@programs.demos.ribbon =
510+
submenu: "Complex"
511+
title: "Ribbon"
408512
code: """
409513
turns = 1 // 1 = Möbius strip
410514
detail = 200 // try up to 400 or so
@@ -422,8 +526,8 @@ define [
422526
"""
423527

424528
@programs.demos.theeye =
425-
submenu: "WebGL"
426-
title: "WebGL: The eye"
529+
submenu: "Complex"
530+
title: "The eye"
427531
code: """
428532
turns = Math.floor(time/10)%6
429533
detail = 100
@@ -440,30 +544,6 @@ define [
440544
▶▶rect 1
441545
"""
442546

443-
@programs.demos.webglnuclearOctopusDemo =
444-
submenu: "WebGL"
445-
title: "WebGL: Nuclear octopus"
446-
code: """
447-
simpleGradient black,color(0,0,(time/.005)%255),black
448-
scale 0.2
449-
move 5,0,0
450-
animationStyle motionBlur
451-
//animationStyle paintOver
452-
stroke 255,0,0,120
453-
fill (time*1000)%255,0,0
454-
pushMatrix
455-
count = 0
456-
3 times
457-
▶count++
458-
▶pushMatrix
459-
▶rotate count+3+time,2+count + time,4+count
460-
▶120 times
461-
▶▶scale 0.9
462-
▶▶move 1,1,0
463-
▶▶rotate time/.1
464-
▶▶box
465-
▶popMatrix
466-
"""
467547

468548
@programs.tutorials.introTutorial =
469549
submenu: "Intro"

0 commit comments

Comments
 (0)