Skip to content

Instantly share code, notes, and snippets.

@jezinka
Created Jul 24, 2017
Embed
What would you like to do?
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