Created
May 26, 2018 01:34
-
-
Save MacTuitui/3358eec3a8be60e3f25de156052656e0 to your computer and use it in GitHub Desktop.
Code for daily
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //roughly like this | |
| function draw(){ | |
| var frac = (gCount%200)*1.0/(100) | |
| if(frac>1 ) frac = 2-frac | |
| var frac2 = (gCount%200)*1.0/(200) | |
| gFrac = 1-frac2 | |
| val s = 40 | |
| for(k <- 0 until s){ | |
| val sx = if (k%2==0) -width/2 else (k)*1.0/s*width-width/2 | |
| val sy = if (k%2==0) -height/2+k*1.0/s*height else -height/2 | |
| val ex = if (k%2==0) (k)*1.0/s*width-width/2 else -width/2 | |
| val ey = if (k%2==0) -height/2 else -height/2+k*1.0/s*height | |
| val start = new Vec2(sx,sy) | |
| val end = new Vec2(ex,ey) | |
| val d = start.distance(end) | |
| val s2 = (d/5).toInt | |
| for(l <- 0 to s2){ | |
| val f = l*1.0/s2 | |
| val px = start.x+f*(end.x-start.x) | |
| val py = start.y+f*(end.y-start.y) | |
| val pp = new Vec2(px,py).rotate(frac2*TWO_PI) | |
| var dy = (field(pp.x,pp.y)-.5)*20 | |
| val d = new Vec2(px,py).length/width | |
| dy *= frac* 4*(cos((d-frac)*12*TWO_PI)*(1-frac)*frac+frac) | |
| if(l%2==1) dy*= -1 | |
| trace += new Vec2(px+dy,py+dy) | |
| } | |
| } | |
| for(k <- 0 until s){ | |
| val sx = if (k%2==0) (k)*1.0/s*width-width/2 else width/2 | |
| val sy = if (k%2==0) height/2 else -height/2+k*1.0/s*height | |
| val ex = if (k%2==0) width/2 else (k)*1.0/s*width-width/2 | |
| val ey = if (k%2==0) -height/2+k*1.0/s*height else height/2 | |
| val start = new Vec2(sx,sy) | |
| val end = new Vec2(ex,ey) | |
| val d = start.distance(end) | |
| val s2 = (d/5).toInt | |
| for(l <- 0 to s2){ | |
| val f = l*1.0/s2 | |
| val px = start.x+f*(end.x-start.x) | |
| val py = start.y+f*(end.y-start.y) | |
| val pp = new Vec2(px,py).rotate(frac2*TWO_PI) | |
| var dy = (field(pp.x,pp.y)-.5)*20 | |
| val d = new Vec2(px,py).length/width | |
| dy *= frac* 4*(cos((d-frac)*12*TWO_PI)*(1-frac)*frac+frac) | |
| if(l%2==1) dy*= -1 | |
| trace += new Vec2(px+dy,py+dy) | |
| } | |
| } | |
| gCount+=1 | |
| beginShape | |
| trace.map(v => vertex(v.x,v.y)) | |
| endShape | |
| } | |
| def field(x:Double, y:Double) = { | |
| val sc = 0.04*gFrac | |
| min(1, max(0,(noise(x*sc, y*sc)-.15)/.7)) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment