Skip to content

Instantly share code, notes, and snippets.

@martoo6
Created May 10, 2016 17:38
Show Gist options
  • Save martoo6/209f4e8f0f238344e6d144a5ee93c76d to your computer and use it in GitHub Desktop.
Save martoo6/209f4e8f0f238344e6d144a5ee93c76d to your computer and use it in GitHub Desktop.
MCCC Colaboration
import main.lib._
import main.recorder.{GifRecorder, RecorderConfig}
import scala.scalajs.js.annotation.JSExport
import scala.util.Try
@JSExport
class ThreeJSApp21 extends BasicCanvas with SimplexNoise with DrawingUtils with StatsDisplay with GifRecorder with CameraControls with AutoClear{
Setup._2D.asScene
val recorderConfig = RecorderConfig(Nil, frameLimit = 30*5)
lineWeight(3)
val p = Palette(new Color(0x2D4059), new Color(0xFF5722), new Color(0xEEEEEE))
val scale = 20
val similarity = 0.04
val stripLength = 50
val steps = (2 to stripLength).map(_*0.05).toArray
val list = for{
i <- 0 to 100
lineNoiseSeed = i *similarity
} yield {
steps.foldLeft((0.0, 0.0, 0.0) :: Nil) { (lst, n) =>
val (x, y, z) = lst.head
(noise(n, lineNoiseSeed + 200) * scale + x, noise(n, lineNoiseSeed + 300) * scale + y, noise(n, lineNoiseSeed + 400) * scale + z) :: lst
}
}
def render(): Unit = {
rect((0, 0, -500), width*100, height*100, new Color(0x222831))
val slice = fCos(TWO_PI*frameCount/(30*5)).map(-1,1,0,stripLength - 2).toInt
val g = list.indices.map { i =>
val c = p(i % p.colors.size)
mspline(list(i).drop(slice), list.size, c)
}
grouped(g).setRotationFromAxisAngle(yAxis, frameCount.map(0, 30 * 5, 0, TWO_PI))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment