Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Strange Attractors
var cnt = 0.0; var aa = 0.0; var bb = 0.0; var cc = 0.0; var dd = 0.0; var ee = 0.0; var ff = 0.0; var xr = 0.0; var yr = 0.0; var zr = 0.0; function setup() { createCanvas(800, 600,WEBGL); background(249); cnt = 0; aa = random(-3,3); bb = random(-3,3); cc = random(-3,3); dd = random(-3,3); ee = random(-3,3); ff = random(-3,3); xr = random(-1,1); yr = random(-1,1); zr = random(-1,1); } function draw() { cnt +=0.1; var xm = mouseX / width + 0.5; var ym = mouseY / height + 0.5; var pA = xm + aa ; var pB = ym - bb ; var pC = ym + cc ; var pD = xm + dd ; var pE = ym + ee ; var pF = ym - ff ; background(249); rotateX(cnt * PI * xr * 0.03); rotateY(cnt * PI * yr * 0.03); rotateZ(cnt * PI * zr * 0.03); var prevX = 0.0; var prevY = 0.0; var prevZ = 0.0; var singularityX = 0.0; var singularityY = 0.0; var singularityZ = 0.0; stroke(60, 8, 60, 128); beginShape(POINTS); for (var i = 0; i < 60000; i++) { var x = sin(pA * prevY) - cos(pB * prevX); var y = sin(pC * prevZ) - cos(pD * prevY); var z = sin(pE * prevX) - cos(pF * prevZ); var scale = 6.0 + sin(cnt * PI * 0.05); vertex(x * width / scale, y * height / scale, z * height / scale); prevX = x; prevY = y; prevZ = z; if(i == 10000){ singularityX = x; singularityY = y; singularityZ = z; } } endShape(CLOSE); noFill(); stroke(250, 200, 250, 10); push(); translate(singularityX * width / scale, singularityY * height / scale, singularityZ * height / scale); sphere(1200.3); pop(); } function mouseClicked() { changeVariable(); } function changeVariable() { aa = random(-3,3); bb = random(-3,3); cc = random(-3,3); dd = random(-3,3); ee = random(-3,3); ff = random(-3,3); xr = random(-1,1); yr = random(-1,1); zr = random(-1,1); }
run
|
edit
|
history
|
help
0
Mreee
Javascript Basics
Set(), union, intersection, difference
Arrays
Dum
Aa
strCompression
100034322376708
Javascript Basics If statements
Just stop thinking about it and go eat