-
-
Save jezinka/5f27bbef562198b4473abdd58da74bd6 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
class FernView : View { | |
var fern: Fern = BarnsleyFern() | |
var n: Int = 100000 | |
constructor(ctx: Context) : super(ctx) | |
constructor(ctx: Context, attributeSet: AttributeSet) : super(ctx, attributeSet) | |
val paint = Paint() | |
override fun onDraw(canvas: Canvas) { | |
super.onDraw(canvas) | |
canvas.translate(width / 2f, 0f) | |
paint.style = Paint.Style.FILL | |
paint.color = Color.WHITE | |
canvas.drawPaint(paint) | |
paint.color = Color.parseColor("#006200") | |
val points = fern.generateFern(n) | |
canvas.drawPoints(points, paint) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment