Skip to content

Instantly share code, notes, and snippets.

@nasustim
Created November 26, 2018 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nasustim/008256bdb707148c0c5943b23f15e650 to your computer and use it in GitHub Desktop.
Save nasustim/008256bdb707148c0c5943b23f15e650 to your computer and use it in GitHub Desktop.
import processing.core.PApplet
trait Points{
val w: Int
val h: Int
}
trait Slopes{
val deg: Double
}
class Ellipses( val w: Int, val h: Int, val deg: Double ) extends Points with Slopes{}
class App extends PApplet{
private var ellipseList: List[Ellipses] = List()
private var seccount = 0
private var count = 0
override def settings(): Unit = {
size( 500, 500 )
}
override def draw(): Unit = {
//background( 0 )
if( seccount >= 60 ){
count += 1
ellipseList :+= addEllipse( count )
seccount = 0
}
pushMatrix()
translate( 250, 250 )
for( i <- 0 until ellipseList.length ){
ellipse( 30, 30, ellipseList.apply(i).w, ellipseList.apply(i).h )
rotate( ellipseList.apply(i).deg.toFloat )
}
popMatrix()
seccount += 1
}
def addEllipse( n: Int ): Ellipses =
new Ellipses( 30, 80, fibonacci( n ) % Math.PI )
def fibonacci( n: Int ): Double =
(1 / Math.sqrt( 5 ) ) * (Math.pow( phi( 1 ), n ) - Math.pow( phi( -1 ), n ))
def phi( n: Int ): Double =
( 1 + (Math.sqrt( 5 ) + n ) ) / 2
}
object p20181126{
def main( Args: Array[String] ): Unit = {
PApplet.main("App")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment