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
a b cc dd e e | |
bb ccc ddd eeee | |
ccc ddd eeeee | |
dddd eeee | |
eeeee |
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
z*aa y * bb b x * ccc cc w * dddd dd v * eeeee e e | |
y ***bbbb xxx *** cccccc www *** dddd ddd vvv *** eeeee eeee | |
x *****cccccc www ***** dddd ddd vvvvv ***** eeeeeeeeee | |
w *******dddddddd vvv ******* eeeee eeee | |
v *********eeeeeeeeee |
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
panel { | |
repeat(5) { | |
composed { | |
val rhombus = rhombus { | |
lines = it + 1 | |
char = 'z' - it | |
} | |
val triangle = triangle { | |
lines = it + 1 | |
} |
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
a bbbbb ccccc d eeeee | |
aaa bbbbb ccccc ddd eeeee d | |
aaaaa bbbbb ccccc ddddd eeeee ddd | |
aaaaaaa bbbbb ccccc ddd eeeee ddd | |
aaaaaaaaa bbbbb ccccc d eeeee d |
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
panel { | |
val shapes = mutableListOf<Shape>() | |
repeat(5) { | |
shapes.add(when ((1..3).random()) { | |
1 -> square { | |
lines = 5 | |
char = 'a' + it | |
} | |
2 -> triangle { |
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
a b c d e f g h i j | |
bbb ccc ddd eee fff ggg hhh iii jjj | |
ccccc ddddd eeeee fffff ggggg hhhhh iiiii jjjjj | |
ddddddd eeeeeee fffffff ggggggg hhhhhhh iiiiiii jjjjjjj | |
eeeeeeeee fffffffff ggggggggg hhhhhhhhh iiiiiiiii jjjjjjjjj | |
fffffffffff ggggggggggg hhhhhhhhhhh iiiiiiiiiii jjjjjjjjjjj | |
ggggggggggggg hhhhhhhhhhhhh iiiiiiiiiiiii jjjjjjjjjjjjj | |
hhhhhhhhhhhhhhh iiiiiiiiiiiiiii |
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
panel { | |
for (i in 0..9) { | |
triangle { | |
lines = i + 1 | |
char = 'a' + i | |
} | |
space() | |
} |
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
inline fun panel(init: (@ShapeDsl 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) } |
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
panel { | |
square { | |
lines = 8 | |
char = 'd' | |
this@panel.triangle { | |
lines = 10 | |
char = 'x' | |
} | |
} |
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
@ShapeDsl | |
abstract class ShapeBuilder { | |
private companion object { | |
const val DEFAULT_CHAR = '*' | |
} | |
var char = DEFAULT_CHAR | |
var lines = 0 |
NewerOlder