Flutter – Turtle
- 2021年10月15日
- 技術情報
What is flutter turtle? This is a simple presentation of turtle graphics for flutter. It can simply apply to draw graphics with a custom painter like a logo language.
Flutter turtle is two classes, named with TurtleView and AnimatedTurtleView. To create a turtleView, both of classes require commands parameter. If you want your logo to repeat 5 times and forward 100 , right 200. You can use like this using commands parameter.
[
Repeat((_) => 5, [
Forward((_) => 100),
Right((_) => 200),
]),
];
With more information about flutter turtle, check on flutter pub.dev.
Example code :
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('TurtleView'),
centerTitle: true,
elevation: 0,
),
body: TurtleView(
child: Container(),
commands: [
PenDown(),
SetColor((_) => const Color(0xFF006EFF)),
SetStrokeWidth((_) => 2),
Repeat((_) => 20, [
Repeat((_) => 180, [
Forward((_) => 25.0),
Right((_) => 20),
]),
Right((_) => 18),
]),
PenUp(),
],
),
);
}
Hop you enjoyed this article!
By Ami
asahi at 2021年10月15日 10:00:00