Skip to content

Commit

Permalink
fixed broken code in new presets
Browse files Browse the repository at this point in the history
  • Loading branch information
iangilman committed Jan 23, 2018
1 parent 6a5b54f commit 88b707c
Show file tree
Hide file tree
Showing 2 changed files with 171 additions and 27 deletions.
178 changes: 152 additions & 26 deletions src/lib/autoPresets.js
Original file line number Diff line number Diff line change
Expand Up @@ -682,8 +682,18 @@ vec2 get_velocity(vec2 p) {
"cy": -1.6277,
"w": 30.2937,
"h": 30.2937,
"code": `v.x = length(p)*min(sin(p.y),cos(p.x));
v.y = cos((p.y+p.y));`
"code": `// p.x and p.y are current coordinates
// v.x and v.y is a velocity at point p
vec2 get_velocity(vec2 p) {
vec2 v = vec2(0., 0.);
// change this to get a new vector field
v.x = length(p)*min(sin(p.y),cos(p.x));
v.y = cos((p.y+p.y));
return v;
}`
},
{
"name": "README 2",
Expand All @@ -695,8 +705,18 @@ v.y = cos((p.y+p.y));`
"cy": -1.62765,
"w": 30.2937,
"h": 30.2937,
"code": `v.x = cos(p.y);
v.y = cos(p.x);`
"code": `// p.x and p.y are current coordinates
// v.x and v.y is a velocity at point p
vec2 get_velocity(vec2 p) {
vec2 v = vec2(0., 0.);
// change this to get a new vector field
v.x = cos(p.y);
v.y = cos(p.x);
return v;
}`
},
{
"name": "README 3",
Expand All @@ -708,8 +728,18 @@ v.y = cos(p.x);`
"cy": -0.7710999999999997,
"w": 55.970200000000006,
"h": 55.970200000000006,
"code": `v.x = min(sin(exp(p.x)),sin(length(p)));
v.y = sin(p.x);`
"code": `// p.x and p.y are current coordinates
// v.x and v.y is a velocity at point p
vec2 get_velocity(vec2 p) {
vec2 v = vec2(0., 0.);
// change this to get a new vector field
v.x = min(sin(exp(p.x)),sin(length(p)));
v.y = sin(p.x);
return v;
}`
},
{
"name": "README 4",
Expand All @@ -721,8 +751,18 @@ v.y = sin(p.x);`
"cy": -1.1695,
"w": 11.4385,
"h": 11.4385,
"code": `v.x = (p.y+cos(p.y));
v.y = sin(min(length(p),log((p.y+p.x))*p.x));`
"code": `// p.x and p.y are current coordinates
// v.x and v.y is a velocity at point p
vec2 get_velocity(vec2 p) {
vec2 v = vec2(0., 0.);
// change this to get a new vector field
v.x = (p.y+cos(p.y));
v.y = sin(min(length(p),log((p.y+p.x))*p.x));
return v;
}`
},
{
"name": "True Dipole",
Expand All @@ -734,12 +774,21 @@ v.y = sin(min(length(p),log((p.y+p.x))*p.x));`
"cy": 0,
"w": 8.5398,
"h": 8.5398,
"code": `float x = p.x;
"code": `// p.x and p.y are current coordinates
// v.x and v.y is a velocity at point p
vec2 get_velocity(vec2 p) {
vec2 v = vec2(0., 0.);
// change this to get a new vector field
float x = p.x;
float y = p.y;
// true dipole
v.x = 2.0*x*y;
v.y = y*y - x*x;`
v.y = y*y - x*x;
return v;
}`
},
{
"name": "Flow profile of a sphere",
Expand All @@ -751,7 +800,13 @@ v.y = y*y - x*x;`
"cy": -0.11769999999999992,
"w": 11.434999999999999,
"h": 11.434999999999999,
"code": `float x = p.x;
"code": `// p.x and p.y are current coordinates
// v.x and v.y is a velocity at point p
vec2 get_velocity(vec2 p) {
vec2 v = vec2(0., 0.);
// change this to get a new vector field
float x = p.x;
float y = p.y;
float r = sqrt(x*x+y*y);
float sinth = y/r;
Expand All @@ -764,7 +819,10 @@ float ur = Uinf*(1.-1.5*R/r+0.5*R*R*R/(r*r*r))*costh;
float uth = Uinf*(-1.+0.75*R/r+0.25*R*R*R/(r*r*r))*sinth;
// to ux uy
v.x = costh*ur-sinth*uth;
v.y = sinth*ur+costh*uth;`,
v.y = sinth*ur+costh*uth;
return v;
}`,
"particleCount": 7000
},
{
Expand All @@ -774,13 +832,22 @@ v.y = sinth*ur+costh*uth;`,
"cy": -0.9834499999999995,
"w": 96.8415,
"h": 96.8415,
"code": `float r = length(p);
"code": `// p.x and p.y are current coordinates
// v.x and v.y is a velocity at point p
vec2 get_velocity(vec2 p) {
vec2 v = vec2(0., 0.);
// change this to get a new vector field
float r = length(p);
float theta = atan(p.y, p.x);
v = vec2(p.y, -p.x) / r;
float t = sqrt(r * 10.) + theta + frame * .02;
v *= sin(t);
v *= length(v) * 10.;
v += p * .2;`,
v += p * .2;
return v;
}`,
"timeStep": 0.01,
"fadeOut": 0.9,
"dropProbability": 0.009,
Expand All @@ -796,9 +863,18 @@ v += p * .2;`,
"cy": 0.3591500000000001,
"w": 8.5397,
"h": 8.5397,
"code": `float a = .1;
"code": `// p.x and p.y are current coordinates
// v.x and v.y is a velocity at point p
vec2 get_velocity(vec2 p) {
vec2 v = vec2(0., 0.);
// change this to get a new vector field
float a = .1;
float r2 = p.x * p.x + p.y * p.y;
v = vec2(p.y, -p.x) / r2 - a * p;`
v = vec2(p.y, -p.x) / r2 - a * p;
return v;
}`
},
{
"name": "Julia set",
Expand All @@ -810,13 +886,23 @@ v = vec2(p.y, -p.x) / r2 - a * p;`
"cy": -0.01795000000000002,
"w": 5.0845,
"h": 5.0845,
"code": `vec2 c = p;
"code": `// p.x and p.y are current coordinates
// v.x and v.y is a velocity at point p
vec2 get_velocity(vec2 p) {
vec2 v = vec2(0., 0.);
// change this to get a new vector field
vec2 c = p;
vec2 z = vec2(.4, .5);
for (int i = 0; i < 8; i++) {
c = vec2(c.x * c.x - c.y * c.y, c.y * c.x + c.x * c.y);
c += z;
}
v = c;`,
v = c;
return v;
}`,
"particleCount": 10000
},
{
Expand All @@ -829,14 +915,26 @@ v = c;`,
"cy": -0.07015000000000005,
"w": 4.9902,
"h": 4.9902,
"code": `vec2 z = p;
"code": `// p.x and p.y are current coordinates
// v.x and v.y is a velocity at point p
vec2 get_velocity(vec2 p) {
vec2 v = vec2(0., 0.);
// change this to get a new vector field
vec2 z = p;
for(int k=0; k<50; k++) {
z = vec2(z.x * z.x - z.y * z.y, 2. * z.x * z.y) + p;
}
float mask = step(length(z), 2.);
v.x = -p.y/length(p) * (0.5 - mask);
v.y = p.x/length(p) * (0.5 - mask);`,
v.y = p.x/length(p) * (0.5 - mask);
return v;
}`,
"particleCount": 30000
},
{
Expand All @@ -849,8 +947,17 @@ v.y = p.x/length(p) * (0.5 - mask);`,
"cy": 0,
"w": 8.5398,
"h": 8.5398,
"code": `v.x = sin(5.0*p.y + p.x);
v.y = cos(5.0*p.x - p.y);`
"code": `// p.x and p.y are current coordinates
// v.x and v.y is a velocity at point p
vec2 get_velocity(vec2 p) {
vec2 v = vec2(0., 0.);
// change this to get a new vector field
v.x = sin(5.0*p.y + p.x);
v.y = cos(5.0*p.x - p.y);
return v;
}`
},
{
"name": "Shear zone",
Expand All @@ -862,14 +969,24 @@ v.y = cos(5.0*p.x - p.y);`
"cy": 0,
"w": 8.539734222673566,
"h": 8.539734222673566,
"code": `float r = length(p) - 1.5;
"code": `// p.x and p.y are current coordinates
// v.x and v.y is a velocity at point p
vec2 get_velocity(vec2 p) {
vec2 v = vec2(0., 0.);
// change this to get a new vector field
float r = length(p) - 1.5;
float c = 1.0/(1.0+exp(-5.0*r));
float vx1 = -p.y, // circle
vy1 = p.x;
float vx2 = 0.2*p.x+p.y, // spiral
vy2 = 0.2*p.y-p.x;
v.x = c*vx1 + (1.0-c)*vx2;
v.y = c*vy1 + (1.0-c)*vy2;`
v.y = c*vy1 + (1.0-c)*vy2;
return v;
}`
},
{
"name": "Beautiful field",
Expand All @@ -881,14 +998,23 @@ v.y = c*vy1 + (1.0-c)*vy2;`
"cy": -0.36424999999999974,
"w": 24.7317,
"h": 24.7317,
"code": `float dt = 0.01;
"code": `// p.x and p.y are current coordinates
// v.x and v.y is a velocity at point p
vec2 get_velocity(vec2 p) {
vec2 v = vec2(0., 0.);
// change this to get a new vector field
float dt = 0.01;
float t = frame*dt;
float w = 2.*PI/5.;
float A = 2.;
float d = sqrt(p.x*p.x + p.y*p.y);
v.x = A*cos(w*t/d);
v.y = A*sin(w*t/d);`,
v.y = A*sin(w*t/d);
return v;
}`,
"particleCount": 3000
}
];
20 changes: 19 additions & 1 deletion util/makeAutoPresets.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 88b707c

Please sign in to comment.