animageo


Nameanimageo JSON
Version 0.1.6 PyPI version JSON
download
home_pagehttp://animageo.ru/
SummaryTools for using GeoGebra construction, processing with Manim animation and exporting to SVG and MP4
upload_time2025-10-20 13:28:15
maintainerNone
docs_urlNone
authorivaleo
requires_python>=3.9
licenseNone
keywords geometry dynamic geogebra manim animation drawing svg mp4 python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # AnimaGeo

## Installation

```bash
pip install --upgrade animageo
```

## Using in terminal

```bash
animageo test.ggb -s default.json -px 240 auto
```

*Description:*

```
usage: animageo ggbfile [-o OUTPUT] [-px PX PX] [-s STYLE] [-d DEBUG]

positional arguments:
  ggbfile                       GeoGebra file to parse

options:
  -o OUTPUT, --output OUTPUT    SVG file to export into
  -px PX PX                     image width and height in px (values: num or auto)
  -s STYLE, --style STYLE       JSON file with style definitions    
  -d DEBUG, --debug DEBUG       print options

  -h, --help                    show this help message and exit
```

## Using in code

1. Prepare code `scene.py`:

```python
from animageo import *

class TestScene(AnimaGeoScene):
    def construct(self):
        # ............................................................
        # Load geometric construction directly from GeoGebra-file     
        self.loadGGB('scene.ggb', style_file = 'default.json', px_size = [400, 'auto'])
        
        # ............................................................
        # Load your own simplified python-style Code-file for manipulations with geometric construction
        # - add new vars and elements
        # - change previous definitions
        self.loadCode('scene_code.py')

        # ............................................................
        # Stylize elements using their names from GeoGebra-file or from your Code-file
        # - use any predefined attributes from style_file or from Manim
        self.element('a').style['stroke'] = self.style.col 
        self.element('A_1').style['fill'] = self.style.col_accent

        # ............................................................
        # Export current scene to image with px_size width/height
        self.exportSVG('scene.svg')

        # ............................................................
        # Do whatever you do with Manim, but also specific things:

        # - add special ValueTracker and link it to Var in geometric construction
        x = self.addVar('x', 5)

        # - use predefined methods to Show, Hide and Update geometric elements without animation
        self.HideAll()
        self.Show(['A', 'B'])

        # - use predefined methods to Show, Hide and Update geometric elements with animation
        self.playShow(['a'])
        self.element('b').style['stroke_opacity'] = 0.5
        self.playUpdate(['b'])

        # - use tracker values for animation
        self.addUpdater(x)
        self.play(x.animate.set_value(10))
        self.clearUpdater(x)

        # - you may also want to change geometric elements as Manim objects (but without affecting geometric construction)
        a = self.mobject('a')
        b = self.mobject('b')
        self.play(VGroup(a, b).animate.arrange(buff=1).shift(DOWN))
        self.play(FadeOut(a, b))        
```

and code `scene_code.py`:

```python
from animageo.code import *

A = Point(x, 0)
B = Intersect(b, c)
a = Segment(A, B)
```

2. Run compilation:

```bash
manim 'scene.py' TestScene
```


## Style definitions in JSON

Here is an example of JSON-file for styling images:

```json
{
   "name": "default",
   "version": 0.1,
   "style": {
       "dot": {
           "main": 7,
           "bold": 9,
           "aux": 5
       },
       "line": {
           "main": 2,
           "bold": 2.5,
           "aux": 1.5
       },
       "angle": {
           "line": 1,
           "r_default": 20,
           "r_shift": 3,
           "r_right": 14
       },
       "strich": {
           "width": 1,
           "len": 12,
           "shift": 4
       },
       "arrow": {
           "width": 7.5,
           "length": 10.5
       },
       "color": {
           "black": "#000000",
           "main": "#2581b5",
           "light": "#bef3fc",
           "aux": "#000000",
           "acc": "#ef60ab",
           "acc_light": "#ffd2ee"
       },
       "font": {
           "size": 17
       }
   },
   "technic": {
       "line_caps": "round",
       "right_angle_joint": "miter",
       "polygon_boundary_layer": "top",
       "points_display": "only_labels",
       "crop_padding": 4,
       "scale_export": 0.75
   },
   "ggb_export": {
       "colors": {
           "#1565c0": "main",
           "#1565c0 0.1": "main 0",
           "#d32f2f": "acc",
           "#d32f2f 0.1": "acc_light 1",
           "#616161": "aux",
           "#000000 0.6": "main",
           "#000000 0.1": "light 1",
           "#1565c0 0": "white 1",
           "#d32f2f 0": "white 1"
       },
       "dot": {
           "5": "main"
       },
       "line": {
           "5": "main",
           "3": "aux"
       }
   }
}

```


*Description:*

**technic:**

*round* - закруглять концы всех отрезков
*butt* - обрезать концы всех отрезков
*square* - концы отрезков завершаются квадратами
```json
        "line_caps": "round" | "butt" | "square",  
```

*round* - скруглять соединение уголка в отображении отметки прямого угла
```json
        "right_angle_joint": "round" | "bevel" | "miter" 
```

*top* - отображать границу многоугольников поверх остальных линий (Важно! это касается именно дополнительных отрезков-сторон, создаваемых автоматически в GeoGebra)
```json
        "polygon_boundary_layer": "top" | "auto"
```

*only_labels* - скрывать все точки (оставляя их надписи, если они есть)
*only_points* - скрывать надписи (оставляя точки, если они видимые)
```json
        "points_display": "only_labels" | "only_points" | "auto"
```

обрезать картинку по содержимому, оставляя поле 4px
```json
        "crop_padding": 4 
```

вспомогательный коэффициент растяжения/сжатия всех параметров при экспорте в svg (должен влиять и на размеры и на толщины, стили…)
```json
        "scale_export": 0.75,  1 
```

**ggb_export:**

конвертирует конкретные цвета из GeoGebra в другие цвета c возможным параметром прозрачности (цвет либо конкретный, либо по имени из стилевика)
```json
    "colors": {}
```

конвертирует определенную ширину линии из GeoGebra в другую заданную ширину (величина либо конкретная, либо по имени из стилевика)
```json
    "line": {}
```

конвертирует определенный размер точек из GeoGebra в другой заданный размер (величина либо конкретная, либо по имени из стилевика)
```json
    "dot": {}
```

            

Raw data

            {
    "_id": null,
    "home_page": "http://animageo.ru/",
    "name": "animageo",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "geometry dynamic geogebra manim animation drawing svg mp4 python",
    "author": "ivaleo",
    "author_email": "ivaleotion@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/42/97/e62620b6996169d747bf8c3967241c5d3733efd0df0f10763b8d2d80afd1/animageo-0.1.6.tar.gz",
    "platform": null,
    "description": "# AnimaGeo\n\n## Installation\n\n```bash\npip install --upgrade animageo\n```\n\n## Using in terminal\n\n```bash\nanimageo test.ggb -s default.json -px 240 auto\n```\n\n*Description:*\n\n```\nusage: animageo ggbfile [-o OUTPUT] [-px PX PX] [-s STYLE] [-d DEBUG]\n\npositional arguments:\n  ggbfile                       GeoGebra file to parse\n\noptions:\n  -o OUTPUT, --output OUTPUT    SVG file to export into\n  -px PX PX                     image width and height in px (values: num or auto)\n  -s STYLE, --style STYLE       JSON file with style definitions    \n  -d DEBUG, --debug DEBUG       print options\n\n  -h, --help                    show this help message and exit\n```\n\n## Using in code\n\n1. Prepare code `scene.py`:\n\n```python\nfrom animageo import *\n\nclass TestScene(AnimaGeoScene):\n    def construct(self):\n        # ............................................................\n        # Load geometric construction directly from GeoGebra-file     \n        self.loadGGB('scene.ggb', style_file = 'default.json', px_size = [400, 'auto'])\n        \n        # ............................................................\n        # Load your own simplified python-style Code-file for manipulations with geometric construction\n        # - add new vars and elements\n        # - change previous definitions\n        self.loadCode('scene_code.py')\n\n        # ............................................................\n        # Stylize elements using their names from GeoGebra-file or from your Code-file\n        # - use any predefined attributes from style_file or from Manim\n        self.element('a').style['stroke'] = self.style.col \n        self.element('A_1').style['fill'] = self.style.col_accent\n\n        # ............................................................\n        # Export current scene to image with px_size width/height\n        self.exportSVG('scene.svg')\n\n        # ............................................................\n        # Do whatever you do with Manim, but also specific things:\n\n        # - add special ValueTracker and link it to Var in geometric construction\n        x = self.addVar('x', 5)\n\n        # - use predefined methods to Show, Hide and Update geometric elements without animation\n        self.HideAll()\n        self.Show(['A', 'B'])\n\n        # - use predefined methods to Show, Hide and Update geometric elements with animation\n        self.playShow(['a'])\n        self.element('b').style['stroke_opacity'] = 0.5\n        self.playUpdate(['b'])\n\n        # - use tracker values for animation\n        self.addUpdater(x)\n        self.play(x.animate.set_value(10))\n        self.clearUpdater(x)\n\n        # - you may also want to change geometric elements as Manim objects (but without affecting geometric construction)\n        a = self.mobject('a')\n        b = self.mobject('b')\n        self.play(VGroup(a, b).animate.arrange(buff=1).shift(DOWN))\n        self.play(FadeOut(a, b))        \n```\n\nand code `scene_code.py`:\n\n```python\nfrom animageo.code import *\n\nA = Point(x, 0)\nB = Intersect(b, c)\na = Segment(A, B)\n```\n\n2. Run compilation:\n\n```bash\nmanim 'scene.py' TestScene\n```\n\n\n## Style definitions in JSON\n\nHere is an example of JSON-file for styling images:\n\n```json\n{\n   \"name\": \"default\",\n   \"version\": 0.1,\n   \"style\": {\n       \"dot\": {\n           \"main\": 7,\n           \"bold\": 9,\n           \"aux\": 5\n       },\n       \"line\": {\n           \"main\": 2,\n           \"bold\": 2.5,\n           \"aux\": 1.5\n       },\n       \"angle\": {\n           \"line\": 1,\n           \"r_default\": 20,\n           \"r_shift\": 3,\n           \"r_right\": 14\n       },\n       \"strich\": {\n           \"width\": 1,\n           \"len\": 12,\n           \"shift\": 4\n       },\n       \"arrow\": {\n           \"width\": 7.5,\n           \"length\": 10.5\n       },\n       \"color\": {\n           \"black\": \"#000000\",\n           \"main\": \"#2581b5\",\n           \"light\": \"#bef3fc\",\n           \"aux\": \"#000000\",\n           \"acc\": \"#ef60ab\",\n           \"acc_light\": \"#ffd2ee\"\n       },\n       \"font\": {\n           \"size\": 17\n       }\n   },\n   \"technic\": {\n       \"line_caps\": \"round\",\n       \"right_angle_joint\": \"miter\",\n       \"polygon_boundary_layer\": \"top\",\n       \"points_display\": \"only_labels\",\n       \"crop_padding\": 4,\n       \"scale_export\": 0.75\n   },\n   \"ggb_export\": {\n       \"colors\": {\n           \"#1565c0\": \"main\",\n           \"#1565c0 0.1\": \"main 0\",\n           \"#d32f2f\": \"acc\",\n           \"#d32f2f 0.1\": \"acc_light 1\",\n           \"#616161\": \"aux\",\n           \"#000000 0.6\": \"main\",\n           \"#000000 0.1\": \"light 1\",\n           \"#1565c0 0\": \"white 1\",\n           \"#d32f2f 0\": \"white 1\"\n       },\n       \"dot\": {\n           \"5\": \"main\"\n       },\n       \"line\": {\n           \"5\": \"main\",\n           \"3\": \"aux\"\n       }\n   }\n}\n\n```\n\n\n*Description:*\n\n**technic:**\n\n*round* - \u0437\u0430\u043a\u0440\u0443\u0433\u043b\u044f\u0442\u044c \u043a\u043e\u043d\u0446\u044b \u0432\u0441\u0435\u0445 \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u0432\n*butt* - \u043e\u0431\u0440\u0435\u0437\u0430\u0442\u044c \u043a\u043e\u043d\u0446\u044b \u0432\u0441\u0435\u0445 \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u0432\n*square* - \u043a\u043e\u043d\u0446\u044b \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u0432 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u044e\u0442\u0441\u044f \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0430\u043c\u0438\n```json\n        \"line_caps\": \"round\" | \"butt\" | \"square\",  \n```\n\n*round* - \u0441\u043a\u0440\u0443\u0433\u043b\u044f\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0443\u0433\u043e\u043b\u043a\u0430 \u0432 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043e\u0442\u043c\u0435\u0442\u043a\u0438 \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0443\u0433\u043b\u0430\n```json\n        \"right_angle_joint\": \"round\" | \"bevel\" | \"miter\" \n```\n\n*top* - \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0433\u0440\u0430\u043d\u0438\u0446\u0443 \u043c\u043d\u043e\u0433\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432 \u043f\u043e\u0432\u0435\u0440\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043b\u0438\u043d\u0438\u0439 (\u0412\u0430\u0436\u043d\u043e! \u044d\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u0432-\u0441\u0442\u043e\u0440\u043e\u043d, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432 GeoGebra)\n```json\n        \"polygon_boundary_layer\": \"top\" | \"auto\"\n```\n\n*only_labels* - \u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0442\u043e\u0447\u043a\u0438 (\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0438\u0445 \u043d\u0430\u0434\u043f\u0438\u0441\u0438, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0435\u0441\u0442\u044c)\n*only_points* - \u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0434\u043f\u0438\u0441\u0438 (\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0442\u043e\u0447\u043a\u0438, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0432\u0438\u0434\u0438\u043c\u044b\u0435)\n```json\n        \"points_display\": \"only_labels\" | \"only_points\" | \"auto\"\n```\n\n\u043e\u0431\u0440\u0435\u0437\u0430\u0442\u044c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u043f\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u043c\u0443, \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u043f\u043e\u043b\u0435 4px\n```json\n        \"crop_padding\": 4 \n```\n\n\u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0440\u0430\u0441\u0442\u044f\u0436\u0435\u043d\u0438\u044f/\u0441\u0436\u0430\u0442\u0438\u044f \u0432\u0441\u0435\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u0440\u0438 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0435 \u0432 svg (\u0434\u043e\u043b\u0436\u0435\u043d \u0432\u043b\u0438\u044f\u0442\u044c \u0438 \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0438 \u043d\u0430 \u0442\u043e\u043b\u0449\u0438\u043d\u044b, \u0441\u0442\u0438\u043b\u0438\u2026)\n```json\n        \"scale_export\": 0.75,  1 \n```\n\n**ggb_export:**\n\n\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u0446\u0432\u0435\u0442\u0430 \u0438\u0437 GeoGebra \u0432 \u0434\u0440\u0443\u0433\u0438\u0435 \u0446\u0432\u0435\u0442\u0430 c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438 (\u0446\u0432\u0435\u0442 \u043b\u0438\u0431\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439, \u043b\u0438\u0431\u043e \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u0438\u0437 \u0441\u0442\u0438\u043b\u0435\u0432\u0438\u043a\u0430)\n```json\n    \"colors\": {}\n```\n\n\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u0448\u0438\u0440\u0438\u043d\u0443 \u043b\u0438\u043d\u0438\u0438 \u0438\u0437 GeoGebra \u0432 \u0434\u0440\u0443\u0433\u0443\u044e \u0437\u0430\u0434\u0430\u043d\u043d\u0443\u044e \u0448\u0438\u0440\u0438\u043d\u0443 (\u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0430 \u043b\u0438\u0431\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0430\u044f, \u043b\u0438\u0431\u043e \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u0438\u0437 \u0441\u0442\u0438\u043b\u0435\u0432\u0438\u043a\u0430)\n```json\n    \"line\": {}\n```\n\n\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0442\u043e\u0447\u0435\u043a \u0438\u0437 GeoGebra \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 (\u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0430 \u043b\u0438\u0431\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0430\u044f, \u043b\u0438\u0431\u043e \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u0438\u0437 \u0441\u0442\u0438\u043b\u0435\u0432\u0438\u043a\u0430)\n```json\n    \"dot\": {}\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Tools for using GeoGebra construction, processing with Manim animation and exporting to SVG and MP4",
    "version": "0.1.6",
    "project_urls": {
        "Homepage": "http://animageo.ru/"
    },
    "split_keywords": [
        "geometry",
        "dynamic",
        "geogebra",
        "manim",
        "animation",
        "drawing",
        "svg",
        "mp4",
        "python"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b466284ecf169a1c84b0e23f9e6c69ad621e2a9656000bcb48272a7f72c48c08",
                "md5": "2552b1130ece3ca80e8ff852418171b0",
                "sha256": "69f09ffd69b4ff69c16dca729c6b23a93bd2a17a9972188e7bfd743531a658de"
            },
            "downloads": -1,
            "filename": "animageo-0.1.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2552b1130ece3ca80e8ff852418171b0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 83134,
            "upload_time": "2025-10-20T13:28:14",
            "upload_time_iso_8601": "2025-10-20T13:28:14.447175Z",
            "url": "https://files.pythonhosted.org/packages/b4/66/284ecf169a1c84b0e23f9e6c69ad621e2a9656000bcb48272a7f72c48c08/animageo-0.1.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4297e62620b6996169d747bf8c3967241c5d3733efd0df0f10763b8d2d80afd1",
                "md5": "0158306584290f36298301bdcf0cf510",
                "sha256": "f73890252a9ecd0514acf020bb2c5c69e681c77af3e32866aa7d38385074f7d5"
            },
            "downloads": -1,
            "filename": "animageo-0.1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "0158306584290f36298301bdcf0cf510",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 46205,
            "upload_time": "2025-10-20T13:28:15",
            "upload_time_iso_8601": "2025-10-20T13:28:15.509350Z",
            "url": "https://files.pythonhosted.org/packages/42/97/e62620b6996169d747bf8c3967241c5d3733efd0df0f10763b8d2d80afd1/animageo-0.1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-20 13:28:15",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "animageo"
}
        
Elapsed time: 2.13049s