Permalink
Browse files

Fix up many broken eamples.

  • Loading branch information...
1 parent 51cf3e4 commit 9fae696ef9b4340074f3df4bc05fcbda6f524686 @jdf committed Jun 5, 2013
View
@@ -19,7 +19,7 @@ Download [Processing.py without JRE](http://s.xr.io/processing.py/latest.nojre.z
Then, paste this code into a file, e.g., `mysketch.py`.
def setup():
- size(600, 400, P3D)
+ size(600, 400)
def draw():
ellipse(mouseX, mouseY, 10, 10)
@@ -8,15 +8,15 @@
def setup():
global g
- size(destSize, destSize, P3D)
- g = createGraphics(srcSize, srcSize, JAVA2D)
+ size(destSize, destSize)
+ g = createGraphics(srcSize, srcSize)
def draw():
t = .0005 * millis()
g.beginDraw()
for y in range(srcSize):
for x in range(srcSize):
- blue = noise(t + .1*x, t + .05*y, .2*t)
+ blue = noise(t + .1*x, t + .05*y, .1 * t)
g.set(x, y, color(0, 0, 255 * blue))
g.endDraw()
image(g, 0, 0, destSize, destSize)
@@ -37,7 +37,7 @@
from ddf.minim import Minim
def setup():
- size(512, 200, P2D)
+ size(512, 200)
# always start Minim before you do anything with it
global minim
minim = Minim(this)
@@ -1,8 +1,4 @@
-
-#ifdef GL_ES
-precision mediump float;
-#endif
-
+#define PROCESSING_COLOR_SHADER
uniform float time;
uniform vec2 resolution;
@@ -23,10 +19,10 @@ vec3 fade(vec3 t) {
}
vec2 rotate(vec2 point, float rads) {
- float cs = cos(rads);
- float sn = sin(rads);
- return point * mat2(cs, -sn, sn, cs);
-}
+ float cs = cos(rads);
+ float sn = sin(rads);
+ return point * mat2(cs, -sn, sn, cs);
+}
vec4 randomizer4(const vec4 x)
{
@@ -63,54 +59,53 @@ float cnoise4(const in vec3 xx)
return 1.0 - 2.0 * re;
}
float surface3 ( vec3 coord, float frequency ) {
-
- float n = 0.0;
-
- n += 1.0 * abs( cnoise4( coord * frequency ) );
- n += 0.5 * abs( cnoise4( coord * frequency * 2.0 ) );
- n += 0.25 * abs( cnoise4( coord * frequency * 4.0 ) );
- n += 0.125 * abs( cnoise4( coord * frequency * 8.0 ) );
- n += 0.0625 * abs( cnoise4( coord * frequency * 16.0 ) );
-
- return n;
+
+ float n = 0.0;
+
+ n += 1.0 * abs( cnoise4( coord * frequency ) );
+ n += 0.5 * abs( cnoise4( coord * frequency * 2.0 ) );
+ n += 0.25 * abs( cnoise4( coord * frequency * 4.0 ) );
+ n += 0.125 * abs( cnoise4( coord * frequency * 8.0 ) );
+ n += 0.0625 * abs( cnoise4( coord * frequency * 16.0 ) );
+
+ return n;
}
-
+
void main( void ) {
- float rads = radians(time*3.15);
- vec2 position = gl_FragCoord.xy / resolution.xy;
- position += rotate(position, rads);
- float n = surface3(vec3(position*sin(time*0.1), time * 0.05)*mat3(1,0,0,0,.8,.6,0,-.6,.8),0.9);
- float n2 = surface3(vec3(position*cos(time*0.1), time * 0.04)*mat3(1,0,0,0,.8,.6,0,-.6,.8),0.8);
- float lum = length(n);
- float lum2 = length(n2);
-
- vec3 tc = pow(vec3(1.0-lum),vec3(sin(position.x)+cos(time)+4.0,8.0+sin(time)+4.0,8.0));
- vec3 tc2 = pow(vec3(1.1-lum2),vec3(5.0,position.y+cos(time)+7.0,sin(position.x)+sin(time)+2.0));
- vec3 curr_color = (tc*0.8) + (tc2*0.5);
-
-
- //Let's draw some stars
-
- float scale = sin(0.3 * time) + 5.0;
- vec2 position2 = (((gl_FragCoord.xy / resolution) - 0.5) * scale);
- float gradient = 0.0;
- vec3 color = vec3(0.0);
- float fade = 0.0;
- float z = 0.0;
- vec2 centered_coord = position2 - vec2(sin(time*0.1),sin(time*0.1));
- centered_coord = rotate(centered_coord, rads);
-
- for (float i=1.0; i<=60.0; i++)
- {
- vec2 star_pos = vec2(sin(i) * 250.0, sin(i*i*i) * 250.0);
- float z = mod(i*i - 10.0*time, 256.0);
- float fade = (256.0 - z) /256.0;
- vec2 blob_coord = star_pos / z;
- gradient += ((fade / 384.0) / pow(length(centered_coord - blob_coord), 1.5)) * ( fade);
- }
-
- curr_color += gradient;
-
- gl_FragColor = vec4(curr_color, 1.0);
-}
-
+ float rads = radians(time*3.15);
+ vec2 position = gl_FragCoord.xy / resolution.xy;
+ position += rotate(position, rads);
+ float n = surface3(vec3(position*sin(time*0.1), time * 0.05)*mat3(1,0,0,0,.8,.6,0,-.6,.8),0.9);
+ float n2 = surface3(vec3(position*cos(time*0.1), time * 0.04)*mat3(1,0,0,0,.8,.6,0,-.6,.8),0.8);
+ float lum = length(n);
+ float lum2 = length(n2);
+
+ vec3 tc = pow(vec3(1.0-lum),vec3(sin(position.x)+cos(time)+4.0,8.0+sin(time)+4.0,8.0));
+ vec3 tc2 = pow(vec3(1.1-lum2),vec3(5.0,position.y+cos(time)+7.0,sin(position.x)+sin(time)+2.0));
+ vec3 curr_color = (tc*0.8) + (tc2*0.5);
+
+
+ //Let's draw some stars
+
+ float scale = sin(0.3 * time) + 5.0;
+ vec2 position2 = (((gl_FragCoord.xy / resolution) - 0.5) * scale);
+ float gradient = 0.0;
+ vec3 color = vec3(0.0);
+ float fade = 0.0;
+ float z = 0.0;
+ vec2 centered_coord = position2 - vec2(sin(time*0.1),sin(time*0.1));
+ centered_coord = rotate(centered_coord, rads);
+
+ for (float i=1.0; i<=60.0; i++)
+ {
+ vec2 star_pos = vec2(sin(i) * 250.0, sin(i*i*i) * 250.0);
+ float z = mod(i*i - 10.0*time, 256.0);
+ float fade = (256.0 - z) /256.0;
+ vec2 blob_coord = star_pos / z;
+ gradient += ((fade / 384.0) / pow(length(centered_coord - blob_coord), 1.5)) * ( fade);
+ }
+
+ curr_color += gradient;
+
+ gl_FragColor = vec4(curr_color, 1.0);
+}
@@ -20,8 +20,8 @@
pg = None
def setup():
global pg
- size(640, 360, OPENGL)
- pg = createGraphics(160, 90, P2D)
+ size(640, 360)
+ pg = createGraphics(160, 90)
frame.setTitle("Processing.py")
@@ -121,6 +121,11 @@ public void launcher() throws Exception {
assertEquals("CMLx\n", run("launcher"));
}
+ @Test
+ public void millis() throws Exception {
+ assertEquals("True\n", run("millis"));
+ }
+
public static void main(final String[] args) {
JUnitCore.runClasses(JycessingTests.class);
}

0 comments on commit 9fae696

Please sign in to comment.