animageo 0.1.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.
- animageo-0.1.0/LICENSE.txt +1 -0
- animageo-0.1.0/PKG-INFO +213 -0
- animageo-0.1.0/README.md +183 -0
- animageo-0.1.0/animageo/__init__.py +1 -0
- animageo-0.1.0/animageo/__main__.py +69 -0
- animageo-0.1.0/animageo/animageo.py +1331 -0
- animageo-0.1.0/animageo/geo/__init__.py +0 -0
- animageo-0.1.0/animageo/geo/construction.py +345 -0
- animageo-0.1.0/animageo/geo/lib_commands.py +966 -0
- animageo-0.1.0/animageo/geo/lib_elements.py +447 -0
- animageo-0.1.0/animageo/geo/lib_vars.py +72 -0
- animageo-0.1.0/animageo/parsers/__init__.py +0 -0
- animageo-0.1.0/animageo/parsers/ggb_generator.py +445 -0
- animageo-0.1.0/animageo/parsers/ggb_parser.py +516 -0
- animageo-0.1.0/animageo/parsers/short_parser.py +100 -0
- animageo-0.1.0/animageo/parsers/svg_parser.py +116 -0
- animageo-0.1.0/animageo.egg-info/PKG-INFO +213 -0
- animageo-0.1.0/animageo.egg-info/SOURCES.txt +23 -0
- animageo-0.1.0/animageo.egg-info/dependency_links.txt +1 -0
- animageo-0.1.0/animageo.egg-info/entry_points.txt +2 -0
- animageo-0.1.0/animageo.egg-info/requires.txt +4 -0
- animageo-0.1.0/animageo.egg-info/top_level.txt +1 -0
- animageo-0.1.0/setup.cfg +4 -0
- animageo-0.1.0/setup.py +33 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
copyright (c) 2024
|
animageo-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: animageo
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Tools for using GeoGebra construction, processing with Manim animation and exporting to SVG and MP4
|
|
5
|
+
Home-page: http://animageo.ru/
|
|
6
|
+
Author: ivaleo
|
|
7
|
+
Author-email: ivaleotion@gmail.com
|
|
8
|
+
Keywords: geometry dynamic geogebra manim animation drawing svg mp4 python
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.9
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE.txt
|
|
15
|
+
Requires-Dist: requests>=2.25.1
|
|
16
|
+
Requires-Dist: numpy>=1.26.0
|
|
17
|
+
Requires-Dist: manim>=0.19.0
|
|
18
|
+
Requires-Dist: pycairo>=1.0.0
|
|
19
|
+
Dynamic: author
|
|
20
|
+
Dynamic: author-email
|
|
21
|
+
Dynamic: classifier
|
|
22
|
+
Dynamic: description
|
|
23
|
+
Dynamic: description-content-type
|
|
24
|
+
Dynamic: home-page
|
|
25
|
+
Dynamic: keywords
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
Dynamic: requires-dist
|
|
28
|
+
Dynamic: requires-python
|
|
29
|
+
Dynamic: summary
|
|
30
|
+
|
|
31
|
+
# GeoDynamic
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install --upgrade geodynamic
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Using in terminal
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
geodynamic test.ggb -s pandora.json -px 240 auto
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
*Description:*
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
usage: geodynamic ggbfile [-o OUTPUT] [-px PX PX] [-s STYLE] [-d DEBUG]
|
|
49
|
+
|
|
50
|
+
positional arguments:
|
|
51
|
+
ggbfile GeoGebra file to parse
|
|
52
|
+
|
|
53
|
+
options:
|
|
54
|
+
-o OUTPUT, --output OUTPUT SVG file to export into
|
|
55
|
+
-px PX PX image width and height in px (values: num or auto)
|
|
56
|
+
-s STYLE, --style STYLE JSON file with style definitions
|
|
57
|
+
-d DEBUG, --debug DEBUG print options
|
|
58
|
+
|
|
59
|
+
-h, --help show this help message and exit
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Using in code
|
|
63
|
+
|
|
64
|
+
1. Preparing code `test.py`:
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from geodynamic.manim_dynamic import *
|
|
68
|
+
|
|
69
|
+
class TestScene(GeoDynamic):
|
|
70
|
+
def construct(self):
|
|
71
|
+
self.loadGeoGebra('test.ggb', style_json_file = 'pandora.json', px_size = [400, 'auto'])
|
|
72
|
+
self.exportSVG('test.svg')
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
2. Run compilation:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
manim 'test.py' TestScene
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
## Style definitions in JSON
|
|
83
|
+
|
|
84
|
+
Here is an example of JSON-file for styling images:
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"name": "pandora",
|
|
89
|
+
"version": 0.1,
|
|
90
|
+
"style": {
|
|
91
|
+
"dot": {
|
|
92
|
+
"main": 7,
|
|
93
|
+
"bold": 9,
|
|
94
|
+
"aux": 5
|
|
95
|
+
},
|
|
96
|
+
"line": {
|
|
97
|
+
"main": 2,
|
|
98
|
+
"bold": 2.5,
|
|
99
|
+
"aux": 1.5
|
|
100
|
+
},
|
|
101
|
+
"angle": {
|
|
102
|
+
"line": 1,
|
|
103
|
+
"r_default": 20,
|
|
104
|
+
"r_shift": 3,
|
|
105
|
+
"r_right": 14
|
|
106
|
+
},
|
|
107
|
+
"strich": {
|
|
108
|
+
"width": 1,
|
|
109
|
+
"len": 12,
|
|
110
|
+
"shift": 4
|
|
111
|
+
},
|
|
112
|
+
"arrow": {
|
|
113
|
+
"width": 7.5,
|
|
114
|
+
"length": 10.5
|
|
115
|
+
},
|
|
116
|
+
"color": {
|
|
117
|
+
"black": "#000000",
|
|
118
|
+
"main": "#2581b5",
|
|
119
|
+
"light": "#bef3fc",
|
|
120
|
+
"aux": "#000000",
|
|
121
|
+
"acc": "#ef60ab",
|
|
122
|
+
"acc_light": "#ffd2ee"
|
|
123
|
+
},
|
|
124
|
+
"font": {
|
|
125
|
+
"size": 17
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"technic": {
|
|
129
|
+
"line_caps": "round",
|
|
130
|
+
"right_angle_joint": "miter",
|
|
131
|
+
"polygon_boundary_layer": "top",
|
|
132
|
+
"points_display": "only_labels",
|
|
133
|
+
"crop_padding": 4,
|
|
134
|
+
"scale_export": 0.75
|
|
135
|
+
},
|
|
136
|
+
"ggb_export": {
|
|
137
|
+
"colors": {
|
|
138
|
+
"#1565c0": "main",
|
|
139
|
+
"#1565c0 0.1": "main 0",
|
|
140
|
+
"#d32f2f": "acc",
|
|
141
|
+
"#d32f2f 0.1": "acc_light 1",
|
|
142
|
+
"#616161": "aux",
|
|
143
|
+
"#000000 0.6": "main",
|
|
144
|
+
"#000000 0.1": "light 1",
|
|
145
|
+
"#1565c0 0": "white 1",
|
|
146
|
+
"#d32f2f 0": "white 1"
|
|
147
|
+
},
|
|
148
|
+
"dot": {
|
|
149
|
+
"5": "main"
|
|
150
|
+
},
|
|
151
|
+
"line": {
|
|
152
|
+
"5": "main",
|
|
153
|
+
"3": "aux"
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
*Description:*
|
|
162
|
+
|
|
163
|
+
**technic:**
|
|
164
|
+
|
|
165
|
+
*round* - закруглять концы всех отрезков
|
|
166
|
+
*butt* - обрезать концы всех отрезков
|
|
167
|
+
*square* - концы отрезков завершаются квадратами
|
|
168
|
+
```json
|
|
169
|
+
"line_caps": "round" | "butt" | "square",
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
*round* - скруглять соединение уголка в отображении отметки прямого угла
|
|
173
|
+
```json
|
|
174
|
+
"right_angle_joint": "round" | "bevel" | "miter"
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
*top* - отображать границу многоугольников поверх остальных линий (Важно! это касается именно дополнительных отрезков-сторон, создаваемых автоматически в GeoGebra)
|
|
178
|
+
```json
|
|
179
|
+
"polygon_boundary_layer": "top" | "auto"
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
*only_labels* - скрывать все точки (оставляя их надписи, если они есть)
|
|
183
|
+
*only_points* - скрывать надписи (оставляя точки, если они видимые)
|
|
184
|
+
```json
|
|
185
|
+
"points_display": "only_labels" | "only_points" | "auto"
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
обрезать картинку по содержимому, оставляя поле 4px
|
|
189
|
+
```json
|
|
190
|
+
"crop_padding": 4
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
вспомогательный коэффициент растяжения/сжатия всех параметров при экспорте в svg (должен влиять и на размеры и на толщины, стили…)
|
|
194
|
+
```json
|
|
195
|
+
"scale_export": 0.75, 1
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**ggb_export:**
|
|
199
|
+
|
|
200
|
+
конвертирует конкретные цвета из GeoGebra в другие цвета c возможным параметром прозрачности (цвет либо конкретный, либо по имени из стилевика)
|
|
201
|
+
```json
|
|
202
|
+
"colors": {}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
конвертирует определенную ширину линии из GeoGebra в другую заданную ширину (величина либо конкретная, либо по имени из стилевика)
|
|
206
|
+
```json
|
|
207
|
+
"line": {}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
конвертирует определенный размер точек из GeoGebra в другой заданный размер (величина либо конкретная, либо по имени из стилевика)
|
|
211
|
+
```json
|
|
212
|
+
"dot": {}
|
|
213
|
+
```
|
animageo-0.1.0/README.md
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# GeoDynamic
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pip install --upgrade geodynamic
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Using in terminal
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
geodynamic test.ggb -s pandora.json -px 240 auto
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
*Description:*
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
usage: geodynamic ggbfile [-o OUTPUT] [-px PX PX] [-s STYLE] [-d DEBUG]
|
|
19
|
+
|
|
20
|
+
positional arguments:
|
|
21
|
+
ggbfile GeoGebra file to parse
|
|
22
|
+
|
|
23
|
+
options:
|
|
24
|
+
-o OUTPUT, --output OUTPUT SVG file to export into
|
|
25
|
+
-px PX PX image width and height in px (values: num or auto)
|
|
26
|
+
-s STYLE, --style STYLE JSON file with style definitions
|
|
27
|
+
-d DEBUG, --debug DEBUG print options
|
|
28
|
+
|
|
29
|
+
-h, --help show this help message and exit
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Using in code
|
|
33
|
+
|
|
34
|
+
1. Preparing code `test.py`:
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from geodynamic.manim_dynamic import *
|
|
38
|
+
|
|
39
|
+
class TestScene(GeoDynamic):
|
|
40
|
+
def construct(self):
|
|
41
|
+
self.loadGeoGebra('test.ggb', style_json_file = 'pandora.json', px_size = [400, 'auto'])
|
|
42
|
+
self.exportSVG('test.svg')
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
2. Run compilation:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
manim 'test.py' TestScene
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## Style definitions in JSON
|
|
53
|
+
|
|
54
|
+
Here is an example of JSON-file for styling images:
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"name": "pandora",
|
|
59
|
+
"version": 0.1,
|
|
60
|
+
"style": {
|
|
61
|
+
"dot": {
|
|
62
|
+
"main": 7,
|
|
63
|
+
"bold": 9,
|
|
64
|
+
"aux": 5
|
|
65
|
+
},
|
|
66
|
+
"line": {
|
|
67
|
+
"main": 2,
|
|
68
|
+
"bold": 2.5,
|
|
69
|
+
"aux": 1.5
|
|
70
|
+
},
|
|
71
|
+
"angle": {
|
|
72
|
+
"line": 1,
|
|
73
|
+
"r_default": 20,
|
|
74
|
+
"r_shift": 3,
|
|
75
|
+
"r_right": 14
|
|
76
|
+
},
|
|
77
|
+
"strich": {
|
|
78
|
+
"width": 1,
|
|
79
|
+
"len": 12,
|
|
80
|
+
"shift": 4
|
|
81
|
+
},
|
|
82
|
+
"arrow": {
|
|
83
|
+
"width": 7.5,
|
|
84
|
+
"length": 10.5
|
|
85
|
+
},
|
|
86
|
+
"color": {
|
|
87
|
+
"black": "#000000",
|
|
88
|
+
"main": "#2581b5",
|
|
89
|
+
"light": "#bef3fc",
|
|
90
|
+
"aux": "#000000",
|
|
91
|
+
"acc": "#ef60ab",
|
|
92
|
+
"acc_light": "#ffd2ee"
|
|
93
|
+
},
|
|
94
|
+
"font": {
|
|
95
|
+
"size": 17
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"technic": {
|
|
99
|
+
"line_caps": "round",
|
|
100
|
+
"right_angle_joint": "miter",
|
|
101
|
+
"polygon_boundary_layer": "top",
|
|
102
|
+
"points_display": "only_labels",
|
|
103
|
+
"crop_padding": 4,
|
|
104
|
+
"scale_export": 0.75
|
|
105
|
+
},
|
|
106
|
+
"ggb_export": {
|
|
107
|
+
"colors": {
|
|
108
|
+
"#1565c0": "main",
|
|
109
|
+
"#1565c0 0.1": "main 0",
|
|
110
|
+
"#d32f2f": "acc",
|
|
111
|
+
"#d32f2f 0.1": "acc_light 1",
|
|
112
|
+
"#616161": "aux",
|
|
113
|
+
"#000000 0.6": "main",
|
|
114
|
+
"#000000 0.1": "light 1",
|
|
115
|
+
"#1565c0 0": "white 1",
|
|
116
|
+
"#d32f2f 0": "white 1"
|
|
117
|
+
},
|
|
118
|
+
"dot": {
|
|
119
|
+
"5": "main"
|
|
120
|
+
},
|
|
121
|
+
"line": {
|
|
122
|
+
"5": "main",
|
|
123
|
+
"3": "aux"
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
*Description:*
|
|
132
|
+
|
|
133
|
+
**technic:**
|
|
134
|
+
|
|
135
|
+
*round* - закруглять концы всех отрезков
|
|
136
|
+
*butt* - обрезать концы всех отрезков
|
|
137
|
+
*square* - концы отрезков завершаются квадратами
|
|
138
|
+
```json
|
|
139
|
+
"line_caps": "round" | "butt" | "square",
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
*round* - скруглять соединение уголка в отображении отметки прямого угла
|
|
143
|
+
```json
|
|
144
|
+
"right_angle_joint": "round" | "bevel" | "miter"
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
*top* - отображать границу многоугольников поверх остальных линий (Важно! это касается именно дополнительных отрезков-сторон, создаваемых автоматически в GeoGebra)
|
|
148
|
+
```json
|
|
149
|
+
"polygon_boundary_layer": "top" | "auto"
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
*only_labels* - скрывать все точки (оставляя их надписи, если они есть)
|
|
153
|
+
*only_points* - скрывать надписи (оставляя точки, если они видимые)
|
|
154
|
+
```json
|
|
155
|
+
"points_display": "only_labels" | "only_points" | "auto"
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
обрезать картинку по содержимому, оставляя поле 4px
|
|
159
|
+
```json
|
|
160
|
+
"crop_padding": 4
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
вспомогательный коэффициент растяжения/сжатия всех параметров при экспорте в svg (должен влиять и на размеры и на толщины, стили…)
|
|
164
|
+
```json
|
|
165
|
+
"scale_export": 0.75, 1
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**ggb_export:**
|
|
169
|
+
|
|
170
|
+
конвертирует конкретные цвета из GeoGebra в другие цвета c возможным параметром прозрачности (цвет либо конкретный, либо по имени из стилевика)
|
|
171
|
+
```json
|
|
172
|
+
"colors": {}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
конвертирует определенную ширину линии из GeoGebra в другую заданную ширину (величина либо конкретная, либо по имени из стилевика)
|
|
176
|
+
```json
|
|
177
|
+
"line": {}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
конвертирует определенный размер точек из GeoGebra в другой заданный размер (величина либо конкретная, либо по имени из стилевика)
|
|
181
|
+
```json
|
|
182
|
+
"dot": {}
|
|
183
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .animageo import *
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import argparse
|
|
3
|
+
|
|
4
|
+
def main():
|
|
5
|
+
parser = argparse.ArgumentParser(prog='animageo', description='Converting GeoGebra construction file into SVG image.')
|
|
6
|
+
parser.add_argument('ggbfile',
|
|
7
|
+
help='GeoGebra file to convert')
|
|
8
|
+
parser.add_argument('-o', '--output', type=str,
|
|
9
|
+
help="SVG file to export into")
|
|
10
|
+
parser.add_argument('-px', nargs=2,
|
|
11
|
+
help="image width and height in px (values: num or auto)")
|
|
12
|
+
parser.add_argument('-s', '--style', type=str, default='pandora.json',
|
|
13
|
+
help="JSON file with style definitions")
|
|
14
|
+
parser.add_argument('-d', '--debug', action='store_true',
|
|
15
|
+
help="print options")
|
|
16
|
+
|
|
17
|
+
args = parser.parse_args()
|
|
18
|
+
|
|
19
|
+
def create_tempfile_for_manim():
|
|
20
|
+
f = open('temp.py', 'w')
|
|
21
|
+
f.write('''\
|
|
22
|
+
|
|
23
|
+
#this file has been autogenerated by AnimaGeo
|
|
24
|
+
|
|
25
|
+
from animageo import *
|
|
26
|
+
|
|
27
|
+
class Scene(AnimaGeoScene):
|
|
28
|
+
def construct(self):
|
|
29
|
+
self.loadGeoGebra(''' + "'" + args.ggbfile + "'" + ''', style_json_file = ''' + "'" + args.style + "'" + ''', px_size = ''' + str(args.px) + ''', debug = ''' + "'" + str(args.debug) + "'" + ''')
|
|
30
|
+
#print(self.geo)
|
|
31
|
+
self.exportSVG(''' + "'" + args.output + "')"
|
|
32
|
+
|
|
33
|
+
)
|
|
34
|
+
f.close()
|
|
35
|
+
|
|
36
|
+
if 'ggbfile' in args:
|
|
37
|
+
if not os.path.exists(args.ggbfile):
|
|
38
|
+
print('not finded ggb file: ' + args.ggbfile)
|
|
39
|
+
exit(-1)
|
|
40
|
+
|
|
41
|
+
if args.style is None:
|
|
42
|
+
args.__setattr__('style', 'default.json')
|
|
43
|
+
|
|
44
|
+
if not os.path.exists(args.style):
|
|
45
|
+
print('not finded style file: ' + args.style)
|
|
46
|
+
exit(-1)
|
|
47
|
+
|
|
48
|
+
if args.output is None:
|
|
49
|
+
args.__setattr__('output', args.ggbfile.replace('.ggb', '.svg'))
|
|
50
|
+
|
|
51
|
+
if args.px is None:
|
|
52
|
+
args.__setattr__('px', [640, 480])
|
|
53
|
+
|
|
54
|
+
create_tempfile_for_manim()
|
|
55
|
+
|
|
56
|
+
if args.debug:
|
|
57
|
+
print('FROM: ', args.ggbfile)
|
|
58
|
+
print('TO: ', args.output)
|
|
59
|
+
print('SIZE: ', args.px)
|
|
60
|
+
print('STYLE: ', args.style)
|
|
61
|
+
|
|
62
|
+
print('Running manim... [be patient, first run may take a longer time]')
|
|
63
|
+
os.system('manim temp.py Pandora')
|
|
64
|
+
|
|
65
|
+
print('-----------------')
|
|
66
|
+
print("SVG file exported: '" + args.ggbfile.replace('.ggb', '.svg') + "'\n\n")
|
|
67
|
+
|
|
68
|
+
if __name__ == '__main__':
|
|
69
|
+
main()
|