4 {
5
6
7
8struct rules_t {
9 char c;
11};
12
13rules_t rules[6] = {
14 {'X', "F-[[X]+X]+F[+FX]-X"},
15 {'F', "FF"},
16 {'+', "+"},
17 {'-', "-"},
18 {'[', "["},
19 {']', "]"},
20};
21
22std::string
E(std::string
s) {
24 return "";
25 }
26 for (
int i=0;
i<6;
i++) {
27 if (rules[
i].c ==
s[0]) {
28 return rules[
i].s +
E(
s.substr(1));
29 }
30 }
31 return "";
32}
33
34struct Pt {
38};
39
42
44 p.setColor(0xFFA6761D);
48
49 std::vector<struct Pt> ptstack;
50 std::string plant =
E(
E(
E(
E(
E(
"X")))));
51 const double len = 2.5;
52 struct Pt pt = {128, 256, 3.14};
54 path.moveTo(pt.x, pt.y);
55
56 for (std::string::iterator it=plant.begin(); it!=plant.end(); ++it) {
57 if (*it == 'F') {
58 pt.x +=
len*sin(pt.a);
59 pt.y +=
len*cos(pt.a);
60 path.lineTo(pt.x, pt.y);
61 } else if (*it == '+') {
62 pt.a += (0.15 + sin(
frame*2.0*3.14159)*0.05);
63 } else if (*it == '-') {
64 pt.a += (-0.15 + sin(
frame*2.0*3.14159)*0.05);
65 } else if (*it == '[') {
66 ptstack.push_back(pt);
67 } else if (*it == ']') {
68 pt = ptstack.back();
69 ptstack.pop_back();
70 path.moveTo(pt.x, pt.y);
71 }
72 }
74}
75}
constexpr SkColor SK_ColorLTGRAY
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
void drawPath(const SkPath &path, const SkPaint &paint)
@ kStroke_Style
set to stroke geometry
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path