flowerevolver 4.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- flowerevolver-4.0.0/LICENSE.md +201 -0
- flowerevolver-4.0.0/PKG-INFO +111 -0
- flowerevolver-4.0.0/cmake/modules/FindEvoAI.cmake +73 -0
- flowerevolver-4.0.0/cmake/modules/FindJsonBox.cmake +62 -0
- flowerevolver-4.0.0/include/fe/3D/FlowerParameters.hpp +66 -0
- flowerevolver-4.0.0/include/fe/3D/GLTF/JsonWriter.hpp +31 -0
- flowerevolver-4.0.0/include/fe/3D/GLTF/Material.hpp +124 -0
- flowerevolver-4.0.0/include/fe/3D/GLTF/Mesh.hpp +66 -0
- flowerevolver-4.0.0/include/fe/3D/GLTF/Node.hpp +43 -0
- flowerevolver-4.0.0/include/fe/3D/GLTF/Scene.hpp +73 -0
- flowerevolver-4.0.0/include/fe/3D/GLTF/TextureInfo.hpp +33 -0
- flowerevolver-4.0.0/include/fe/3D/GLTF/Vertex.hpp +43 -0
- flowerevolver-4.0.0/include/fe/3D/GLTF.hpp +13 -0
- flowerevolver-4.0.0/include/fe/3D/Resources.hpp +11 -0
- flowerevolver-4.0.0/include/fe/3D/Vec.hpp +109 -0
- flowerevolver-4.0.0/include/fe/3D/Vec.inl +109 -0
- flowerevolver-4.0.0/include/fe/3D/contourFinder.hpp +33 -0
- flowerevolver-4.0.0/include/fe/3D/contourSimplifier.hpp +36 -0
- flowerevolver-4.0.0/include/fe/3D/meshGenerator.hpp +140 -0
- flowerevolver-4.0.0/include/fe/3D/utils.hpp +33 -0
- flowerevolver-4.0.0/include/fe/3D.hpp +13 -0
- flowerevolver-4.0.0/include/fe/Color.hpp +312 -0
- flowerevolver-4.0.0/include/fe/DNA.hpp +186 -0
- flowerevolver-4.0.0/include/fe/Flower.hpp +91 -0
- flowerevolver-4.0.0/include/fe/FlowerEvolver.hpp +153 -0
- flowerevolver-4.0.0/include/fe/Image.hpp +93 -0
- flowerevolver-4.0.0/include/fe/MathUtils.hpp +79 -0
- flowerevolver-4.0.0/include/fe/Petals.hpp +149 -0
- flowerevolver-4.0.0/include/fe/Rect.hpp +274 -0
- flowerevolver-4.0.0/include/fe/Rect.inl +171 -0
- flowerevolver-4.0.0/include/fe/SFML-LICENSE.md +21 -0
- flowerevolver-4.0.0/include/fe/Stats.hpp +63 -0
- flowerevolver-4.0.0/include/fe/Vector2.hpp +301 -0
- flowerevolver-4.0.0/include/fe/Vector2.inl +161 -0
- flowerevolver-4.0.0/include/fe/config.hpp.template +50 -0
- flowerevolver-4.0.0/include/fe/detail/FlowerEvolver.hpp +157 -0
- flowerevolver-4.0.0/include/fe/detail/GenomeValidation.hpp +22 -0
- flowerevolver-4.0.0/include/fe.hpp +17 -0
- flowerevolver-4.0.0/include/stb_image_write.h +1724 -0
- flowerevolver-4.0.0/package.json +79 -0
- flowerevolver-4.0.0/pyproject.toml +45 -0
- flowerevolver-4.0.0/python/CMakeLists.txt +106 -0
- flowerevolver-4.0.0/python/README.md +96 -0
- flowerevolver-4.0.0/python/flowerevolver/__init__.py +73 -0
- flowerevolver-4.0.0/python/flowerevolver/cli.py +146 -0
- flowerevolver-4.0.0/python/tests/test_cli.py +204 -0
- flowerevolver-4.0.0/python/tests/test_flowerevolver.py +311 -0
- flowerevolver-4.0.0/src/Android.mk +27 -0
- flowerevolver-4.0.0/src/bindings/emscripten.cpp +170 -0
- flowerevolver-4.0.0/src/bindings/native.cpp +54 -0
- flowerevolver-4.0.0/src/bindings/python/api.cpp +132 -0
- flowerevolver-4.0.0/src/bindings/python/dna.cpp +77 -0
- flowerevolver-4.0.0/src/bindings/python/flower.cpp +51 -0
- flowerevolver-4.0.0/src/bindings/python/image.cpp +69 -0
- flowerevolver-4.0.0/src/bindings/python/json_helpers.hpp +43 -0
- flowerevolver-4.0.0/src/bindings/python/module.cpp +26 -0
- flowerevolver-4.0.0/src/bindings/python/mutation_rates.cpp +48 -0
- flowerevolver-4.0.0/src/bindings/python/petals.cpp +40 -0
- flowerevolver-4.0.0/src/bindings/python/stats.cpp +62 -0
- flowerevolver-4.0.0/src/fe/3D/FlowerParameters.cpp +91 -0
- flowerevolver-4.0.0/src/fe/3D/GLTF/JsonWriter.cpp +492 -0
- flowerevolver-4.0.0/src/fe/3D/GLTF/Material.cpp +93 -0
- flowerevolver-4.0.0/src/fe/3D/GLTF/Mesh.cpp +57 -0
- flowerevolver-4.0.0/src/fe/3D/GLTF/Node.cpp +25 -0
- flowerevolver-4.0.0/src/fe/3D/GLTF/Scene.cpp +26 -0
- flowerevolver-4.0.0/src/fe/3D/GLTF/TextureInfo.cpp +13 -0
- flowerevolver-4.0.0/src/fe/3D/GLTF/Vertex.cpp +14 -0
- flowerevolver-4.0.0/src/fe/3D/contourFinder.cpp +110 -0
- flowerevolver-4.0.0/src/fe/3D/contourSimplifier.cpp +72 -0
- flowerevolver-4.0.0/src/fe/3D/meshGenerator.cpp +870 -0
- flowerevolver-4.0.0/src/fe/3D/utils.cpp +24 -0
- flowerevolver-4.0.0/src/fe/Color.cpp +155 -0
- flowerevolver-4.0.0/src/fe/DNA.cpp +153 -0
- flowerevolver-4.0.0/src/fe/Flower.cpp +76 -0
- flowerevolver-4.0.0/src/fe/Image.cpp +114 -0
- flowerevolver-4.0.0/src/fe/MathUtils.cpp +34 -0
- flowerevolver-4.0.0/src/fe/Petals.cpp +185 -0
- flowerevolver-4.0.0/src/fe/Stats.cpp +137 -0
- flowerevolver-4.0.0/src/fe/detail/FlowerEvolver.cpp +267 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2023-2025 Cristian Gonzalez cristian.glez.m@gmail.com
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: flowerevolver
|
|
3
|
+
Version: 4.0.0
|
|
4
|
+
Summary: Generates 2D/3D flowers from CPPN genomes evolved via EvoAI
|
|
5
|
+
Author-Email: Cristian Gonzalez <cristian.glez.m@gmail.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Programming Language :: C++
|
|
9
|
+
Classifier: Topic :: Multimedia :: Graphics
|
|
10
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Life
|
|
11
|
+
Project-URL: Homepage, https://github.com/cristianglezm/FlowerEvolver-WASM
|
|
12
|
+
Project-URL: Source, https://github.com/cristianglezm/FlowerEvolver-WASM
|
|
13
|
+
Requires-Python: >=3.9
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# FlowerEvolver
|
|
17
|
+
|
|
18
|
+
Native Python bindings for [FlowerEvolver-WASM](https://github.com/cristianglezm/FlowerEvolver-WASM) - generates 2D/3D flowers from CPPN genomes evolved via [EvoAI](https://github.com/cristianglezm/EvoAI).
|
|
19
|
+
|
|
20
|
+
Genomes and rendered images round-trip with FlowerEvolver-WASM's own JS/WASM API and the native desktop app - `Flower.to_json()`/`Flower.from_json()` use the same `{"Flower": {...}}` wire format throughout.
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
Requires JsonBox and EvoAI already built, reuses the exact same build the native C++ library/tests use.
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# builds JsonBox/EvoAI under build/native/, if not already done
|
|
28
|
+
bash .devops/prep.sh native
|
|
29
|
+
|
|
30
|
+
pip install . -Cbuild-dir=build/python \
|
|
31
|
+
-Ccmake.define.EvoAI_ROOT=$(pwd)/build/native/EvoAI/build/install \
|
|
32
|
+
-Ccmake.define.JsonBox_ROOT=$(pwd)/build/native/JsonBox/build/install
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Android (Termux)
|
|
36
|
+
|
|
37
|
+
Not an officially supported/tested platform, but reported working. Termux's Python doesn't expose the Python C-API symbols (`PyExc_ImportError` and friends) back to a `dlopen`'d extension the way a typical glibc Linux build does, so the nanobind extension fails to import with `dlopen failed: cannot locate symbol "PyExc_ImportError"` unless it's linked against `libpython` explicitly:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
LDFLAGS="-lm -lpython3.14" npm run build:python
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
(adjust `python3.14` to whatever `python3 --version` reports on your install).
|
|
44
|
+
|
|
45
|
+
## Usage
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from pathlib import Path
|
|
49
|
+
from flowerevolver import make_flower, reproduce, mutate
|
|
50
|
+
|
|
51
|
+
# make two flowers, breed them, mutate the child
|
|
52
|
+
a = make_flower(radius=64, num_layers=3, P=6.0, bias=1.0)
|
|
53
|
+
b = make_flower(radius=64, num_layers=3, P=6.0, bias=1.0)
|
|
54
|
+
child = reproduce(a.dna, b.dna, radius=64, num_layers=3, P=6.0, bias=1.0)
|
|
55
|
+
mutant = mutate(child.dna, radius=64, num_layers=3, P=6.0, bias=1.0)
|
|
56
|
+
|
|
57
|
+
# save an image and the genome
|
|
58
|
+
Path("flower.png").write_bytes(mutant.petals.image.to_png_bytes())
|
|
59
|
+
Path("flower.json").write_text(mutant.to_json())
|
|
60
|
+
|
|
61
|
+
# ... and load it back later
|
|
62
|
+
from flowerevolver import Flower
|
|
63
|
+
loaded = Flower.from_json(Path("flower.json").read_text())
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Every class and function has a docstring (`help(flowerevolver.make_flower)`, etc.), and the same content is published as a browsable API reference at the [Python docs site](https://cristianglezm.github.io/FlowerEvolver-WASM/docs/python/) (Sphinx + autodoc, matching the C++/JS sites -- see `docs/python-conf/`). Build it locally with:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pip install -r docs/requirements.txt
|
|
70
|
+
npm run build:docs:python
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
(after the install steps above -- autodoc needs the real package importable, unlike the C++/JS sites, which only read source text; see `.devops/build.sh`'s `docs` mode for how this fits alongside those two, or `package.json`'s `build:docs:python` script if you'd rather skip npm and call `sphinx-build`/`python -m sphinx` directly.)
|
|
74
|
+
|
|
75
|
+
## CLI
|
|
76
|
+
|
|
77
|
+
Installing the package also installs a `flower-evolver` command, matching the native desktop app's own single-flower flags - minus `-cli`: the native app has that flag to pick its flag-driven single-flower path instead of launching its GUI, but this binding has no GUI to disambiguate from in the first place, so generating a flower is simply what happens by default:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# create a new flower, print its genome to stdout
|
|
81
|
+
flower-evolver -l 3 -r 64 -p 6.0 -b 1.0
|
|
82
|
+
|
|
83
|
+
# create one, save the genome + image to disk
|
|
84
|
+
flower-evolver -l 3 -r 64 -p 6.0 -b 1.0 -sf flower.json -si flower.png
|
|
85
|
+
|
|
86
|
+
# also generate + save a 3D model (glTF) alongside the 2D image
|
|
87
|
+
flower-evolver -l 3 -r 64 -p 6.0 -b 1.0 -sf flower.json -si flower.png -s3d flower.gltf
|
|
88
|
+
|
|
89
|
+
# ...or an emissive 3D model (useEmissive=true) instead, or both at once
|
|
90
|
+
flower-evolver -l 3 -r 64 -p 6.0 -b 1.0 -sf flower.json -si flower.png -s3d flower.gltf -se3d flower_emissive.gltf
|
|
91
|
+
|
|
92
|
+
# load a flower, mutate it 5 times, save only the final result - matches
|
|
93
|
+
# the native app: -m mutates in a loop and saves once at the end,
|
|
94
|
+
# Run this repeatedly (feeding each -sf output back in
|
|
95
|
+
# via -lf) if you want every intermediate step saved instead.
|
|
96
|
+
flower-evolver -lf flower.json -l 3 -r 64 -p 6.0 -b 1.0 -m 5 -sf flower.json -si flower.png
|
|
97
|
+
|
|
98
|
+
# reproduce two flowers, mutate the child twice, keep only the final result
|
|
99
|
+
flower-evolver -repr flower1.json flower2.json -l 3 -r 64 -p 6.0 -b 1.0 -m 2 -sf kidFlower.json -si kidFlower.png
|
|
100
|
+
|
|
101
|
+
flower-evolver --help
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
`-s3d <filename>`/`-se3d <filename>` are new to this Python CLI - the native app and JS demo both offer 3D export, but as its own separate action (a "Download 3D" button, distinct from "Download Image"), not a CLI flag; they mirror `-sf`/`-si`'s own "save this if you pass a path for it" shape rather than introducing a different kind of flag just for these two outputs. `-s3d` matches `FEService.make3DFlower()` (useEmissive=false); `-se3d` matches `FEService.makeEmissive3DFlower()` (useEmissive=true) -- pass either, or both, to save one or two models from the same flower. Both currently always render `sex="both"` with normals on (matching the JS demo's own default 3D view) -- narrower than `FEService`'s full `make3DFlower`/`makeEmissive3DFlower`/`draw3DFlower` trio in that per-flower sex control and reading params back out of the genome (what `draw3DFlower` does) aren't exposed here; widen it if that turns out to matter for the CLI too.
|
|
105
|
+
|
|
106
|
+
## Tests
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
pip install pytest
|
|
110
|
+
pytest python/tests/
|
|
111
|
+
```
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
######
|
|
2
|
+
# Try to find EvoAI library and include path.
|
|
3
|
+
# Once done this will define
|
|
4
|
+
#
|
|
5
|
+
# EvoAI_FOUND
|
|
6
|
+
# EvoAI_INCLUDE_DIR
|
|
7
|
+
# EvoAI_LIBRARY
|
|
8
|
+
# EvoAI_LIBRARIES
|
|
9
|
+
# EvoAI_ROOT
|
|
10
|
+
######
|
|
11
|
+
|
|
12
|
+
set(FIND_EvoAI_PATHS
|
|
13
|
+
${EvoAI_ROOT}
|
|
14
|
+
$ENV{EvoAI_ROOT}
|
|
15
|
+
/usr/local
|
|
16
|
+
/usr/local/include
|
|
17
|
+
/usr
|
|
18
|
+
/sw
|
|
19
|
+
/opt/local
|
|
20
|
+
/opt/csw
|
|
21
|
+
/opt
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
if(NOT EvoAI_FIND_VERSION_MAJOR)
|
|
25
|
+
set(EvoAI_FIND_VERSION_MAJOR 1)
|
|
26
|
+
endif()
|
|
27
|
+
|
|
28
|
+
set(LIB_SUFFIX "")
|
|
29
|
+
if(CMAKE_SYSTEM_NAME MATCHES "Android")
|
|
30
|
+
set(LIB_SUFFIX "/${CMAKE_ANDROID_ARCH_ABI}")
|
|
31
|
+
endif()
|
|
32
|
+
|
|
33
|
+
if(EvoAI_BUILD_STATIC)
|
|
34
|
+
set(EvoAI_LIBRARY_NAME "EvoAI-${EvoAI_FIND_VERSION_MAJOR}-s")
|
|
35
|
+
else()
|
|
36
|
+
set(EvoAI_LIBRARY_NAME "EvoAI-${EvoAI_FIND_VERSION_MAJOR}")
|
|
37
|
+
endif()
|
|
38
|
+
|
|
39
|
+
find_path(EvoAI_INCLUDE_DIR
|
|
40
|
+
EvoAI.hpp
|
|
41
|
+
PATH_SUFFIXES include
|
|
42
|
+
PATHS ${EvoAI_ROOT}
|
|
43
|
+
NO_CMAKE_FIND_ROOT_PATH
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
find_library(EvoAI_LIBRARY
|
|
47
|
+
NAMES ${EvoAI_LIBRARY_NAME}
|
|
48
|
+
PATH_SUFFIXES lib${LIB_SUFFIX}
|
|
49
|
+
PATHS ${EvoAI_ROOT}
|
|
50
|
+
NO_CMAKE_FIND_ROOT_PATH
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
find_path(EvoAI_INCLUDE_DIR
|
|
54
|
+
EvoAI.hpp
|
|
55
|
+
PATH_SUFFIXES include
|
|
56
|
+
PATHS ${FIND_EvoAI_PATHS}
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
find_library(EvoAI_LIBRARY
|
|
60
|
+
NAMES ${EvoAI_LIBRARY_NAME}
|
|
61
|
+
PATH_SUFFIXES lib${LIB_SUFFIX}
|
|
62
|
+
PATHS ${FIND_EvoAI_PATHS}
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
set(EvoAI_LIBRARIES ${EvoAI_LIBRARY})
|
|
66
|
+
|
|
67
|
+
include(FindPackageHandleStandardArgs)
|
|
68
|
+
find_package_handle_standard_args(
|
|
69
|
+
EvoAI
|
|
70
|
+
DEFAULT_MSG
|
|
71
|
+
EvoAI_LIBRARY
|
|
72
|
+
EvoAI_INCLUDE_DIR
|
|
73
|
+
)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Try to find JsonBox library and include path.
|
|
3
|
+
# Once done this will define
|
|
4
|
+
#
|
|
5
|
+
# JsonBox_FOUND
|
|
6
|
+
# JsonBox_INCLUDE_DIR
|
|
7
|
+
# JsonBox_LIBRARIES
|
|
8
|
+
# JsonBox_LIBRARY
|
|
9
|
+
# JsonBox_ROOT
|
|
10
|
+
#
|
|
11
|
+
|
|
12
|
+
set(FIND_JsonBox_PATHS
|
|
13
|
+
${JsonBox_ROOT}
|
|
14
|
+
$ENV{JsonBox_ROOT}
|
|
15
|
+
/usr/local
|
|
16
|
+
/usr/local/include
|
|
17
|
+
/usr
|
|
18
|
+
/sw
|
|
19
|
+
/opt/local
|
|
20
|
+
/opt/csw
|
|
21
|
+
/opt)
|
|
22
|
+
|
|
23
|
+
set(LIB_SUFFIX "")
|
|
24
|
+
if(CMAKE_SYSTEM_NAME MATCHES "Android")
|
|
25
|
+
set(LIB_SUFFIX "/${CMAKE_ANDROID_ARCH_ABI}")
|
|
26
|
+
endif()
|
|
27
|
+
|
|
28
|
+
find_path(JsonBox_INCLUDE_DIR
|
|
29
|
+
JsonBox.h
|
|
30
|
+
PATH_SUFFIXES include
|
|
31
|
+
PATHS ${JsonBox_ROOT}
|
|
32
|
+
NO_CMAKE_FIND_ROOT_PATH
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
find_library(JsonBox_LIBRARY
|
|
36
|
+
NAMES JsonBox
|
|
37
|
+
PATH_SUFFIXES lib${LIB_SUFFIX}
|
|
38
|
+
PATHS ${JsonBox_ROOT}
|
|
39
|
+
NO_CMAKE_FIND_ROOT_PATH
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
find_path(JsonBox_INCLUDE_DIR
|
|
43
|
+
JsonBox.h
|
|
44
|
+
PATH_SUFFIXES include
|
|
45
|
+
PATHS ${FIND_JsonBox_PATHS}
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
find_library(JsonBox_LIBRARY
|
|
49
|
+
NAMES JsonBox
|
|
50
|
+
PATH_SUFFIXES lib${LIB_SUFFIX}
|
|
51
|
+
PATHS ${FIND_JsonBox_PATHS}
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
set(JsonBox_LIBRARIES ${JsonBox_LIBRARY})
|
|
55
|
+
|
|
56
|
+
include(FindPackageHandleStandardArgs)
|
|
57
|
+
find_package_handle_standard_args(
|
|
58
|
+
JsonBox
|
|
59
|
+
DEFAULT_MSG
|
|
60
|
+
JsonBox_LIBRARY
|
|
61
|
+
JsonBox_INCLUDE_DIR
|
|
62
|
+
)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#ifndef FLOWER_EVOLVER_3D_FLOWER_PARAMETERS_HPP
|
|
2
|
+
#define FLOWER_EVOLVER_3D_FLOWER_PARAMETERS_HPP
|
|
3
|
+
|
|
4
|
+
#include <JsonBox.h>
|
|
5
|
+
|
|
6
|
+
namespace fe{
|
|
7
|
+
/**
|
|
8
|
+
* @brief creation parameters for 3d flowers
|
|
9
|
+
*/
|
|
10
|
+
struct FlowerParameters final{
|
|
11
|
+
/**
|
|
12
|
+
* @brief default constructor
|
|
13
|
+
*/
|
|
14
|
+
FlowerParameters() noexcept;
|
|
15
|
+
/**
|
|
16
|
+
* @brief deserializable constructor
|
|
17
|
+
* @param o JsonBox::Object
|
|
18
|
+
*/
|
|
19
|
+
FlowerParameters(JsonBox::Object o);
|
|
20
|
+
/**
|
|
21
|
+
* @brief serializes the parameters
|
|
22
|
+
* @return JsonBox::Object
|
|
23
|
+
*/
|
|
24
|
+
JsonBox::Object toJson() const noexcept;
|
|
25
|
+
// data
|
|
26
|
+
int sex;
|
|
27
|
+
bool useNormals;
|
|
28
|
+
bool useEmissive;
|
|
29
|
+
// Stem
|
|
30
|
+
float stemHeight;
|
|
31
|
+
float stemRadius;
|
|
32
|
+
int stemSegments;
|
|
33
|
+
// Pistil style
|
|
34
|
+
float pistilStyleHeight;
|
|
35
|
+
float pistilStyleRadius;
|
|
36
|
+
// Pistil Stigma
|
|
37
|
+
int pistilStigmaRadialSegments;
|
|
38
|
+
float pistilStigmaHeight;
|
|
39
|
+
float pistilStigmaMaxWidthFactor;
|
|
40
|
+
float pistilStigmaTipNarrowFactor;
|
|
41
|
+
// stamen filament
|
|
42
|
+
int stamenCount;
|
|
43
|
+
int stamenFilamentRadialSegments;
|
|
44
|
+
float stamenFilamentHeight;
|
|
45
|
+
float stamenFilamentRadius;
|
|
46
|
+
// stamen anther
|
|
47
|
+
int stamenAntherRadialSegments;
|
|
48
|
+
float stamenAntherHeight;
|
|
49
|
+
// Petal Scaling & Shape
|
|
50
|
+
float petalScaleFactor;
|
|
51
|
+
float connectionRadiusPx;
|
|
52
|
+
float droopStartRadiusPx;
|
|
53
|
+
float peakHeightOffset;
|
|
54
|
+
// Droop amount per pixel distance beyond droopStartRadiusPx, scaled by petalScaleFactor
|
|
55
|
+
float petalDroopFactor;
|
|
56
|
+
// Stacking & Connection
|
|
57
|
+
float layerVerticalSpacing;
|
|
58
|
+
float connectionVerticalOffset;
|
|
59
|
+
// Increase -> less detail, fewer verts. Try 0.5 to 3.0
|
|
60
|
+
float contourSimplificationTolerance;
|
|
61
|
+
// Alpha value below which pixels are considered transparent
|
|
62
|
+
int alphaThreshold;
|
|
63
|
+
};
|
|
64
|
+
} // namespace fe
|
|
65
|
+
|
|
66
|
+
#endif // FLOWER_EVOLVER_3D_FLOWER_PARAMETERS_HPP
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#ifndef FLOWER_EVOLVER_3D_GLTF_JSON_WRITER_HPP
|
|
2
|
+
#define FLOWER_EVOLVER_3D_GLTF_JSON_WRITER_HPP
|
|
3
|
+
|
|
4
|
+
#include <fe/3D/GLTF/Scene.hpp>
|
|
5
|
+
#include <fe/3D/FlowerParameters.hpp>
|
|
6
|
+
#include <string>
|
|
7
|
+
#include <sstream>
|
|
8
|
+
#include <JsonBox.h>
|
|
9
|
+
|
|
10
|
+
namespace fe::gltf{
|
|
11
|
+
JsonBox::Array toJsonArray(const fe::Vec3f& vec);
|
|
12
|
+
JsonBox::Array toJsonArray(const fe::Vec4f& vec);
|
|
13
|
+
/**
|
|
14
|
+
* @brief converts a fe::gltf::Scene to a glTF 2.0 JSON from the provided scene.
|
|
15
|
+
* @details Serializes the scene's mesh parts, materials, and textures into
|
|
16
|
+
* a glTF asset with embedded Base64 binary data for geometry and images.
|
|
17
|
+
*
|
|
18
|
+
* @param scene const fe::gltf::Scene& The populated fe::gltf::Scene object.
|
|
19
|
+
* @param params const fe::FlowerParameters& The FlowerParameters used for generation (can be used for glTF extras).
|
|
20
|
+
* @return A JsonBox::Value containing the glTF JSON.
|
|
21
|
+
*/
|
|
22
|
+
JsonBox::Value toJson(const fe::gltf::Scene& scene, const fe::FlowerParameters& params);
|
|
23
|
+
/**
|
|
24
|
+
* @brief converts a JsonBox::Value to a std::string.
|
|
25
|
+
* @param json const JsonBox::Value&
|
|
26
|
+
* @return A std::string containing the glTF stringified json.
|
|
27
|
+
*/
|
|
28
|
+
std::string toJsonStr(const JsonBox::Value& json);
|
|
29
|
+
} // namespace fe::gltf
|
|
30
|
+
|
|
31
|
+
#endif // FLOWER_EVOLVER_3D_GLTF_JSON_WRITER_HPP
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#ifndef FLOWER_EVOLVER_3D_GLTF_MATERIAL_HPP
|
|
2
|
+
#define FLOWER_EVOLVER_3D_GLTF_MATERIAL_HPP
|
|
3
|
+
|
|
4
|
+
#include <optional>
|
|
5
|
+
#include <string>
|
|
6
|
+
|
|
7
|
+
#include <fe/3D/Vec.hpp>
|
|
8
|
+
|
|
9
|
+
namespace fe::gltf{
|
|
10
|
+
/**
|
|
11
|
+
* @brief KHR_MaterialsTransmission extension properties.
|
|
12
|
+
*/
|
|
13
|
+
struct KHR_MaterialsTransmission final{
|
|
14
|
+
float transmissionFactor = 0.0f;
|
|
15
|
+
std::optional<int> transmissionTextureIndex;
|
|
16
|
+
// If not using TEXCOORD_0
|
|
17
|
+
// std::optional<int> transmissionTextureTexCoord;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* @brief KHR_MaterialsVolume extension properties.
|
|
21
|
+
*/
|
|
22
|
+
struct KHR_MaterialsVolume final{
|
|
23
|
+
float thicknessFactor = 0.0f;
|
|
24
|
+
std::optional<int> thicknessTextureIndex;
|
|
25
|
+
// std::optional<int> thicknessTextureTexCoord;
|
|
26
|
+
float attenuationDistance = 0.0f;
|
|
27
|
+
fe::Vec3f attenuationColor = {1.0f, 1.0f, 1.0f};
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* @brief KHR_MaterialsIOR extension properties.
|
|
31
|
+
*/
|
|
32
|
+
struct KHR_MaterialsIOR final{
|
|
33
|
+
float ior = 1.0f;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* @brief KHR_MaterialsEmissiveStrength extension properties
|
|
37
|
+
*/
|
|
38
|
+
struct KHR_MaterialsEmissiveStrength final {
|
|
39
|
+
float emissiveStrength = 1.0f;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* @brief KHR_MaterialsClearcoat extension properties.
|
|
43
|
+
*/
|
|
44
|
+
struct KHR_MaterialsClearcoat final{
|
|
45
|
+
float clearcoatFactor = 0.0f;
|
|
46
|
+
std::optional<int> clearcoatTextureIndex;
|
|
47
|
+
// std::optional<int> clearcoatTextureTexCoord;
|
|
48
|
+
float clearcoatRoughnessFactor = 0.0f;
|
|
49
|
+
std::optional<int> clearcoatRoughnessTextureIndex;
|
|
50
|
+
// std::optional<int> clearcoatRoughnessTextureTexCoord;
|
|
51
|
+
std::optional<int> clearcoatNormalTextureIndex;
|
|
52
|
+
// std::optional<int> clearcoatNormalTextureTexCoord;
|
|
53
|
+
// std::optional<float> clearcoatNormalTextureScale;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* @brief Defines material properties for rendering.
|
|
57
|
+
*/
|
|
58
|
+
struct Material final{
|
|
59
|
+
/**
|
|
60
|
+
* @brief Default constructor.
|
|
61
|
+
*/
|
|
62
|
+
Material() = default;
|
|
63
|
+
/**
|
|
64
|
+
* @brief Creates a default stem material.
|
|
65
|
+
* @return A Material configured for a stem.
|
|
66
|
+
*/
|
|
67
|
+
static Material createStemMaterial();
|
|
68
|
+
/**
|
|
69
|
+
* @brief creates a default Pistil style Material
|
|
70
|
+
* @return A Material configured for a Pistil style.
|
|
71
|
+
*/
|
|
72
|
+
static Material createPistilStyleMaterial();
|
|
73
|
+
/**
|
|
74
|
+
* @brief creates a default Pistil stigma material
|
|
75
|
+
* @param normal_tex_idx The index of the normal texture for the Stigma.
|
|
76
|
+
* @return A Material configured for Pistil Stigma.
|
|
77
|
+
*/
|
|
78
|
+
static Material createPistilStigmaMaterial(int normal_tex_idx);
|
|
79
|
+
/**
|
|
80
|
+
* @brief creates a default Stamen filament material
|
|
81
|
+
* @return A Material configured for Stamen Filament.
|
|
82
|
+
*/
|
|
83
|
+
static Material createStamenFilamentMaterial();
|
|
84
|
+
/**
|
|
85
|
+
* @brief creates a default Stamen anther material
|
|
86
|
+
* @param normal_tex_idx The index of the normal texture for the Anther.
|
|
87
|
+
* @return A Material configured for Stamen Anther.
|
|
88
|
+
*/
|
|
89
|
+
static Material createStamenAntherMaterial(int normal_tex_idx);
|
|
90
|
+
/**
|
|
91
|
+
* @brief Creates a default petal material.
|
|
92
|
+
* @param petal_name const std::string& The name for the petal material.
|
|
93
|
+
* @param texture_idx int The index of the base color texture for this petal.
|
|
94
|
+
* @param normal_idx int the index of the normal texture for this petal.
|
|
95
|
+
* @param emissive_idx int the index of the emissive texture for this petal.
|
|
96
|
+
* @return A Material configured for a petal.
|
|
97
|
+
*/
|
|
98
|
+
static Material createPetalMaterial(const std::string& petal_name, int texture_idx, int normal_idx, int emissive_idx);
|
|
99
|
+
// data
|
|
100
|
+
std::string name;
|
|
101
|
+
fe::Vec4f baseColorFactor = {1.0f, 1.0f, 1.0f, 1.0f};
|
|
102
|
+
std::optional<int> baseColorTextureIndex;
|
|
103
|
+
float metallicFactor = 0.0f;
|
|
104
|
+
float roughnessFactor = 0.5f;
|
|
105
|
+
std::optional<int> metallicRoughnessTextureIndex;
|
|
106
|
+
std::optional<int> normalTextureIndex;
|
|
107
|
+
std::optional<float> normalTextureScale = 1.0f;
|
|
108
|
+
std::optional<int> occlusionTextureIndex;
|
|
109
|
+
std::optional<float> occlusionTextureStrength = 1.0f;
|
|
110
|
+
std::optional<int> emissiveTextureIndex;
|
|
111
|
+
fe::Vec3f emissiveFactor = {0.0f, 0.0f, 0.0f};
|
|
112
|
+
bool doubleSided = false;
|
|
113
|
+
std::string alphaMode = "OPAQUE"; // "OPAQUE", "MASK", "BLEND"
|
|
114
|
+
float alphaCutoff = 0.5f;
|
|
115
|
+
// KHR Extensions
|
|
116
|
+
std::optional<KHR_MaterialsTransmission> khrMaterialsTransmission;
|
|
117
|
+
std::optional<KHR_MaterialsClearcoat> khrMaterialsClearcoat;
|
|
118
|
+
std::optional<KHR_MaterialsVolume> khrMaterialsVolume;
|
|
119
|
+
std::optional<KHR_MaterialsIOR> khrMaterialsIOR;
|
|
120
|
+
std::optional<KHR_MaterialsEmissiveStrength> khrMaterialsEmissiveStrength;
|
|
121
|
+
};
|
|
122
|
+
} // namespace fe::gltf
|
|
123
|
+
|
|
124
|
+
#endif // FLOWER_EVOLVER_3D_GLTF_MATERIAL_HPP
|