Metadata-Version: 2.2
Name: laser_turtle
Version: 1.0.0
Summary: A SVG Turtle package for Laser cutting machine
Author-email: Christophe Declercq <christophe.declercq@univ-reunion.fr>
License: Copyright (c) 2018 The Python Packaging Authority
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://gitlab.com/iremi974/laser-turtle
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE

# laser-turtle

Module inspiré de Turtle générant un dessin vectoriel natif en SVG pour gravure et découpe Laser.

La fonction `circle` de Turtle, qui approxime un cercle par un polygone régulier, a été remplacée par la fonction `turn` qui génère un chemin de type arc en SVG. Les fonctions `forward` et `backward` génèrent des chemins de type ligne en SVG.

Des fonctions ont été ajoutés pour contrôler le mode gravure ou découpe.

Le fichier SVG généré peut être directement utilisé pour commander une machine à découpe et gravure laser.
Le fichier comporte deux frames : une en trait noir pour la gravure, une en trait rouge pour la découpe.

## Installation et ouverture

Télécharger le fichier : `laser_turtle.py` 

```python
from laser_turtle import laser_turtle
```

## Méthodes disponibles

- Création d'une instance : `laser_turtle(width, height)`
- `moveto(self, x, y)`: Déplace le curseur à une position absolue (x,y), sans dessiner
- `heading(self, angle)` : Oriente le curseur à un angle absolu (0 pour Nord) dans le sens horaire.
- `rotate(self, angle)` : Pivote le curseur d'un angle relatif (positif dans le sens horaire)
- `forward(self, d)` : Avance le curseur d'une distance d, en générant un chemin de type ligne
- `backward(self,d)` : Recule le curseur d'une distance d, en générant un chemin de type ligne
- `turn(self, r, a)` : Fait parcourir au curseur un arc de cercle de rayon r et d'angle a
- `draw_on(self)` : Positionne le curseur en position de dessin
- `draw_off(self)` : Remonte le curseur
- `cut_on(self)` : Positionne le curseur en position de découpe
- `cut_off(self)` : Remonte le curseur
- `to_svg(self)` : Renvoie le dessin vectoriel en svg
- `export_svg(self, nom)` : Enregistre le dessin vectoriel en svg dans le fichier nom.svg

## Exemples d'utilisation

### Avec Python

Le programme suivant : 

```python
from laser_turtle import laser_turtle
t = laser_turtle(100,100)
t.moveto(30, 20)
for i in range(4):
    t.forward(40)
    t.turn(10,90)
t.export_svg("test")
```
génère une image vectorielle dans le fichier `test.svg`

### Avec Ipython ou notebook

Les objets de type `laser_turtle` peuvent directement être affichés dans un notebook : 

![Utilisation dans un notebook](notebook.png)

## Licence et crédits

Diffusé sous licence MIT.

Auteur : Christophe Declercq, Université de La Réunion : christophe.declercq@univ-reunion.fr
