Skip to content

Instantly share code, notes, and snippets.

@pencelab
Created May 16, 2021 11:58
Show Gist options
  • Save pencelab/1c30d08e51ab6a0b808c8a5b4c5c336d to your computer and use it in GitHub Desktop.
Save pencelab/1c30d08e51ab6a0b808c8a5b4c5c336d to your computer and use it in GitHub Desktop.
inline fun panel(init: Panel.() -> Unit): Panel {
return Panel().apply { init() }
}
inline fun Panel.square(init: SquareBuilder.() -> Unit): Square {
return SquareBuilder().apply { init() }.build().also { this.addShape(it) }
}
inline fun Panel.triangle(init: TriangleBuilder.() -> Unit): Triangle {
return TriangleBuilder().apply { init() }.build().also { this.addShape(it) }
}
inline fun Panel.rhombus(init: RhombusBuilder.() -> Unit): Rhombus {
return RhombusBuilder().apply { init() }.build().also { this.addShape(it) }
}
inline fun Panel.composed(init: Panel.() -> ComposedShape): ComposedShape {
return init().also { this.addShape(it) }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment