Created
November 26, 2018 14:13
-
-
Save nasustim/008256bdb707148c0c5943b23f15e650 to your computer and use it in GitHub Desktop.
This file contains 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
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