turtle graphics
flutter_turtle is a simple implementation of turtle graphics for flutter. it simply uses a custom painter to draw graphics by a series of logo-like commands.
why i make this?
it is always fun to make your own dsl!
example
a quick example:
@override
widget build(buildcontext context) {
return scaffold(
appbar: appbar(title: text(widget.title)),
body: turtleview(
child: container(),
commands: [
pendown(),
setcolor((_) => color(0xffff9933)),
setstrokewidth((_) => 2),
repeat((_) => 20, [
repeat((_) => 180, [
forward((_) => 25.0),
right((_) => 20),
]),
right((_) => 18),
]),
penup(),
],
),
);
}
commands
currently supported commands are including:
turtle motion
- pendown
- penup
- left
- right
- forward
- back
- setcolor
- setstrokewidth
- goto
- resetposition
- resetheading
flow control
- ifelse
- repeat
macros
- setmacro
- runmacro
misc
- exec
Comments are closed.