Version initiale de l'extension Inkscape de remplissage tête de mort
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No files matched your search
@@ -0,0 +1,15 @@
|
||||
# Cache Python et outils
|
||||
__pycache__/
|
||||
*.pyc
|
||||
.pytest_cache/
|
||||
.venv/
|
||||
|
||||
# Archives de distribution
|
||||
*.zip
|
||||
|
||||
# SVG intermediaires du schema (regeneres par docs/schema_parametres.py)
|
||||
docs/*.svg
|
||||
|
||||
# Page de presentation : hors depot (publiee sur le NAS par site/deploy.ps1 ;
|
||||
# sa configuration contient hote, compte et chemin de cle SSH)
|
||||
site/
|
||||
@@ -0,0 +1,246 @@
|
||||
# Remplissage têtes de mort — extension Inkscape
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td width="50%" valign="top">
|
||||
<img src="docs/capture-desktop.png" alt="Cœur rempli de têtes de mort de tailles variées, inclinées et superposées, coupées au contour" width="420">
|
||||
</td>
|
||||
<td valign="top">
|
||||
|
||||
Extension Inkscape 1.x qui remplit une forme de têtes de mort, à la manière du
|
||||
motif [`doc/patern.png`](doc/patern.png) : un même crâne répété à des tailles,
|
||||
des angles et en miroir différents, empilé sans laisser de vide. Les petits
|
||||
crânes tapissent le fond, les grands passent par-dessus, et le tout est
|
||||
découpé au contour de la forme. Le crâne est le dessin vectoriel
|
||||
[`doc/dessin.svg`](doc/dessin.svg), sans ses cornes : vu de trois quarts,
|
||||
arêtes vives, mâchoire en équerre, sutures et ombre sur la tempe.
|
||||
|
||||
Le résultat est prévu pour la **gravure laser** : il ne contient que l'encre
|
||||
réellement visible. Les traits cachés par les crânes du dessus sont supprimés,
|
||||
les crânes du bord sont coupés, et aucun masque, clone ni objet blanc n'est
|
||||
écrit : le laser ne grave rien de caché.
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## Sommaire
|
||||
|
||||
- [Fonctionnalités](#fonctionnalités)
|
||||
- [Installation](#installation)
|
||||
- [Utilisation](#utilisation)
|
||||
- [Paramètres](#paramètres)
|
||||
- [Structure du projet](#structure-du-projet)
|
||||
- [Développement](#développement)
|
||||
|
||||
## Fonctionnalités
|
||||
|
||||
- Remplit chemins, rectangles, cercles, ellipses et polygones, y compris les
|
||||
formes trouées (règle pair-impair) ; un groupe sélectionné est rempli forme
|
||||
par forme. Textes et images sont ignorés.
|
||||
- Tailles tirées selon une loi de puissance entre la plus petite et la plus
|
||||
grande : beaucoup de petits crânes, quelques grands, dessinés du plus petit
|
||||
au plus grand pour que les grands passent devant.
|
||||
- Grille décalée et secouée au hasard, inclinaison aléatoire bornée, miroir
|
||||
aléatoire ; une graine change la disposition, et deux formes voisines
|
||||
remplies avec la même graine partagent les mêmes positions (grille calée sur
|
||||
l'origine du document).
|
||||
- Prêt pour la gravure laser : seule l'encre visible est écrite. Pour chaque
|
||||
crâne, son trait, limité à la forme, moins les silhouettes des crânes posés
|
||||
au-dessus ; les crânes entièrement cachés disparaissent. Les interstices
|
||||
(la forme moins toutes les silhouettes) peuvent prendre la couleur de
|
||||
l'encre, comme les ombres du motif de référence.
|
||||
- Que des chemins pleins, en règle pair-impair, qui ne se recouvrent pas :
|
||||
ni masque (`clipPath`), ni clone (`<use>`), ni objet blanc.
|
||||
- Opérations booléennes (différence, intersection, union) par un balayage
|
||||
écrit en Python pur (`boolean_ops.py`), sans dépendance.
|
||||
- Environ 5 s pour 100 crânes : 30 s et 600 Ko pour un cœur de 190 mm garni
|
||||
de 640 crânes (350 visibles).
|
||||
- Unités réelles (mm, cm, px, pt, in), justes même sur une page redimensionnée.
|
||||
- Interface traduite en français et en anglais, selon la langue d'Inkscape
|
||||
(anglais pour toute autre langue).
|
||||
- Script de déploiement Windows (`deploy.ps1`).
|
||||
|
||||
## Installation
|
||||
|
||||
Aucune dépendance externe : l'extension utilise `inkex`, fourni avec Inkscape.
|
||||
|
||||
### Windows (script)
|
||||
|
||||
Inkscape fermé :
|
||||
|
||||
```powershell
|
||||
.\deploy.ps1 # installe ou met à jour
|
||||
.\deploy.ps1 -Uninstall # désinstalle
|
||||
.\deploy.ps1 -Force # déploie même si Inkscape est ouvert
|
||||
```
|
||||
|
||||
Les fichiers sont copiés dans `%APPDATA%\inkscape\extensions\skullFill`.
|
||||
|
||||
### Manuelle
|
||||
|
||||
Copier dans un sous-dossier du répertoire des extensions utilisateur :
|
||||
|
||||
- `skull_fill.inx`, `skull_fill.py`, `skull_fill_core.py`, `skull_drawing.py` ;
|
||||
- `images/parameters_en.png` ;
|
||||
- `locale/` (traductions compilées).
|
||||
|
||||
| Système | Répertoire des extensions |
|
||||
| ------- | -------------------------------------------------- |
|
||||
| Windows | `%APPDATA%\inkscape\extensions` |
|
||||
| Linux | `~/.config/inkscape/extensions` |
|
||||
| macOS | `~/Library/Application Support/org.inkscape.Inkscape/config/inkscape/extensions` |
|
||||
|
||||
Redémarrer Inkscape.
|
||||
|
||||
## Utilisation
|
||||
|
||||
1. Sélectionner une ou plusieurs formes.
|
||||
2. **Extensions > AlexDesign > Remplissage têtes de mort…** (*Skull Pattern Fill*).
|
||||
3. Régler les onglets **Crânes** et **Style**, puis **Appliquer**.
|
||||
|
||||
Le résultat est un groupe « Remplissage têtes de mort » placé juste au-dessus
|
||||
de chaque forme : un chemin par crâne visible, plus les interstices. Pour la
|
||||
gravure, garder la forme d'origine seulement si son contour doit être gravé
|
||||
ou découpé.
|
||||
|
||||
**Conseils**
|
||||
|
||||
| Symptôme | Réglage |
|
||||
| ------------------------------------- | -------------------------------------------------------- |
|
||||
| Des vides apparaissent | Baisser l'espacement (70 % par défaut) ou cocher *Remplir les interstices* |
|
||||
| Trop de crânes, calcul refusé | Augmenter la plus petite hauteur ou l'espacement |
|
||||
| Calcul long, fichier lourd | Augmenter la plus petite hauteur ou l'espacement : moins de crânes |
|
||||
| Motif trop régulier | Écarter les deux hauteurs, augmenter l'inclinaison |
|
||||
| La disposition ne plaît pas | Changer la graine aléatoire |
|
||||
|
||||
## Paramètres
|
||||
|
||||

|
||||
|
||||
| Paramètre | Défaut | Rôle |
|
||||
| ------------------------------------------- | ----------- | ---- |
|
||||
| Hauteur du plus grand crâne | 30 | Taille maximale tirée |
|
||||
| Hauteur du plus petit crâne | 10 | Taille minimale ; fixe aussi le pas de la grille |
|
||||
| Unité | mm | mm, cm, px, pt, in |
|
||||
| Espacement (% de la plus petite hauteur) | 70 | Pas de la grille ; sous 100 %, les crânes se chevauchent |
|
||||
| Inclinaison maximale (°) | 30 | Angle tiré entre -max et +max |
|
||||
| Retourner des crânes en miroir au hasard | oui | Environ un crâne sur deux retourné |
|
||||
| Graine aléatoire | 1 | Autre valeur, autre disposition |
|
||||
| Couleur de l'encre | noir | Couleur de tout ce qui est écrit (trait, ombres, interstices) |
|
||||
| Remplir les interstices de la couleur de l'encre | oui | Fond de la forme sous les crânes |
|
||||
| Conserver la forme d'origine | oui | Sinon, la forme est supprimée |
|
||||
|
||||
## Structure du projet
|
||||
|
||||
```text
|
||||
skull_fill.inx Boîte de dialogue (textes source en anglais)
|
||||
skull_fill.py Couche inkex : sélection, unités, écriture des chemins
|
||||
skull_fill_core.py Logique pure, sans inkex : crâne, placements, encre visible
|
||||
boolean_ops.py Opérations booléennes sur polygones (balayage, Python pur)
|
||||
skull_drawing.py Données du crâne (générées par docs/extraire_crane.py)
|
||||
docs/extraire_crane.py Extraction du crâne de doc/dessin.svg, cornes retirées
|
||||
i18n.py Extraction / mise à jour / compilation des traductions
|
||||
po/ skullfill.pot, en.po, fr.po
|
||||
locale/ Catalogues .mo compilés (déployés)
|
||||
images/parameters_en.png Schéma de l'onglet « Help »
|
||||
docs/schema_parametres.py Générateur du schéma (fr pour le README, en pour le dialogue)
|
||||
docs/parametres.png Schéma du README
|
||||
docs/capture-desktop.png Rendu d'exemple
|
||||
doc/patern.png Motif de référence (disposition des crânes)
|
||||
doc/dessin.svg Dessin vectoriel du crâne (avec cornes, retirées à l'extraction)
|
||||
tests/data/ Formes d'exemple (shapes.svg, scaled.svg)
|
||||
test_skull_fill.py Tests pytest
|
||||
deploy.ps1 Déploiement Windows
|
||||
```
|
||||
|
||||
API du noyau `skull_fill_core` :
|
||||
|
||||
| Fonction | Rôle |
|
||||
| -------- | ---- |
|
||||
| `skull_geometry()` | Le crâne dans son repère unité : (silhouette, encre), listes de boucles de Bézier |
|
||||
| `skull_paths(placement, precision=3)` | Données `d` (silhouette, encre) d'un crâne placé |
|
||||
| `parse_loops(d)` | Chemin SVG en M, C, Z absolus → boucles de Bézier |
|
||||
| `Region(rings)` | Forme à remplir (pair-impair) : `contains(point)` |
|
||||
| `visible_skulls(placements, region, step=0.01)` | Encre visible de chaque crâne : `[(placement, anneaux)]`, crânes cachés omis |
|
||||
| `visible_gaps(placements, region, step=0.01)` | Interstices : la forme moins l'union des silhouettes |
|
||||
| `skull_radius()` | Rayon du disque contenant le crâne, pour une hauteur 1 |
|
||||
| `flatten_loops(loops, matrix, step)` | Boucles de Bézier → polygones |
|
||||
| `simplify_ring(ring, tolerance)` | Simplification de Douglas-Peucker |
|
||||
| `rings_to_d(rings, precision=2)` | Chemin compact (M, l relatifs, z) |
|
||||
| `ring_area(ring)` | Aire signée d'un anneau |
|
||||
| `skull_placements(rings, size_min, size_max, spacing=0.7, max_rotation=30, mirror=True, seed=1, origin=(0, 0))` | Tuples `(x, y, taille, angle, miroir)` couvrant la région, du plus petit au plus grand |
|
||||
| `placement_matrix(x, y, size, angle=0, mirror=False)` | Matrice affine du repère unité vers le document |
|
||||
| `loops_to_d(loops, matrix, precision=3)` | Chemin SVG (M, C, Z absolus) de boucles transformées |
|
||||
| `random_size(rng, size_min, size_max, exponent=3)` | Taille selon une loi de puissance tronquée |
|
||||
| `estimate_count(rings, size_min, spacing)` | Nombre de positions candidates |
|
||||
| `point_in_rings(point, rings)`, `distance_to_rings(point, rings)`, `rings_bbox(rings)` | Géométrie de la région (pair-impair) |
|
||||
| `parse_color(value)` | Couleur Inkscape → (`#rrggbb`, opacité) |
|
||||
|
||||
Moteur `boolean_ops` : `boolean(ensembles, prédicat)` combine des ensembles
|
||||
`(anneaux, règle)` (`"evenodd"` ou `"nonzero"`) selon un prédicat sur
|
||||
l'appartenance à chacun ; `union`, `intersection` et `difference` en sont des
|
||||
raccourcis. Résultat : des anneaux à remplir en pair-impair. Les points sont
|
||||
calés sur une grille de 1e-6 ; deux polygones aux côtés exactement confondus
|
||||
sont gérés, mais pas des côtés décalés de moins de 1e-5 (cas absent des
|
||||
crânes).
|
||||
|
||||
## Développement
|
||||
|
||||
```powershell
|
||||
python -m venv .venv
|
||||
.venv\Scripts\activate
|
||||
pip install pytest lxml tinycss2 cssselect2 cssselect
|
||||
python -m pytest -q
|
||||
```
|
||||
|
||||
Sans inkex : 32 tests passés, 6 ignorés (bout en bout). Avec inkex :
|
||||
|
||||
```powershell
|
||||
$env:PYTHONPATH = 'C:\Program Files\Inkscape\share\inkscape\extensions'
|
||||
python -m pytest -q # 38 tests passés (environ 30 s)
|
||||
```
|
||||
|
||||
Les tests couvrent le crâne (repère unité, encre dans le cadre, boucles fermées,
|
||||
absence de cornes, vue de trois quarts), la lecture et l'écriture des chemins,
|
||||
le moteur booléen (opérations de base, côtés communs, règle non nulle, trous,
|
||||
différences aléatoires vérifiées par échantillonnage), l'encre visible (aucun
|
||||
point sous un crâne du dessus ni hors de la forme, crâne du dessus entier,
|
||||
crâne caché ou hors forme omis, interstices), les placements (couverture,
|
||||
ordre, bornes d'angle, miroir, trous, reproductibilité), le bout en bout (ni
|
||||
masque, ni clone, ni blanc, tout dans la forme, trou laissé vide, couleur,
|
||||
interstices, groupes, échelle de document non standard, garde-fou du nombre
|
||||
de crânes) et la cohérence `.inx` ↔ arguments ↔ traductions.
|
||||
|
||||
### Traductions
|
||||
|
||||
```powershell
|
||||
python i18n.py # extrait, met à jour po/*.po, compile locale/*.mo
|
||||
```
|
||||
|
||||
Après modification d'un texte (`.inx` ou `_("...")`) : lancer `python i18n.py`,
|
||||
compléter les `msgstr` vides de `po/fr.po`, relancer. Pour ajouter une langue,
|
||||
l'ajouter à `LANGUAGES` dans `i18n.py`.
|
||||
|
||||
### Dessin du crâne
|
||||
|
||||
```powershell
|
||||
$env:PYTHONPATH = 'C:\Program Files\Inkscape\share\inkscape\extensions'
|
||||
python docs/extraire_crane.py # doc/dessin.svg -> skull_drawing.py
|
||||
```
|
||||
|
||||
Le script lit le chemin unique de `doc/dessin.svg`, remplace les cornes par
|
||||
un arc qui prolonge la calotte, supprime leurs reflets et ramène le dessin au
|
||||
repère unité du noyau. Après une retouche du dessin dans Inkscape, vérifier
|
||||
les indices de nœuds notés en tête du script (`CUTS`, `HORN_DETAILS`), puis
|
||||
relancer le script, les tests et le schéma.
|
||||
|
||||
### Schéma des paramètres
|
||||
|
||||
```powershell
|
||||
python docs/schema_parametres.py # docs/parametres.png (fr) + images/parameters_en.png (en)
|
||||
```
|
||||
|
||||
Le schéma est dessiné avec les fonctions du noyau, puis exporté par
|
||||
`C:\Program Files\Inkscape\bin\inkscape.com`. La version anglaise est celle de
|
||||
l'onglet « Help » : Inkscape ne traduit pas le chemin d'une image.
|
||||
@@ -0,0 +1,411 @@
|
||||
# coding=utf-8
|
||||
"""
|
||||
Operations booleennes sur des polygones, en Python pur (sans inkex).
|
||||
|
||||
Sert a ne garder que l'encre reellement visible des cranes : une decoupeuse
|
||||
laser grave tout trait present dans le fichier, meme cache sous un autre
|
||||
objet. Il faut donc calculer la geometrie visible (difference, intersection,
|
||||
union) au lieu de laisser les cranes du dessus masquer ceux du dessous.
|
||||
|
||||
Principe (balayage de Bentley-Ottmann, a la maniere de PolyBool de Sean
|
||||
Connelly) : tous les cotes des polygones sont balayes de gauche a droite ;
|
||||
chaque croisement coupe les cotes concernes ; chaque morceau connait alors,
|
||||
pour chaque ensemble d'entree, le nombre d'enroulement juste au-dessus et
|
||||
juste au-dessous de lui. Un predicat dit si un point est dans le resultat
|
||||
selon son appartenance a chaque ensemble ; on garde les morceaux qui
|
||||
separent un cote « dedans » d'un cote « dehors », puis on les enchaine en
|
||||
anneaux fermes.
|
||||
|
||||
Conventions :
|
||||
- un anneau est une liste de points (x, y), ferme implicitement ;
|
||||
- un ensemble est (anneaux, regle), regle valant "evenodd" ou "nonzero" ;
|
||||
- le resultat est une liste d'anneaux a remplir en regle pair-impair.
|
||||
"""
|
||||
|
||||
import heapq
|
||||
|
||||
# Tous les points (sommets d'entree et croisements) sont cales sur une
|
||||
# grille de pas GRID : deux points sont confondus s'ils sont egaux, et
|
||||
# l'ordre de balayage est une simple comparaison de nombres. EPS sert aux
|
||||
# produits vectoriels (alignements), EPS_T a la position le long d'un
|
||||
# segment.
|
||||
GRID = 1e-6
|
||||
EPS = 1e-10
|
||||
EPS_T = 1e-9
|
||||
# Un croisement plus proche que SNAP d'une extremite est rabattu sur elle :
|
||||
# sans cela, deux croisements presque confondus creent des segments de
|
||||
# quelques millioniemes que les tests d'alignement jugent mal.
|
||||
SNAP = 1e-5
|
||||
|
||||
|
||||
def snap(p):
|
||||
return (round(p[0] / GRID) * GRID, round(p[1] / GRID) * GRID)
|
||||
|
||||
|
||||
def _compare(a, b):
|
||||
"""Ordre de balayage : x croissant, puis y croissant."""
|
||||
if a == b:
|
||||
return 0
|
||||
return -1 if a < b else 1
|
||||
|
||||
|
||||
def _same(a, b):
|
||||
return a == b
|
||||
|
||||
|
||||
def _near(a, b):
|
||||
return abs(a[0] - b[0]) < SNAP and abs(a[1] - b[1]) < SNAP
|
||||
|
||||
|
||||
def _above_or_on(pt, left, right):
|
||||
return ((right[0] - left[0]) * (pt[1] - left[1])
|
||||
- (right[1] - left[1]) * (pt[0] - left[0])) >= -EPS
|
||||
|
||||
|
||||
def _collinear(a, b, c):
|
||||
return abs((a[0] - b[0]) * (b[1] - c[1]) - (b[0] - c[0]) * (a[1] - b[1])) < EPS
|
||||
|
||||
|
||||
def _between(p, left, right):
|
||||
"""p (aligne sur left-right) est-il strictement entre les deux ?"""
|
||||
dpx, dpy = p[0] - left[0], p[1] - left[1]
|
||||
drx, dry = right[0] - left[0], right[1] - left[1]
|
||||
dot = dpx * drx + dpy * dry
|
||||
if dot < EPS:
|
||||
return False
|
||||
return dot - (drx * drx + dry * dry) <= -EPS
|
||||
|
||||
|
||||
def _along(v):
|
||||
"""Position d'un parametre sur un segment : -2 avant, -1 au debut,
|
||||
0 dedans, 1 a la fin, 2 apres."""
|
||||
if v <= -EPS_T:
|
||||
return -2
|
||||
if v < EPS_T:
|
||||
return -1
|
||||
if v - 1 <= -EPS_T:
|
||||
return 0
|
||||
if v - 1 < EPS_T:
|
||||
return 1
|
||||
return 2
|
||||
|
||||
|
||||
def _lines_intersect(a0, a1, b0, b1):
|
||||
adx, ady = a1[0] - a0[0], a1[1] - a0[1]
|
||||
bdx, bdy = b1[0] - b0[0], b1[1] - b0[1]
|
||||
axb = adx * bdy - ady * bdx
|
||||
if abs(axb) < EPS:
|
||||
return None
|
||||
dx, dy = a0[0] - b0[0], a0[1] - b0[1]
|
||||
a = (bdx * dy - bdy * dx) / axb
|
||||
b = (adx * dy - ady * dx) / axb
|
||||
return _along(a), _along(b), snap((a0[0] + a * adx, a0[1] + a * ady))
|
||||
|
||||
|
||||
class _Segment(object):
|
||||
__slots__ = ("start", "end", "delta", "below", "above")
|
||||
|
||||
def __init__(self, start, end, delta):
|
||||
self.start, self.end, self.delta = start, end, delta
|
||||
self.below = self.above = None
|
||||
|
||||
|
||||
class _Event(object):
|
||||
__slots__ = ("is_start", "pt", "seg", "other", "entry")
|
||||
|
||||
def __init__(self, is_start, pt, seg):
|
||||
self.is_start, self.pt, self.seg = is_start, pt, seg
|
||||
self.other = None
|
||||
self.entry = None
|
||||
|
||||
|
||||
class _Tie(object):
|
||||
"""Departage de deux evenements au meme point (cle figee a l'insertion)."""
|
||||
__slots__ = ("is_start", "p1", "p2")
|
||||
|
||||
def __init__(self, ev):
|
||||
self.is_start, self.p1, self.p2 = ev.is_start, ev.pt, ev.other.pt
|
||||
|
||||
def compare(self, other):
|
||||
if self.p2 == other.p2:
|
||||
return 0
|
||||
if self.is_start != other.is_start:
|
||||
# A meme point, les fins passent avant les debuts.
|
||||
return 1 if self.is_start else -1
|
||||
if other.is_start:
|
||||
return 1 if _above_or_on(self.p2, other.p1, other.p2) else -1
|
||||
return 1 if _above_or_on(self.p2, other.p2, other.p1) else -1
|
||||
|
||||
def __lt__(self, other):
|
||||
return self.compare(other) < 0
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.compare(other) == 0
|
||||
|
||||
|
||||
def _status_compare(ev1, ev2):
|
||||
a1, a2 = ev1.seg.start, ev1.seg.end
|
||||
b1, b2 = ev2.seg.start, ev2.seg.end
|
||||
if _collinear(a1, b1, b2):
|
||||
if _collinear(a2, b1, b2):
|
||||
return 1
|
||||
return 1 if _above_or_on(a2, b1, b2) else -1
|
||||
return 1 if _above_or_on(a1, b1, b2) else -1
|
||||
|
||||
|
||||
class _Sweep(object):
|
||||
|
||||
def __init__(self, count):
|
||||
self.count = count
|
||||
self.heap = []
|
||||
self.serial = 0
|
||||
self.status = []
|
||||
|
||||
# -- file des evenements (tas, suppressions paresseuses) ---------------
|
||||
|
||||
def push(self, ev):
|
||||
self.serial += 1
|
||||
ev.entry = self.serial
|
||||
# Le point d'abord (comparaison rapide), le departage ensuite.
|
||||
heapq.heappush(self.heap, (ev.pt, _Tie(ev), self.serial, ev))
|
||||
|
||||
def head(self):
|
||||
heap = self.heap
|
||||
while heap and heap[0][3].entry != heap[0][2]:
|
||||
heapq.heappop(heap)
|
||||
return heap[0][3] if heap else None
|
||||
|
||||
def add_segment(self, seg):
|
||||
start = _Event(True, seg.start, seg)
|
||||
end = _Event(False, seg.end, seg)
|
||||
start.other, end.other = end, start
|
||||
self.push(start)
|
||||
self.push(end)
|
||||
return start
|
||||
|
||||
def update_end(self, ev, pt):
|
||||
ev.other.entry = None
|
||||
ev.seg.end = pt
|
||||
ev.other.pt = pt
|
||||
self.push(ev.other)
|
||||
|
||||
def divide(self, ev, pt):
|
||||
# La coupe doit tomber strictement entre les extremites, dans l'ordre
|
||||
# du balayage, sinon elle retournerait un morceau.
|
||||
if not (ev.seg.start < pt < ev.seg.end):
|
||||
return None
|
||||
piece = _Segment(pt, ev.seg.end, list(ev.seg.delta))
|
||||
self.update_end(ev, pt)
|
||||
return self.add_segment(piece)
|
||||
|
||||
def add_ring(self, ring, index):
|
||||
ring = [snap(p) for p in ring]
|
||||
n = len(ring)
|
||||
for i in range(n):
|
||||
p1, p2 = ring[i - 1], ring[i]
|
||||
forward = _compare(p1, p2)
|
||||
if forward == 0:
|
||||
continue
|
||||
delta = [0] * self.count
|
||||
# Le sens d'origine du cote donne le signe de l'enroulement.
|
||||
delta[index] = 1 if forward < 0 else -1
|
||||
if forward < 0:
|
||||
self.add_segment(_Segment(p1, p2, delta))
|
||||
else:
|
||||
self.add_segment(_Segment(p2, p1, delta))
|
||||
|
||||
# -- croisements --------------------------------------------------------
|
||||
|
||||
def check(self, ev1, ev2):
|
||||
"""Coupe ev1 et ev2 a leur croisement ; renvoie ev2 s'ils sont confondus."""
|
||||
a1, a2 = ev1.seg.start, ev1.seg.end
|
||||
b1, b2 = ev2.seg.start, ev2.seg.end
|
||||
cross = _lines_intersect(a1, a2, b1, b2)
|
||||
if cross is None:
|
||||
# Paralleles : seul le cas aligne et chevauchant compte.
|
||||
if not _collinear(a1, a2, b1):
|
||||
return None
|
||||
if _same(a1, b2) or _same(a2, b1):
|
||||
return None
|
||||
a1_b1, a2_b2 = _same(a1, b1), _same(a2, b2)
|
||||
if a1_b1 and a2_b2:
|
||||
return ev2
|
||||
a1_between = not a1_b1 and _between(a1, b1, b2)
|
||||
a2_between = not a2_b2 and _between(a2, b1, b2)
|
||||
if a1_b1:
|
||||
if a2_between:
|
||||
self.divide(ev2, a2)
|
||||
else:
|
||||
self.divide(ev1, b2)
|
||||
return ev2
|
||||
if a1_between:
|
||||
if not a2_b2:
|
||||
if a2_between:
|
||||
self.divide(ev2, a2)
|
||||
else:
|
||||
self.divide(ev1, b2)
|
||||
self.divide(ev2, a1)
|
||||
return None
|
||||
along_a, along_b, pt = cross
|
||||
# Croisement confondu avec un sommet : on le rabat sur ce sommet.
|
||||
if along_a == 0:
|
||||
if _near(pt, a1):
|
||||
along_a = -1
|
||||
elif _near(pt, a2):
|
||||
along_a = 1
|
||||
if along_b == 0:
|
||||
if _near(pt, b1):
|
||||
along_b, pt = -1, b1
|
||||
elif _near(pt, b2):
|
||||
along_b, pt = 1, b2
|
||||
if along_a == -1:
|
||||
pt = a1
|
||||
elif along_a == 1:
|
||||
pt = a2
|
||||
if along_a == 0:
|
||||
if along_b == -1:
|
||||
self.divide(ev1, b1)
|
||||
elif along_b == 0:
|
||||
self.divide(ev1, pt)
|
||||
elif along_b == 1:
|
||||
self.divide(ev1, b2)
|
||||
if along_b == 0:
|
||||
if along_a == -1:
|
||||
self.divide(ev2, a1)
|
||||
elif along_a == 0:
|
||||
self.divide(ev2, pt)
|
||||
elif along_a == 1:
|
||||
self.divide(ev2, a2)
|
||||
return None
|
||||
|
||||
# -- balayage -----------------------------------------------------------
|
||||
|
||||
def run(self):
|
||||
status = self.status
|
||||
result = []
|
||||
zero = [0] * self.count
|
||||
while True:
|
||||
ev = self.head()
|
||||
if ev is None:
|
||||
break
|
||||
if ev.is_start:
|
||||
index = len(status)
|
||||
for i, here in enumerate(status):
|
||||
if _status_compare(ev, here) > 0:
|
||||
index = i
|
||||
break
|
||||
above = status[index - 1] if index > 0 else None
|
||||
below = status[index] if index < len(status) else None
|
||||
same = self.check(ev, above) if above is not None else None
|
||||
if same is None and below is not None:
|
||||
same = self.check(ev, below)
|
||||
if same is not None:
|
||||
# Cotes confondus : un seul morceau, enroulements cumules.
|
||||
# `same` est deja dans le statut : son enroulement au-dessus
|
||||
# change aussi.
|
||||
for k, d in enumerate(ev.seg.delta):
|
||||
same.seg.delta[k] += d
|
||||
if same.seg.above is not None:
|
||||
same.seg.above[k] += d
|
||||
ev.entry = None
|
||||
ev.other.entry = None
|
||||
if self.head() is not ev:
|
||||
continue
|
||||
base = below.seg.above if below is not None else zero
|
||||
ev.seg.below = list(base)
|
||||
ev.seg.above = [b + d for b, d in zip(base, ev.seg.delta)]
|
||||
status.insert(index, ev)
|
||||
ev.entry = None
|
||||
else:
|
||||
start = ev.other
|
||||
i = status.index(start)
|
||||
if 0 < i < len(status) - 1:
|
||||
self.check(status[i - 1], status[i + 1])
|
||||
del status[i]
|
||||
result.append(ev.seg)
|
||||
ev.entry = None
|
||||
return result
|
||||
|
||||
|
||||
def _inside(winding, rule):
|
||||
return (winding % 2 == 1) if rule == "evenodd" else (winding != 0)
|
||||
|
||||
|
||||
def _chain(segments):
|
||||
"""Morceaux de frontiere -> anneaux fermes."""
|
||||
def key(p):
|
||||
return (round(p[0] * 1e6), round(p[1] * 1e6))
|
||||
|
||||
ends = {}
|
||||
for i, seg in enumerate(segments):
|
||||
ends.setdefault(key(seg.start), []).append(i)
|
||||
ends.setdefault(key(seg.end), []).append(i)
|
||||
used = [False] * len(segments)
|
||||
rings = []
|
||||
for i, seg in enumerate(segments):
|
||||
if used[i]:
|
||||
continue
|
||||
used[i] = True
|
||||
ring = [seg.start]
|
||||
first = key(seg.start)
|
||||
point = seg.end
|
||||
while key(point) != first:
|
||||
ring.append(point)
|
||||
nxt = None
|
||||
for j in ends.get(key(point), ()):
|
||||
if not used[j]:
|
||||
nxt = j
|
||||
break
|
||||
if nxt is None:
|
||||
ring = None
|
||||
break
|
||||
used[nxt] = True
|
||||
other = segments[nxt]
|
||||
point = other.end if key(other.start) == key(point) else other.start
|
||||
if ring and len(ring) >= 3:
|
||||
rings.append(_drop_collinear(ring))
|
||||
return [ring for ring in rings if len(ring) >= 3]
|
||||
|
||||
|
||||
def _drop_collinear(ring):
|
||||
result = []
|
||||
n = len(ring)
|
||||
for i in range(n):
|
||||
a, b, c = ring[i - 1], ring[i], ring[(i + 1) % n]
|
||||
if not _collinear(a, b, c):
|
||||
result.append(b)
|
||||
return result
|
||||
|
||||
|
||||
def boolean(sets, predicate):
|
||||
"""Combinaison booleenne de plusieurs ensembles de polygones.
|
||||
|
||||
`sets` : liste de (anneaux, regle) ; `predicate` recoit un tuple de
|
||||
booleens (le point est-il dans chaque ensemble ?) et dit s'il est dans le
|
||||
resultat. Renvoie des anneaux a remplir en regle pair-impair.
|
||||
"""
|
||||
rules = [rule for _rings, rule in sets]
|
||||
sweep = _Sweep(len(sets))
|
||||
for index, (rings, _rule) in enumerate(sets):
|
||||
for ring in rings:
|
||||
if len(ring) >= 3:
|
||||
sweep.add_ring(ring, index)
|
||||
kept = []
|
||||
for seg in sweep.run():
|
||||
below = predicate(tuple(_inside(w, r) for w, r in zip(seg.below, rules)))
|
||||
above = predicate(tuple(_inside(w, r) for w, r in zip(seg.above, rules)))
|
||||
if below != above:
|
||||
kept.append(seg)
|
||||
return _chain(kept)
|
||||
|
||||
|
||||
def union(rings, rule="nonzero"):
|
||||
return boolean([(rings, rule)], lambda inside: inside[0])
|
||||
|
||||
|
||||
def intersection(a, b, rule_a="evenodd", rule_b="evenodd"):
|
||||
return boolean([(a, rule_a), (b, rule_b)], lambda inside: inside[0] and inside[1])
|
||||
|
||||
|
||||
def difference(a, b, rule_a="evenodd", rule_b="evenodd"):
|
||||
return boolean([(a, rule_a), (b, rule_b)], lambda inside: inside[0] and not inside[1])
|
||||
@@ -0,0 +1,107 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Déploie l'extension « Remplissage têtes de mort » dans Inkscape.
|
||||
|
||||
.DESCRIPTION
|
||||
Copie skull_fill.inx, skull_fill.py, skull_fill_core.py, skull_drawing.py, boolean_ops.py, le schéma de l'onglet
|
||||
« Help » (images\parameters_en.png) et les traductions
|
||||
compilées (locale\<langue>\LC_MESSAGES\skullfill.mo) dans un
|
||||
sous-dossier dédié du répertoire des extensions utilisateur d'Inkscape
|
||||
(Inkscape explore récursivement ce répertoire). Refuse de s'exécuter si
|
||||
Inkscape est ouvert : les extensions ne sont chargées qu'au démarrage.
|
||||
|
||||
.PARAMETER ExtensionsDir
|
||||
Répertoire des extensions Inkscape. Par défaut : %APPDATA%\inkscape\extensions
|
||||
|
||||
.PARAMETER FolderName
|
||||
Nom du sous-dossier de l'extension. Par défaut : skullFill
|
||||
|
||||
.PARAMETER Uninstall
|
||||
Supprime le sous-dossier de l'extension au lieu de le créer.
|
||||
|
||||
.PARAMETER Force
|
||||
Déploie même si Inkscape est en cours d'exécution.
|
||||
|
||||
.EXAMPLE
|
||||
.\deploy.ps1
|
||||
.\deploy.ps1 -Uninstall
|
||||
.\deploy.ps1 -FolderName 'autre-nom'
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string] $ExtensionsDir = (Join-Path $env:APPDATA 'inkscape\extensions'),
|
||||
[string] $FolderName = 'skullFill',
|
||||
[switch] $Uninstall,
|
||||
[switch] $Force
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$files = @('skull_fill.inx', 'skull_fill.py', 'skull_fill_core.py', 'skull_drawing.py', 'boolean_ops.py', 'images\parameters_en.png')
|
||||
$localeDir = 'locale'
|
||||
$source = $PSScriptRoot
|
||||
$destination = Join-Path $ExtensionsDir $FolderName
|
||||
|
||||
# --- Inkscape doit être fermé : les extensions sont lues au démarrage ---------
|
||||
$running = Get-Process -Name 'inkscape' -ErrorAction SilentlyContinue
|
||||
if ($running -and -not $Force) {
|
||||
Write-Error "Inkscape est ouvert. Fermez-le puis relancez le script (ou utilisez -Force)."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# --- Désinstallation ---------------------------------------------------------
|
||||
if ($Uninstall) {
|
||||
if (Test-Path -LiteralPath $destination) {
|
||||
Remove-Item -LiteralPath $destination -Recurse -Force
|
||||
Write-Host "Supprimé : $destination" -ForegroundColor Green
|
||||
}
|
||||
else {
|
||||
Write-Host "Rien à supprimer : $destination n'existe pas." -ForegroundColor Yellow
|
||||
}
|
||||
exit 0
|
||||
}
|
||||
|
||||
# --- Vérification des sources ------------------------------------------------
|
||||
$missing = $files | Where-Object { -not (Test-Path -LiteralPath (Join-Path $source $_)) }
|
||||
if (-not (Test-Path -LiteralPath (Join-Path $source $localeDir))) {
|
||||
$missing = @($missing) + "$localeDir\ (lancer : python i18n.py)"
|
||||
}
|
||||
if ($missing) {
|
||||
Write-Error "Fichier(s) introuvable(s) dans $source : $($missing -join ', ')"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# --- Copie -------------------------------------------------------------------
|
||||
if (-not (Test-Path -LiteralPath $destination)) {
|
||||
New-Item -ItemType Directory -Path $destination -Force | Out-Null
|
||||
Write-Host "Dossier créé : $destination"
|
||||
}
|
||||
|
||||
foreach ($file in $files) {
|
||||
$from = Join-Path $source $file
|
||||
$to = Join-Path $destination $file
|
||||
$action = if (Test-Path -LiteralPath $to) { 'remplacé' } else { 'copié ' }
|
||||
New-Item -ItemType Directory -Path (Split-Path $to) -Force | Out-Null
|
||||
Copy-Item -LiteralPath $from -Destination $to -Force
|
||||
Write-Host " $action $file"
|
||||
}
|
||||
|
||||
# Traductions : le dossier est remplacé en entier (langue retirée => supprimée)
|
||||
$localeTo = Join-Path $destination $localeDir
|
||||
if (Test-Path -LiteralPath $localeTo) {
|
||||
Remove-Item -LiteralPath $localeTo -Recurse -Force
|
||||
}
|
||||
Copy-Item -LiteralPath (Join-Path $source $localeDir) -Destination $localeTo -Recurse
|
||||
$languages = Get-ChildItem -LiteralPath $localeTo -Directory | ForEach-Object Name
|
||||
Write-Host " copié $localeDir\ ($($languages -join ', '))"
|
||||
|
||||
# Le cache Python d'une version précédente peut masquer les fichiers copiés
|
||||
$pycache = Join-Path $destination '__pycache__'
|
||||
if (Test-Path -LiteralPath $pycache) {
|
||||
Remove-Item -LiteralPath $pycache -Recurse -Force
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Extension déployée dans $destination" -ForegroundColor Green
|
||||
Write-Host "Redémarrez Inkscape, puis : Extensions > AlexDesign > Remplissage têtes de mort..."
|
||||
|
After Width: | Height: | Size: 129 KiB |
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="400mm"
|
||||
height="400mm"
|
||||
viewBox="0 0 538.72053 538.72054"
|
||||
version="1.1"
|
||||
id="svg5"
|
||||
inkscape:version="1.4.4 (dcaf3e7, 2026-05-05)"
|
||||
xml:space="preserve"
|
||||
sodipodi:docname="dessin.svg"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
|
||||
id="namedview7"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#cccccc"
|
||||
borderopacity="1"
|
||||
inkscape:showpageshadow="0"
|
||||
inkscape:pageopacity="1"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:document-units="mm"
|
||||
showgrid="false"
|
||||
inkscape:zoom="1.4191288"
|
||||
inkscape:cx="656.03631"
|
||||
inkscape:cy="474.58695"
|
||||
inkscape:window-width="2560"
|
||||
inkscape:window-height="1387"
|
||||
inkscape:window-x="2552"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="layer1" /><defs
|
||||
id="defs2" /><g
|
||||
inkscape:label="Calque 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"><path
|
||||
style="fill:#000000"
|
||||
d="m 189.07036,242.9122 -1.82876,-1.74451 -0.0958,-4.9673 c -0.0796,-4.12772 -0.26201,-5.56957 -1.07936,-8.5307 -0.54097,-1.95988 -1.0246,-4.31026 -1.07473,-5.22307 -0.0549,-0.99905 -0.38634,-2.06284 -0.83279,-2.67256 -0.51919,-0.70909 -0.8111,-1.81452 -0.97318,-3.68546 -0.12735,-1.4699 -0.43924,-2.91309 -0.6931,-3.20707 -0.29541,-0.34209 -0.44323,-1.43245 -0.41063,-3.0289 0.0545,-2.67106 -0.364,-3.84014 -2.00922,-5.61237 -0.88448,-0.95276 -1.0168,-0.97994 -4.77074,-0.97994 h -3.86103 l -2.03561,-3.92714 c -1.11959,-2.15993 -2.03562,-4.31557 -2.03562,-4.79033 0,-0.47476 0.52018,-2.35559 1.15596,-4.17962 1.05444,-3.02515 1.15615,-3.692 1.15811,-7.59253 0.002,-4.16205 -0.0315,-4.34671 -1.25939,-6.92405 l -1.26154,-2.64796 1.67849,-3.27645 c 1.80104,-3.51567 1.84549,-3.72879 2.41523,-11.57883 0.57098,-7.86708 2.40141,-13.85617 6.10263,-19.96758 l 0.77374,-1.27758 -1.63192,-3.35485 c -2.45357,-5.04396 -3.13809,-8.12241 -2.96458,-13.3324 0.1687,-5.06535 0.52806,-6.08115 4.971,-14.05155 3.67953,-6.600876 5.42558,-10.376256 5.98977,-12.951336 0.25143,-1.14756 0.62076,-2.00246 0.83433,-1.93127 0.21077,0.0703 0.70278,0.67491 1.09336,1.34367 1.0736,1.83827 1.16406,7.12093 0.23203,13.549776 -0.82005,5.65635 -0.71477,8.50783 0.36558,9.90175 0.36226,0.4674 0.65865,1.12096 0.65865,1.45234 0,0.33138 0.40088,0.97912 0.89085,1.43942 0.48997,0.4603 0.89086,1.21385 0.89086,1.67456 0,0.64782 0.24512,0.88667 1.08167,1.05398 0.59493,0.11899 1.24198,0.51586 1.43791,0.88195 0.19592,0.36608 0.53786,0.66561 0.75987,0.66561 0.222,0 2.13333,-0.80379 4.24739,-1.78619 4.59828,-2.13682 10.03822,-3.9994 14.81087,-5.0711 2.9575,-0.6641 4.56906,-0.78466 10.44567,-0.78144 9.6392,0.005 15.62618,1.19743 23.43083,4.66564 l 3.65388,1.6237 3.1166,-2.13079 3.11659,-2.13079 3.20708,-0.15661 c 1.76388,-0.0861 3.52777,-0.33083 3.91975,-0.54377 0.918,-0.49871 5.73777,-1.53762 7.12682,-1.53621 1.30766,0.001 4.66726,-1.51635 5.87963,-2.65609 0.48997,-0.46062 1.61158,-1.02848 2.49247,-1.26193 3.02728,-0.80225 6.96649,-6.19575 8.84417,-12.109276 0.98255,-3.09442 1.49164,-6.74481 1.49164,-10.69554 0,-2.90671 0.0666,-3.24136 0.6236,-3.13536 0.93764,0.17843 2.70127,3.05535 3.57874,5.83782 1.28855,4.08602 1.63212,6.5091 1.63859,11.556486 0.005,3.90383 -0.14245,5.33394 -0.7823,7.58703 -2.82283,9.94008 -10.64534,17.87974 -24.61411,24.98274 l -4.64199,2.36041 1.03087,2.29761 c 3.17009,7.06553 4.49175,14.27408 4.15051,22.63753 -0.30187,7.39869 -1.52671,12.37151 -4.73892,19.23992 -1.90065,4.06401 -3.16845,6.12467 -5.83769,9.48849 -1.10738,1.39553 -2.35628,3.2396 -2.77533,4.09792 -1.75344,3.59148 -6.2232,7.44022 -8.64074,7.44022 -0.37573,0 -0.70486,0.0401 -0.73141,0.0891 -0.0265,0.049 -0.14681,3.29615 -0.26726,7.2159 l -0.21899,7.12683 -5.21488,3.91975 c -2.86819,2.15587 -6.18886,4.82715 -7.37926,5.93619 -1.19041,1.10904 -4.99431,3.9954 -8.45311,6.41412 -3.45879,2.41872 -8.07068,5.81632 -10.24864,7.55023 l -3.95993,3.15256 -2.68353,-0.27072 c -3.05483,-0.30818 -14.12472,-0.27528 -16.13003,0.0479 -1.22822,0.19796 -1.47199,0.0799 -3.15966,-1.53001 z m 23.19846,-0.97931 c 0.88195,-0.67099 3.4476,-2.67927 5.70146,-4.46285 2.25386,-1.78358 6.00348,-4.53978 8.3325,-6.12487 2.32902,-1.5851 5.60698,-4.1418 7.28437,-5.68156 1.67738,-1.53976 4.86219,-4.09225 7.07734,-5.67219 2.59,-1.84731 4.08379,-3.15187 4.18514,-3.65498 0.0867,-0.43029 0.25192,-2.85476 0.36721,-5.3877 0.19715,-4.33107 0.8722,-9.89492 1.58598,-13.07172 0.2973,-1.32318 0.25614,-1.43677 -0.69967,-1.93104 -1.46237,-0.75623 -1.64801,-0.67652 -1.88904,0.81111 -0.11908,0.73496 -0.79458,2.192 -1.50112,3.23788 -1.47315,2.18068 -2.95472,2.97453 -5.67846,3.04263 -1.69155,0.0423 -1.78741,-0.005 -1.89446,-0.93539 -0.12192,-1.0596 -0.2294,-1.09035 -2.65089,-0.75845 l -1.61592,0.22149 -0.57885,3.16397 c -0.71489,3.90752 -4.27148,14.25933 -5.06584,14.74462 -0.32081,0.19599 -1.04286,0.7314 -1.60457,1.18979 -1.40978,1.15049 -1.28258,0.34868 0.2061,-1.29911 1.18787,-1.31483 3.04763,-5.89016 2.58305,-6.35474 -0.11779,-0.11779 -0.82288,0.25318 -1.56687,0.82438 -0.74399,0.57121 -1.78107,1.22277 -2.30463,1.44792 -0.71498,0.30747 -0.90419,0.59183 -0.7602,1.14246 0.10651,0.40732 0.0199,0.73309 -0.19501,0.73309 -0.2127,0 -0.30236,-0.21984 -0.19926,-0.48853 0.10311,-0.26869 -0.0981,-0.59813 -0.44721,-0.73208 -0.86953,-0.33367 -1.64424,0.78007 -1.34476,1.93329 0.53147,2.0466 0.55868,2.95889 0.097,3.25158 -0.81865,0.51896 -1.14386,0.33894 -0.56323,-0.31177 0.4686,-0.52516 0.47969,-0.6939 0.0703,-1.06902 -0.58421,-0.53525 -1.22893,-0.58199 -1.22893,-0.0891 0,0.19599 0.26726,0.35635 0.5939,0.35635 0.32665,0 0.48287,0.11103 0.34716,0.24674 -0.40457,0.40457 -1.60197,0.48166 -1.82696,0.11762 -0.11501,-0.1861 -0.54974,0.002 -0.96606,0.41857 l -0.75694,0.75694 0.72298,0.58544 c 0.7109,0.57566 0.69995,0.59869 -0.65542,1.37875 -1.0581,0.60896 -1.37841,1.01442 -1.37841,1.74479 0,0.74004 -0.095,0.85646 -0.42761,0.52387 -0.23519,-0.23518 -0.53136,-0.42761 -0.65816,-0.42761 -0.41122,0 -1.62973,1.22963 -1.87627,1.89338 -0.26652,0.71758 -0.9Line truncated
|
||||
id="path1" /></g></svg>
|
||||
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 537 KiB |
|
After Width: | Height: | Size: 532 KiB |
@@ -0,0 +1,168 @@
|
||||
#!/usr/bin/env python3
|
||||
# coding=utf-8
|
||||
"""
|
||||
Extrait le crane du dessin de reference doc/dessin.svg, sans ses cornes,
|
||||
et l'ecrit dans skull_drawing.py (donnees du noyau, sans inkex).
|
||||
|
||||
python docs/extraire_crane.py
|
||||
|
||||
Necessite inkex (PYTHONPATH vers les extensions d'Inkscape) : il sert a lire
|
||||
le chemin et a le convertir en courbes de Bezier absolues. Le noyau, lui, ne
|
||||
lit que les chaines produites.
|
||||
|
||||
Le dessin est un seul chemin noir (regle non nulle) :
|
||||
- le sous-chemin 0 est le contour exterieur du crane et des cornes ;
|
||||
- le sous-chemin 33 borde l'interieur blanc du crane ; a droite, il contourne
|
||||
la base sombre de la corne ;
|
||||
- les sous-chemins 47 a 62 sont les reflets des cornes.
|
||||
|
||||
Pour retirer les cornes, on remplace les portions du contour exterieur qui
|
||||
les dessinent par un arc qui prolonge la calotte, on referme l'interieur
|
||||
blanc par un arc qui laisse a droite une ombre en croissant s'affinant vers
|
||||
le sommet, et on supprime les reflets. Le contour exterieur sert aussi de
|
||||
silhouette : rempli de la couleur de l'os, il cache les cranes du dessous.
|
||||
"""
|
||||
|
||||
import math
|
||||
import os
|
||||
import sys
|
||||
|
||||
import inkex
|
||||
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
ROOT = os.path.dirname(HERE)
|
||||
SOURCE = os.path.join(ROOT, "doc", "dessin.svg")
|
||||
TARGET = os.path.join(ROOT, "skull_drawing.py")
|
||||
|
||||
OUTER, INNER = 0, 33
|
||||
HORN_DETAILS = range(47, 63)
|
||||
|
||||
# Centre de la calotte (unites du dessin), autour duquel tournent les arcs.
|
||||
CENTER = (218.0, 168.0)
|
||||
|
||||
# (sous-chemin, premier noeud garde, noeud de reprise) : les noeuds entre les
|
||||
# deux sont remplaces par un arc. Indices releves sur le dessin.
|
||||
CUTS = [
|
||||
(OUTER, 20, 36), # corne gauche
|
||||
(OUTER, 39, 56), # corne droite
|
||||
(INNER, 70, 87), # base sombre de la corne droite
|
||||
]
|
||||
|
||||
|
||||
def segments(sub):
|
||||
"""Sous-chemin inkex (CubicSuperPath) -> segments (p0, c1, c2, p3)."""
|
||||
return [(tuple(a[1]), tuple(a[2]), tuple(b[0]), tuple(b[1]))
|
||||
for a, b in zip(sub, sub[1:])]
|
||||
|
||||
|
||||
def polar(point):
|
||||
dx, dy = point[0] - CENTER[0], point[1] - CENTER[1]
|
||||
return math.hypot(dx, dy), math.atan2(dy, dx)
|
||||
|
||||
|
||||
def arc(start, end, max_step=math.radians(15)):
|
||||
"""Arc de `start` a `end` autour de CENTER, rayon interpole lineairement."""
|
||||
r0, a0 = polar(start)
|
||||
r1, a1 = polar(end)
|
||||
# Plus court chemin angulaire.
|
||||
while a1 - a0 > math.pi:
|
||||
a1 -= 2 * math.pi
|
||||
while a0 - a1 > math.pi:
|
||||
a1 += 2 * math.pi
|
||||
count = max(1, int(math.ceil(abs(a1 - a0) / max_step)))
|
||||
result = []
|
||||
for k in range(count):
|
||||
ta, tb = k / count, (k + 1) / count
|
||||
aa, ab = a0 + ta * (a1 - a0), a0 + tb * (a1 - a0)
|
||||
ra, rb = r0 + ta * (r1 - r0), r0 + tb * (r1 - r0)
|
||||
h = 4.0 / 3.0 * math.tan((ab - aa) / 4.0)
|
||||
pa = (CENTER[0] + ra * math.cos(aa), CENTER[1] + ra * math.sin(aa))
|
||||
pb = (CENTER[0] + rb * math.cos(ab), CENTER[1] + rb * math.sin(ab))
|
||||
ca = (pa[0] - h * ra * math.sin(aa), pa[1] + h * ra * math.cos(aa))
|
||||
cb = (pb[0] + h * rb * math.sin(ab), pb[1] - h * rb * math.cos(ab))
|
||||
result.append((pa, ca, cb, pb))
|
||||
# Raccords exacts aux noeuds conserves.
|
||||
first, last = result[0], result[-1]
|
||||
result[0] = (start,) + first[1:]
|
||||
result[-1] = last[:3] + (end,)
|
||||
return result
|
||||
|
||||
|
||||
def cut(segs, keep, resume):
|
||||
"""Remplace les segments entre les noeuds `keep` et `resume` par un arc."""
|
||||
return segs[:keep] + arc(segs[keep][0], segs[resume][0]) + segs[resume:]
|
||||
|
||||
|
||||
def to_d(loops, transform, precision=4):
|
||||
fmt = "{:.%df},{:.%df}" % (precision, precision)
|
||||
|
||||
def pt(p):
|
||||
return fmt.format(*transform(p))
|
||||
|
||||
parts = []
|
||||
for loop in loops:
|
||||
parts.append("M " + pt(loop[0][0]))
|
||||
parts.extend("C {} {} {}".format(pt(c1), pt(c2), pt(p3)) for _p0, c1, c2, p3 in loop)
|
||||
parts.append("Z")
|
||||
return " ".join(parts)
|
||||
|
||||
|
||||
def main():
|
||||
document = inkex.load_svg(SOURCE).getroot()
|
||||
path = document.getElementById("path1")
|
||||
csp = path.path.transform(path.composed_transform()).to_superpath()
|
||||
subs = {k: segments(sub) for k, sub in enumerate(csp)}
|
||||
|
||||
# Les coupes d'un meme sous-chemin se font de la fin vers le debut, pour
|
||||
# que les indices des noeuds restent valables.
|
||||
for index, keep, resume in sorted(CUTS, key=lambda c: -c[1]):
|
||||
subs[index] = cut(subs[index], keep, resume)
|
||||
for index in HORN_DETAILS:
|
||||
del subs[index]
|
||||
|
||||
body = [subs[OUTER]]
|
||||
ink = [subs[k] for k in sorted(subs)]
|
||||
|
||||
# Repere unite : centre du cadre en (0, 0), hauteur 1.
|
||||
xs = [p[0] for seg in body[0] for p in seg]
|
||||
ys = [p[1] for seg in body[0] for p in seg]
|
||||
cx, cy = (min(xs) + max(xs)) / 2, (min(ys) + max(ys)) / 2
|
||||
height = max(ys) - min(ys)
|
||||
|
||||
def unit(p):
|
||||
return ((p[0] - cx) / height, (p[1] - cy) / height)
|
||||
|
||||
with open(TARGET, "w", encoding="utf-8", newline="\n") as handle:
|
||||
handle.write('# coding=utf-8\n"""\nDessin du crane integre, genere par docs/extraire_crane.py '
|
||||
"a partir de\ndoc/dessin.svg (cornes retirees). Ne pas modifier a la main.\n\n"
|
||||
"Repere unite : centre du cadre en (0, 0), hauteur 1, y vers le bas.\n"
|
||||
"BODY_D : silhouette (remplie de la couleur de l'os) ;\n"
|
||||
"INK_D : trait et ombres, un seul chemin en regle non nulle.\n"
|
||||
'"""\n\n')
|
||||
handle.write("WIDTH = {:.4f}\n\n".format((max(xs) - min(xs)) / height))
|
||||
handle.write("BODY_D = (\n")
|
||||
for chunk in wrap(to_d(body, unit)):
|
||||
handle.write(" {!r}\n".format(chunk))
|
||||
handle.write(")\n\nINK_D = (\n")
|
||||
for chunk in wrap(to_d(ink, unit)):
|
||||
handle.write(" {!r}\n".format(chunk))
|
||||
handle.write(")\n")
|
||||
print("{} : {} sous-chemins d'encre".format(TARGET, len(ink)))
|
||||
|
||||
|
||||
def wrap(text, width=90):
|
||||
"""Decoupe une chaine en morceaux d'au plus `width` caracteres, sur les espaces."""
|
||||
chunks, line = [], ""
|
||||
for word in text.split(" "):
|
||||
if line and len(line) + 1 + len(word) > width:
|
||||
chunks.append(line + " ")
|
||||
line = word
|
||||
else:
|
||||
line = word if not line else line + " " + word
|
||||
if line:
|
||||
chunks.append(line)
|
||||
return chunks
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
|
After Width: | Height: | Size: 439 KiB |
@@ -0,0 +1,324 @@
|
||||
#!/usr/bin/env python3
|
||||
# coding=utf-8
|
||||
"""
|
||||
Genere le schema explicatif des parametres de l'extension.
|
||||
|
||||
python docs/schema_parametres.py # les deux versions
|
||||
python docs/schema_parametres.py fr # docs/parametres.svg + .png (README)
|
||||
python docs/schema_parametres.py en # docs/parameters_en.svg
|
||||
# + images/parameters_en.png (onglet
|
||||
# « Help » de la boite de dialogue)
|
||||
|
||||
Les formes sont calculees par skull_fill_core (memes fonctions que l'extension),
|
||||
le schema reste donc fidele au resultat reel. L'export PNG passe par
|
||||
inkscape.com, qui attend la fin de l'export (contrairement au raccourci
|
||||
Chocolatey « inkscape »).
|
||||
"""
|
||||
|
||||
import math
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
ROOT = os.path.dirname(HERE)
|
||||
sys.path.insert(0, ROOT)
|
||||
|
||||
import skull_fill_core # noqa: E402,F401
|
||||
|
||||
W, H = 1400, 1280 # 4 panneaux de 700 x 640
|
||||
|
||||
INK = "#343a40" # element principal
|
||||
GHOST = "#dde1e5" # elements secondaires / voisins
|
||||
DIM = "#d9480f" # cotes
|
||||
DIM2 = "#1971c2" # cotes secondaires
|
||||
EDGE = "#212529" # contour des formes
|
||||
FONT = "font-family:Arial,Helvetica,sans-serif"
|
||||
|
||||
INKSCAPE = [r"C:\Program Files\Inkscape\bin\inkscape.com", "/usr/bin/inkscape",
|
||||
"/Applications/Inkscape.app/Contents/MacOS/inkscape"]
|
||||
|
||||
# Version par langue : textes, fichiers produits, largeur du PNG et agrandissement
|
||||
# des textes (la version anglaise est affichee reduite dans la boite de dialogue :
|
||||
# 900 px de large, textes x 1.25 pour rester lisibles).
|
||||
VERSIONS = {
|
||||
"fr": {
|
||||
"svg": os.path.join(HERE, "parametres.svg"),
|
||||
"png": os.path.join(HERE, "parametres.png"),
|
||||
"png_width": 1400,
|
||||
"font_scale": 1.0,
|
||||
"text": {
|
||||
"title1": "Hauteur des crânes",
|
||||
"note1": ["Tailles tirées entre la plus petite et la plus grande :",
|
||||
"beaucoup de petits crânes, quelques grands par-dessus."],
|
||||
"title2": "Espacement",
|
||||
"note2": ["Pas de la grille, en % de la plus petite hauteur.",
|
||||
"Sous 100 %, les crânes se chevauchent sans laisser de vide."],
|
||||
"title3": "Inclinaison et miroir",
|
||||
"tilt": "max",
|
||||
"mirror": "miroir",
|
||||
"note3": ["Angle tiré entre -max et +max ; un crâne sur deux,",
|
||||
"au hasard, est retourné en miroir."],
|
||||
"title4": "Résultat",
|
||||
"note4": ["Seule l'encre visible est écrite : rien de caché",
|
||||
"ni de masqué, prêt pour la gravure laser."],
|
||||
},
|
||||
},
|
||||
"en": {
|
||||
"svg": os.path.join(HERE, "parameters_en.svg"),
|
||||
"png": os.path.join(ROOT, "images", "parameters_en.png"),
|
||||
"png_width": 900,
|
||||
"font_scale": 1.25,
|
||||
"text": {
|
||||
"title1": "Skull height",
|
||||
"note1": ["Sizes range from the smallest to the largest:",
|
||||
"many small skulls, a few large ones on top."],
|
||||
"title2": "Spacing",
|
||||
"note2": ["Grid step, in % of the smallest height.",
|
||||
"Below 100 %, skulls overlap and leave no gap."],
|
||||
"title3": "Tilt and mirror",
|
||||
"tilt": "max",
|
||||
"mirror": "mirror",
|
||||
"note3": ["Random angle between -max and +max;",
|
||||
"about half the skulls are mirrored."],
|
||||
"title4": "Result",
|
||||
"note4": ["Only the visible ink is written: nothing",
|
||||
"hidden or masked, ready for laser engraving."],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
def _unit(angle):
|
||||
"""Vecteur unitaire, angle en degres, sens anti-horaire a l'ecran (y vers le bas)."""
|
||||
a = math.radians(angle)
|
||||
return math.cos(a), -math.sin(a)
|
||||
|
||||
|
||||
out = []
|
||||
T = {}
|
||||
FS = 1.0
|
||||
|
||||
|
||||
def fmt(v):
|
||||
return "{:.2f}".format(v).rstrip("0").rstrip(".")
|
||||
|
||||
|
||||
def pts(polyline):
|
||||
return " ".join("{},{}".format(fmt(x), fmt(y)) for x, y in polyline)
|
||||
|
||||
|
||||
def polyline(points, color, width, extra=""):
|
||||
out.append('<polyline points="{}" fill="none" stroke="{}" stroke-width="{}" '
|
||||
'stroke-linejoin="miter" {}/>'.format(pts(points), color, fmt(width), extra))
|
||||
|
||||
|
||||
def motif(polylines, color, width):
|
||||
for pl in polylines:
|
||||
polyline(pl, color, width)
|
||||
|
||||
|
||||
def text(x, y, s, size=17, color=INK, anchor="start", weight="normal", halo=True):
|
||||
style = "{};font-size:{}px;font-weight:{};fill:{}".format(
|
||||
FONT, fmt(size * FS), weight, color)
|
||||
if halo:
|
||||
style += ";paint-order:stroke;stroke:#ffffff;stroke-width:5px;stroke-linejoin:round"
|
||||
out.append('<text x="{}" y="{}" text-anchor="{}" style="{}">{}</text>'.format(
|
||||
fmt(x), fmt(y), anchor, style, s))
|
||||
|
||||
|
||||
def note(x, y, lines):
|
||||
"""Legende de bas de panneau, derniere ligne sur la ligne de base `y`."""
|
||||
step = 22 * FS
|
||||
for k, line in enumerate(lines):
|
||||
text(x, y - (len(lines) - 1 - k) * step, line, size=16, halo=False)
|
||||
|
||||
|
||||
def arrow_head(tip, direction, color, size=9):
|
||||
ux, uy = direction
|
||||
nx, ny = -uy, ux
|
||||
base = (tip[0] - size * ux, tip[1] - size * uy)
|
||||
out.append('<polygon points="{}" fill="{}"/>'.format(pts([
|
||||
tip, (base[0] + 0.45 * size * nx, base[1] + 0.45 * size * ny),
|
||||
(base[0] - 0.45 * size * nx, base[1] - 0.45 * size * ny)]), color))
|
||||
|
||||
|
||||
def dimension(p, q, offset, label, color=DIM, label_pos=0.5, label_shift=18, size=17):
|
||||
"""Cote entre p et q, decalee de `offset` perpendiculairement."""
|
||||
dx, dy = q[0] - p[0], q[1] - p[1]
|
||||
length = math.hypot(dx, dy)
|
||||
ux, uy = dx / length, dy / length
|
||||
nx, ny = -uy, ux
|
||||
a = (p[0] + offset * nx, p[1] + offset * ny)
|
||||
b = (q[0] + offset * nx, q[1] + offset * ny)
|
||||
sign = 1 if offset >= 0 else -1
|
||||
for base, end in ((p, a), (q, b)):
|
||||
polyline([(base[0] + sign * 4 * nx, base[1] + sign * 4 * ny),
|
||||
(end[0] + sign * 6 * nx, end[1] + sign * 6 * ny)], color, 1,
|
||||
'stroke-dasharray="3,3"')
|
||||
polyline([a, b], color, 1.6)
|
||||
arrow_head(a, (-ux, -uy), color)
|
||||
arrow_head(b, (ux, uy), color)
|
||||
lx = a[0] + label_pos * (b[0] - a[0]) + sign * label_shift * FS * nx
|
||||
ly = a[1] + label_pos * (b[1] - a[1]) + sign * label_shift * FS * ny + 6 * FS
|
||||
text(lx, ly, label, size=size, color=color, anchor="middle", weight="bold")
|
||||
|
||||
|
||||
def arc(center, radius, a0, a1, color, label=None, label_radius=None, size=16):
|
||||
"""Arc de a0 a a1 degres (sens anti-horaire a l'ecran), fleche au bout."""
|
||||
steps = 40
|
||||
points = []
|
||||
for k in range(steps + 1):
|
||||
ux, uy = _unit(a0 + (a1 - a0) * k / steps)
|
||||
points.append((center[0] + radius * ux, center[1] + radius * uy))
|
||||
polyline(points[:-2], color, 1.6)
|
||||
last, before = points[-1], points[-3]
|
||||
d = math.hypot(last[0] - before[0], last[1] - before[1])
|
||||
arrow_head(last, ((last[0] - before[0]) / d, (last[1] - before[1]) / d), color, 8)
|
||||
if label:
|
||||
ux, uy = _unit((a0 + a1) / 2)
|
||||
r = label_radius or radius + 24
|
||||
text(center[0] + r * ux, center[1] + r * uy + 6 * FS, label, size=size,
|
||||
color=color, anchor="middle", weight="bold")
|
||||
|
||||
|
||||
def circle_ring(cx, cy, r, n=180):
|
||||
return [(cx + r * math.cos(2 * math.pi * k / n), cy + r * math.sin(2 * math.pi * k / n))
|
||||
for k in range(n)]
|
||||
|
||||
|
||||
def panel_title(x, y, number, title):
|
||||
text(x, y, "{} {}".format(number, title), size=22, weight="bold", halo=False)
|
||||
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Panneaux : un par parametre (ou groupe de parametres), numerotes 1 a 4.
|
||||
# Dessiner avec les vraies fonctions de skull_fill_core, puis coter avec
|
||||
# dimension() / arc() et legender avec note().
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
def skull(placement, color=EDGE, fill="#ffffff"):
|
||||
"""Crane du noyau, comme le dessine l'extension (silhouette, puis encre)."""
|
||||
body, ink = skull_fill_core.skull_paths(placement)
|
||||
if fill != "none":
|
||||
out.append('<path d="{}" fill="{}"/>'.format(body, fill))
|
||||
out.append('<path d="{}" fill="{}"/>'.format(ink, color))
|
||||
|
||||
|
||||
def dot(x, y, color=DIM):
|
||||
out.append('<circle cx="{}" cy="{}" r="4" fill="{}"/>'.format(fmt(x), fmt(y), color))
|
||||
|
||||
|
||||
def panel_1():
|
||||
panel_title(30, 50, 1, T["title1"])
|
||||
small, big = 130, 330
|
||||
skull((190, 345, small, 0, False))
|
||||
skull((450, 330, big, 0, False))
|
||||
x = 190 - 0.42 * small
|
||||
dimension((x, 345 - small / 2), (x, 345 + small / 2), 22, "min", label_shift=30)
|
||||
x = 450 + 0.42 * big
|
||||
dimension((x, 330 - big / 2), (x, 330 + big / 2), -22, "max", label_shift=30)
|
||||
note(30, 610, T["note1"])
|
||||
|
||||
|
||||
def panel_2():
|
||||
panel_title(730, 50, 2, T["title2"])
|
||||
h, step = 120, 0.7 * 120
|
||||
rows = []
|
||||
for j, y in enumerate((330, 330 + 0.866 * step)):
|
||||
for i in range(4):
|
||||
rows.append((870 + (i + 0.5 * j) * step, y, h, 0, False))
|
||||
for placement in reversed(rows):
|
||||
skull(placement)
|
||||
for x, y, _h, _a, _m in rows:
|
||||
dot(x, y)
|
||||
dimension((rows[0][0], rows[0][1]), (rows[1][0], rows[1][1]), -95,
|
||||
"70 %", label_shift=16)
|
||||
note(730, 610, T["note2"])
|
||||
|
||||
|
||||
def panel_3():
|
||||
panel_title(30, 690, 3, T["title3"])
|
||||
c, h, angle = (220, 960), 280, 25
|
||||
skull((c[0], c[1], h, 0, False), color=GHOST, fill="none")
|
||||
skull((c[0], c[1], h, angle, False))
|
||||
top = 175
|
||||
polyline([c, (c[0], c[1] - top)], DIM2, 1.2, 'stroke-dasharray="5,4"')
|
||||
ux, uy = _unit(90 - angle)
|
||||
polyline([c, (c[0] + top * ux, c[1] + top * uy)], DIM2, 1.2, 'stroke-dasharray="5,4"')
|
||||
arc(c, 165, 90, 90 - angle, DIM2, T["tilt"], label_radius=190)
|
||||
skull((470, 960, 140, 0, False))
|
||||
skull((620, 960, 140, 0, True))
|
||||
y = 1060
|
||||
polyline([(500, y), (590, y)], DIM, 1.6)
|
||||
arrow_head((500, y), (-1, 0), DIM)
|
||||
arrow_head((590, y), (1, 0), DIM)
|
||||
text(545, y + 28, T["mirror"], size=17, color=DIM, anchor="middle", weight="bold")
|
||||
note(30, 1250, T["note3"])
|
||||
|
||||
|
||||
def panel_4():
|
||||
panel_title(730, 690, 4, T["title4"])
|
||||
cx, cy, r = 1050, 950, 225
|
||||
ring = circle_ring(cx, cy, r)
|
||||
region = skull_fill_core.Region([ring])
|
||||
placements = skull_fill_core.skull_placements([ring], 45, 140, seed=2)
|
||||
# Exactement ce qu'ecrit l'extension : l'encre visible, les interstices,
|
||||
# rien d'autre (pas de blanc, pas de masque).
|
||||
gaps = skull_fill_core.visible_gaps(placements, region)
|
||||
out.append('<path d="{}" fill="{}" fill-rule="evenodd"/>'.format(
|
||||
skull_fill_core.rings_to_d(gaps), EDGE))
|
||||
for _placement, rings in skull_fill_core.visible_skulls(placements, region):
|
||||
out.append('<path d="{}" fill="{}" fill-rule="evenodd"/>'.format(
|
||||
skull_fill_core.rings_to_d(rings), EDGE))
|
||||
out.append('<circle cx="{}" cy="{}" r="{}" fill="none" stroke="{}" stroke-width="2" '
|
||||
'stroke-dasharray="8,5"/>'.format(cx, cy, r + 6, DIM2))
|
||||
note(730, 1250, T["note4"])
|
||||
|
||||
|
||||
def export_png(svg_path, png_path, width):
|
||||
exe = next((path for path in INKSCAPE if os.path.exists(path)), None)
|
||||
if exe is None:
|
||||
print("Inkscape introuvable : exporter {} a la main".format(svg_path))
|
||||
return
|
||||
os.makedirs(os.path.dirname(png_path), exist_ok=True)
|
||||
subprocess.run([exe, svg_path, "--export-type=png",
|
||||
"--export-width={}".format(width),
|
||||
"--export-filename={}".format(png_path)],
|
||||
check=True, stderr=subprocess.DEVNULL)
|
||||
print(png_path)
|
||||
|
||||
|
||||
def build(language):
|
||||
global FS
|
||||
version = VERSIONS[language]
|
||||
out.clear()
|
||||
T.clear()
|
||||
T.update(version["text"])
|
||||
FS = version["font_scale"]
|
||||
|
||||
out.append('<rect width="{}" height="{}" fill="#ffffff"/>'.format(W, H))
|
||||
for x1, y1, x2, y2 in ((700, 20, 700, H - 20), (20, 640, W - 20, 640)):
|
||||
out.append('<line x1="{}" y1="{}" x2="{}" y2="{}" stroke="#dee2e6" '
|
||||
'stroke-width="1.5"/>'.format(x1, y1, x2, y2))
|
||||
panel_1()
|
||||
panel_2()
|
||||
panel_3()
|
||||
panel_4()
|
||||
svg = ('<?xml version="1.0" encoding="UTF-8"?>\n'
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" width="{0}" height="{1}" '
|
||||
'viewBox="0 0 {0} {1}">\n{2}\n</svg>\n').format(W, H, "\n".join(out))
|
||||
with open(version["svg"], "w", encoding="utf-8", newline="\n") as handle:
|
||||
handle.write(svg)
|
||||
print(version["svg"])
|
||||
export_png(version["svg"], version["png"], version["png_width"])
|
||||
|
||||
|
||||
def main(argv):
|
||||
languages = argv or sorted(VERSIONS)
|
||||
for language in languages:
|
||||
build(language)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1:])
|
||||
@@ -0,0 +1,304 @@
|
||||
#!/usr/bin/env python3
|
||||
# coding=utf-8
|
||||
"""
|
||||
Chaine de traduction de l'extension, sans dependance a gettext.
|
||||
|
||||
python i18n.py # extract + update + compile
|
||||
python i18n.py extract # po/<domaine>.pot depuis le .inx et les .py
|
||||
python i18n.py update # reporte le modele dans po/<langue>.po
|
||||
python i18n.py compile # po/<langue>.po -> locale/<langue>/LC_MESSAGES/*.mo
|
||||
|
||||
Le domaine est lu dans l'attribut translationdomain du .inx ; les sources sont
|
||||
le .inx et tous les .py du dossier (hors i18n.py et tests).
|
||||
|
||||
Les textes source (.inx et appels _() des .py) sont en anglais : c'est ce
|
||||
qu'Inkscape affiche pour une langue sans catalogue. Le catalogue anglais est
|
||||
rempli automatiquement avec les textes source ; seul fr.po se traduit a la main.
|
||||
|
||||
Les chaines retenues dans le .inx suivent les regles d'Inkscape (inx.its) :
|
||||
<name>, attributs gui-text et gui-description, contenu de <option>, <item> et
|
||||
<label>, sauf translatable="no". Les espaces sont normalises, sauf sous
|
||||
xml:space="preserve".
|
||||
"""
|
||||
|
||||
import ast
|
||||
import os
|
||||
import re
|
||||
import struct
|
||||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
LANGUAGES = ["en", "fr"]
|
||||
SOURCE_LANGUAGE = "en"
|
||||
PO_DIR = os.path.join(HERE, "po")
|
||||
LOCALE_DIR = os.path.join(HERE, "locale")
|
||||
|
||||
XML_SPACE = "{http://www.w3.org/XML/1998/namespace}space"
|
||||
INX_NS = "{http://www.inkscape.org/namespace/inkscape/extension}"
|
||||
|
||||
|
||||
def _find_inx():
|
||||
found = sorted(name for name in os.listdir(HERE) if name.endswith(".inx"))
|
||||
if len(found) != 1:
|
||||
sys.exit("i18n.py attend un seul fichier .inx dans {} (trouve : {})".format(
|
||||
HERE, found))
|
||||
return found[0]
|
||||
|
||||
|
||||
INX = _find_inx()
|
||||
_INX_ROOT = ET.parse(os.path.join(HERE, INX)).getroot()
|
||||
DOMAIN = _INX_ROOT.get("translationdomain")
|
||||
if not DOMAIN:
|
||||
sys.exit("Attribut translationdomain absent de " + INX)
|
||||
EXTENSION_NAME = (_INX_ROOT.findtext(INX_NS + "name") or DOMAIN).strip()
|
||||
SOURCES = [INX] + sorted(
|
||||
name for name in os.listdir(HERE)
|
||||
if name.endswith(".py") and name != "i18n.py" and not name.startswith("test"))
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Extraction
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
def _local(tag):
|
||||
return tag.rsplit("}", 1)[-1]
|
||||
|
||||
|
||||
def _normalize(text, preserve):
|
||||
return text if preserve else " ".join(text.split())
|
||||
|
||||
|
||||
def extract_inx(path):
|
||||
"""Chaines traduisibles d'un fichier .inx, dans l'ordre du document."""
|
||||
messages = []
|
||||
|
||||
def walk(elem, preserve):
|
||||
preserve = elem.get(XML_SPACE, "preserve" if preserve else "default") == "preserve"
|
||||
if elem.get("translatable") != "no":
|
||||
for attr in ("gui-text", "gui-description"):
|
||||
if elem.get(attr):
|
||||
messages.append(_normalize(elem.get(attr), preserve))
|
||||
if _local(elem.tag) in ("name", "option", "item", "label") and elem.text:
|
||||
messages.append(_normalize(elem.text, preserve))
|
||||
for child in elem:
|
||||
walk(child, preserve)
|
||||
|
||||
walk(ET.parse(path).getroot(), False)
|
||||
return [m for m in messages if m]
|
||||
|
||||
|
||||
def extract_py(path):
|
||||
"""Arguments litteraux des appels _("...") d'un script Python."""
|
||||
with open(path, encoding="utf-8") as handle:
|
||||
tree = ast.parse(handle.read(), path)
|
||||
calls = [node for node in ast.walk(tree)
|
||||
if isinstance(node, ast.Call) and isinstance(node.func, ast.Name)
|
||||
and node.func.id == "_" and len(node.args) == 1
|
||||
and isinstance(node.args[0], ast.Constant)
|
||||
and isinstance(node.args[0].value, str)]
|
||||
calls.sort(key=lambda node: (node.lineno, node.col_offset))
|
||||
return [node.args[0].value for node in calls]
|
||||
|
||||
|
||||
def extract():
|
||||
"""Liste ordonnee et sans doublon de (msgid, [fichiers sources])."""
|
||||
found = {}
|
||||
for name in SOURCES:
|
||||
path = os.path.join(HERE, name)
|
||||
strings = extract_inx(path) if name.endswith(".inx") else extract_py(path)
|
||||
for msgid in strings:
|
||||
found.setdefault(msgid, [])
|
||||
if name not in found[msgid]:
|
||||
found[msgid].append(name)
|
||||
return list(found.items())
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Lecture / ecriture des fichiers .po
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
_ESCAPES = {"n": "\n", "t": "\t", '"': '"', "\\": "\\"}
|
||||
|
||||
|
||||
def _unquote(line):
|
||||
body = line.strip()[1:-1]
|
||||
return re.sub(r'\\(.)', lambda m: _ESCAPES.get(m.group(1), m.group(1)), body)
|
||||
|
||||
|
||||
def _quote(text):
|
||||
text = text.replace("\\", "\\\\").replace('"', '\\"').replace("\t", "\\t")
|
||||
lines = text.split("\n")
|
||||
parts = [line + "\\n" for line in lines[:-1]]
|
||||
if lines[-1]:
|
||||
parts.append(lines[-1])
|
||||
if len(parts) <= 1:
|
||||
return '"{}"'.format(parts[0] if parts else "")
|
||||
return '""\n' + "\n".join('"{}"'.format(part) for part in parts)
|
||||
|
||||
|
||||
def read_po(path):
|
||||
"""Dictionnaire msgid -> (msgstr, fuzzy). L'en-tete a pour cle ""."""
|
||||
entries = {}
|
||||
if not os.path.exists(path):
|
||||
return entries
|
||||
msgid = msgstr = None
|
||||
field = None
|
||||
fuzzy = False
|
||||
|
||||
def flush():
|
||||
if msgid is not None:
|
||||
entries[msgid] = (msgstr or "", fuzzy)
|
||||
|
||||
with open(path, encoding="utf-8") as handle:
|
||||
for raw in handle:
|
||||
line = raw.strip()
|
||||
if line.startswith("#,") and "fuzzy" in line:
|
||||
flush()
|
||||
msgid = msgstr = field = None
|
||||
fuzzy = True
|
||||
elif line.startswith("msgid "):
|
||||
if field == "msgstr":
|
||||
flush()
|
||||
fuzzy = False
|
||||
msgid, msgstr, field = _unquote(line[6:]), None, "msgid"
|
||||
elif line.startswith("msgstr "):
|
||||
msgstr, field = _unquote(line[7:]), "msgstr"
|
||||
elif line.startswith('"') and field == "msgid":
|
||||
msgid += _unquote(line)
|
||||
elif line.startswith('"') and field == "msgstr":
|
||||
msgstr += _unquote(line)
|
||||
elif not line and field == "msgstr":
|
||||
flush()
|
||||
msgid = msgstr = field = None
|
||||
fuzzy = False
|
||||
flush()
|
||||
return entries
|
||||
|
||||
|
||||
def _header(language):
|
||||
fields = [
|
||||
("Project-Id-Version", DOMAIN),
|
||||
("Language", language or ""),
|
||||
("MIME-Version", "1.0"),
|
||||
("Content-Type", "text/plain; charset=UTF-8"),
|
||||
("Content-Transfer-Encoding", "8bit"),
|
||||
("Plural-Forms", {"fr": "nplurals=2; plural=(n > 1);",
|
||||
"en": "nplurals=2; plural=(n != 1);"}.get(language, "")),
|
||||
]
|
||||
return "".join("{}: {}\n".format(key, value) for key, value in fields if value)
|
||||
|
||||
|
||||
def write_po(path, language, messages, translations):
|
||||
title = ("Modele de traduction" if language is None
|
||||
else "Traduction ({})".format(language))
|
||||
out = ["# {} de l'extension Inkscape « {} ».".format(title, EXTENSION_NAME),
|
||||
"# Genere par i18n.py ; ne modifier que les msgstr.",
|
||||
"msgid \"\"",
|
||||
"msgstr " + _quote(_header(language)),
|
||||
""]
|
||||
for msgid, refs in messages:
|
||||
msgstr, fuzzy = translations.get(msgid, ("", False))
|
||||
out.append("#: " + " ".join(refs))
|
||||
if fuzzy:
|
||||
out.append("#, fuzzy")
|
||||
out.append("msgid " + _quote(msgid))
|
||||
out.append("msgstr " + _quote(msgstr))
|
||||
out.append("")
|
||||
with open(path, "w", encoding="utf-8", newline="\n") as handle:
|
||||
handle.write("\n".join(out))
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Compilation .mo (format GNU gettext)
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
def write_mo(path, catalog):
|
||||
"""Ecrit un catalogue {msgid: msgstr} au format .mo, cles triees."""
|
||||
keys = sorted(catalog)
|
||||
ids = [key.encode("utf-8") for key in keys]
|
||||
strs = [catalog[key].encode("utf-8") for key in keys]
|
||||
count = len(keys)
|
||||
ids_start = 7 * 4 + 16 * count
|
||||
strs_start = ids_start + sum(len(b) + 1 for b in ids)
|
||||
|
||||
table_ids, table_strs = [], []
|
||||
offset = ids_start
|
||||
for data in ids:
|
||||
table_ids += [len(data), offset]
|
||||
offset += len(data) + 1
|
||||
offset = strs_start
|
||||
for data in strs:
|
||||
table_strs += [len(data), offset]
|
||||
offset += len(data) + 1
|
||||
|
||||
output = struct.pack("<7I", 0x950412DE, 0, count, 7 * 4, 7 * 4 + 8 * count, 0, 0)
|
||||
output += struct.pack("<{}I".format(2 * count), *table_ids)
|
||||
output += struct.pack("<{}I".format(2 * count), *table_strs)
|
||||
output += b"".join(data + b"\0" for data in ids)
|
||||
output += b"".join(data + b"\0" for data in strs)
|
||||
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
with open(path, "wb") as handle:
|
||||
handle.write(output)
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Commandes
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
def po_path(language):
|
||||
return os.path.join(PO_DIR, "{}.po".format(language))
|
||||
|
||||
|
||||
def mo_path(language):
|
||||
return os.path.join(LOCALE_DIR, language, "LC_MESSAGES", DOMAIN + ".mo")
|
||||
|
||||
|
||||
def cmd_extract():
|
||||
os.makedirs(PO_DIR, exist_ok=True)
|
||||
messages = extract()
|
||||
write_po(os.path.join(PO_DIR, DOMAIN + ".pot"), None, messages, {})
|
||||
print("{} chaines -> po/{}.pot".format(len(messages), DOMAIN))
|
||||
|
||||
|
||||
def cmd_update():
|
||||
messages = extract()
|
||||
for language in LANGUAGES:
|
||||
translations = read_po(po_path(language))
|
||||
if language == SOURCE_LANGUAGE:
|
||||
translations = {msgid: (msgid, False) for msgid, _refs in messages}
|
||||
write_po(po_path(language), language, messages, translations)
|
||||
missing = [m for m, _r in messages if not translations.get(m, ("", False))[0]]
|
||||
print("po/{}.po : {} a traduire".format(language, len(missing)))
|
||||
for msgid in missing:
|
||||
print(" " + msgid.splitlines()[0])
|
||||
|
||||
|
||||
def cmd_compile():
|
||||
for language in LANGUAGES:
|
||||
entries = read_po(po_path(language))
|
||||
catalog = {msgid: msgstr for msgid, (msgstr, fuzzy) in entries.items()
|
||||
if msgid and msgstr and not fuzzy}
|
||||
catalog[""] = _header(language)
|
||||
write_mo(mo_path(language), catalog)
|
||||
print("{} -> {} ({} chaines)".format(
|
||||
os.path.relpath(po_path(language), HERE),
|
||||
os.path.relpath(mo_path(language), HERE), len(catalog) - 1))
|
||||
|
||||
|
||||
def main(argv):
|
||||
commands = {"extract": [cmd_extract], "update": [cmd_update],
|
||||
"compile": [cmd_compile],
|
||||
"all": [cmd_extract, cmd_update, cmd_compile]}
|
||||
name = argv[0] if argv else "all"
|
||||
if name not in commands:
|
||||
print(__doc__)
|
||||
return 1
|
||||
for command in commands[name]:
|
||||
command()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
|
After Width: | Height: | Size: 248 KiB |
@@ -0,0 +1,120 @@
|
||||
# Traduction (en) de l'extension Inkscape « Skull Pattern Fill ».
|
||||
# Genere par i18n.py ; ne modifier que les msgstr.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: skullfill\n"
|
||||
"Language: en\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Skull Pattern Fill"
|
||||
msgstr "Skull Pattern Fill"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Skulls"
|
||||
msgstr "Skulls"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Largest skull height:"
|
||||
msgstr "Largest skull height:"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Smallest skull height:"
|
||||
msgstr "Smallest skull height:"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Unit:"
|
||||
msgstr "Unit:"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Spacing (% of the smallest height):"
|
||||
msgstr "Spacing (% of the smallest height):"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Distance between two neighbouring skulls. Below 100 %, skulls overlap and leave no gap."
|
||||
msgstr "Distance between two neighbouring skulls. Below 100 %, skulls overlap and leave no gap."
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Maximum tilt (°):"
|
||||
msgstr "Maximum tilt (°):"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Each skull is tilted by a random angle between minus and plus this value."
|
||||
msgstr "Each skull is tilted by a random angle between minus and plus this value."
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Randomly mirror skulls"
|
||||
msgstr "Randomly mirror skulls"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Random seed:"
|
||||
msgstr "Random seed:"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Change it to get another arrangement with the same settings."
|
||||
msgstr "Change it to get another arrangement with the same settings."
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Style"
|
||||
msgstr "Style"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Ink color:"
|
||||
msgstr "Ink color:"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Fill the gaps with the ink color"
|
||||
msgstr "Fill the gaps with the ink color"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Keep the original shape"
|
||||
msgstr "Keep the original shape"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Help"
|
||||
msgstr "Help"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid ""
|
||||
"Select one or more shapes (paths, rectangles, circles, ellipses or groups of them), then run the extension. Each shape is filled with skulls of different sizes, tilted and mirrored at random, cut to the outline of the shape.\n"
|
||||
"\n"
|
||||
"Skull heights range from the smallest to the largest: there are many small skulls and a few large ones, drawn on top. The spacing sets how tightly they are packed; below 100 % they overlap and cover the whole shape.\n"
|
||||
"\n"
|
||||
"The result is made for laser engraving: it contains only the ink that is actually visible. Lines hidden by the skulls on top are removed and skulls on the edge are trimmed; no mask, clone or white object is written, so the laser engraves nothing hidden.\n"
|
||||
"\n"
|
||||
"The result is a group of filled paths placed just above each shape. Large fills take time, about 5 seconds per 100 skulls. Change the random seed to get another arrangement."
|
||||
msgstr ""
|
||||
"Select one or more shapes (paths, rectangles, circles, ellipses or groups of them), then run the extension. Each shape is filled with skulls of different sizes, tilted and mirrored at random, cut to the outline of the shape.\n"
|
||||
"\n"
|
||||
"Skull heights range from the smallest to the largest: there are many small skulls and a few large ones, drawn on top. The spacing sets how tightly they are packed; below 100 % they overlap and cover the whole shape.\n"
|
||||
"\n"
|
||||
"The result is made for laser engraving: it contains only the ink that is actually visible. Lines hidden by the skulls on top are removed and skulls on the edge are trimmed; no mask, clone or white object is written, so the laser engraves nothing hidden.\n"
|
||||
"\n"
|
||||
"The result is a group of filled paths placed just above each shape. Large fills take time, about 5 seconds per 100 skulls. Change the random seed to get another arrangement."
|
||||
|
||||
#: skull_fill.py
|
||||
msgid "Select at least one shape to fill."
|
||||
msgstr "Select at least one shape to fill."
|
||||
|
||||
#: skull_fill.py
|
||||
msgid "No fillable shape in the selection: select paths, rectangles, circles, ellipses or groups of them."
|
||||
msgstr "No fillable shape in the selection: select paths, rectangles, circles, ellipses or groups of them."
|
||||
|
||||
#: skull_fill.py
|
||||
msgid "The skull sizes must be strictly positive."
|
||||
msgstr "The skull sizes must be strictly positive."
|
||||
|
||||
#: skull_fill.py
|
||||
msgid "About {} skulls would be needed. Increase the minimum size or the spacing."
|
||||
msgstr "About {} skulls would be needed. Increase the minimum size or the spacing."
|
||||
|
||||
#: skull_fill.py
|
||||
msgid "Skull fill"
|
||||
msgstr "Skull fill"
|
||||
|
||||
#: skull_fill.py
|
||||
msgid "Gaps"
|
||||
msgstr "Gaps"
|
||||
@@ -0,0 +1,120 @@
|
||||
# Traduction (fr) de l'extension Inkscape « Skull Pattern Fill ».
|
||||
# Genere par i18n.py ; ne modifier que les msgstr.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: skullfill\n"
|
||||
"Language: fr\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Skull Pattern Fill"
|
||||
msgstr "Remplissage têtes de mort"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Skulls"
|
||||
msgstr "Crânes"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Largest skull height:"
|
||||
msgstr "Hauteur du plus grand crâne :"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Smallest skull height:"
|
||||
msgstr "Hauteur du plus petit crâne :"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Unit:"
|
||||
msgstr "Unité :"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Spacing (% of the smallest height):"
|
||||
msgstr "Espacement (% de la plus petite hauteur) :"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Distance between two neighbouring skulls. Below 100 %, skulls overlap and leave no gap."
|
||||
msgstr "Distance entre deux crânes voisins. En dessous de 100 %, les crânes se chevauchent et ne laissent aucun vide."
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Maximum tilt (°):"
|
||||
msgstr "Inclinaison maximale (°) :"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Each skull is tilted by a random angle between minus and plus this value."
|
||||
msgstr "Chaque crâne est incliné d'un angle tiré au hasard entre moins et plus cette valeur."
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Randomly mirror skulls"
|
||||
msgstr "Retourner des crânes en miroir au hasard"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Random seed:"
|
||||
msgstr "Graine aléatoire :"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Change it to get another arrangement with the same settings."
|
||||
msgstr "La changer donne une autre disposition avec les mêmes réglages."
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Style"
|
||||
msgstr "Style"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Ink color:"
|
||||
msgstr "Couleur de l'encre :"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Fill the gaps with the ink color"
|
||||
msgstr "Remplir les interstices de la couleur de l'encre"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Keep the original shape"
|
||||
msgstr "Conserver la forme d'origine"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Help"
|
||||
msgstr "Aide"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid ""
|
||||
"Select one or more shapes (paths, rectangles, circles, ellipses or groups of them), then run the extension. Each shape is filled with skulls of different sizes, tilted and mirrored at random, cut to the outline of the shape.\n"
|
||||
"\n"
|
||||
"Skull heights range from the smallest to the largest: there are many small skulls and a few large ones, drawn on top. The spacing sets how tightly they are packed; below 100 % they overlap and cover the whole shape.\n"
|
||||
"\n"
|
||||
"The result is made for laser engraving: it contains only the ink that is actually visible. Lines hidden by the skulls on top are removed and skulls on the edge are trimmed; no mask, clone or white object is written, so the laser engraves nothing hidden.\n"
|
||||
"\n"
|
||||
"The result is a group of filled paths placed just above each shape. Large fills take time, about 5 seconds per 100 skulls. Change the random seed to get another arrangement."
|
||||
msgstr ""
|
||||
"Sélectionnez une ou plusieurs formes (chemins, rectangles, cercles, ellipses ou groupes de ceux-ci), puis lancez l'extension. Chaque forme est remplie de crânes de tailles différentes, inclinés et retournés au hasard, découpés au contour de la forme.\n"
|
||||
"\n"
|
||||
"La hauteur des crânes va de la plus petite à la plus grande : beaucoup de petits crânes, quelques grands, dessinés par-dessus. L'espacement règle leur densité ; en dessous de 100 %, ils se chevauchent et couvrent toute la forme.\n"
|
||||
"\n"
|
||||
"Le résultat est prévu pour la gravure laser : il ne contient que l'encre réellement visible. Les traits cachés par les crânes du dessus sont supprimés et les crânes du bord sont coupés ; aucun masque, clone ni objet blanc n'est écrit, le laser ne grave donc rien de caché.\n"
|
||||
"\n"
|
||||
"Le résultat est un groupe de chemins remplis, placé juste au-dessus de chaque forme. Un grand remplissage prend du temps, environ 5 secondes pour 100 crânes. Changez la graine aléatoire pour obtenir une autre disposition."
|
||||
|
||||
#: skull_fill.py
|
||||
msgid "Select at least one shape to fill."
|
||||
msgstr "Sélectionnez au moins une forme à remplir."
|
||||
|
||||
#: skull_fill.py
|
||||
msgid "No fillable shape in the selection: select paths, rectangles, circles, ellipses or groups of them."
|
||||
msgstr "Aucune forme à remplir dans la sélection : sélectionnez des chemins, rectangles, cercles, ellipses ou des groupes de ceux-ci."
|
||||
|
||||
#: skull_fill.py
|
||||
msgid "The skull sizes must be strictly positive."
|
||||
msgstr "Les tailles des crânes doivent être strictement positives."
|
||||
|
||||
#: skull_fill.py
|
||||
msgid "About {} skulls would be needed. Increase the minimum size or the spacing."
|
||||
msgstr "Il faudrait environ {} crânes. Augmentez la plus petite taille ou l'espacement."
|
||||
|
||||
#: skull_fill.py
|
||||
msgid "Skull fill"
|
||||
msgstr "Remplissage têtes de mort"
|
||||
|
||||
#: skull_fill.py
|
||||
msgid "Gaps"
|
||||
msgstr "Interstices"
|
||||
@@ -0,0 +1,111 @@
|
||||
# Modele de traduction de l'extension Inkscape « Skull Pattern Fill ».
|
||||
# Genere par i18n.py ; ne modifier que les msgstr.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: skullfill\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Skull Pattern Fill"
|
||||
msgstr ""
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Skulls"
|
||||
msgstr ""
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Largest skull height:"
|
||||
msgstr ""
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Smallest skull height:"
|
||||
msgstr ""
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Unit:"
|
||||
msgstr ""
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Spacing (% of the smallest height):"
|
||||
msgstr ""
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Distance between two neighbouring skulls. Below 100 %, skulls overlap and leave no gap."
|
||||
msgstr ""
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Maximum tilt (°):"
|
||||
msgstr ""
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Each skull is tilted by a random angle between minus and plus this value."
|
||||
msgstr ""
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Randomly mirror skulls"
|
||||
msgstr ""
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Random seed:"
|
||||
msgstr ""
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Change it to get another arrangement with the same settings."
|
||||
msgstr ""
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Style"
|
||||
msgstr ""
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Ink color:"
|
||||
msgstr ""
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Fill the gaps with the ink color"
|
||||
msgstr ""
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Keep the original shape"
|
||||
msgstr ""
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid "Help"
|
||||
msgstr ""
|
||||
|
||||
#: skull_fill.inx
|
||||
msgid ""
|
||||
"Select one or more shapes (paths, rectangles, circles, ellipses or groups of them), then run the extension. Each shape is filled with skulls of different sizes, tilted and mirrored at random, cut to the outline of the shape.\n"
|
||||
"\n"
|
||||
"Skull heights range from the smallest to the largest: there are many small skulls and a few large ones, drawn on top. The spacing sets how tightly they are packed; below 100 % they overlap and cover the whole shape.\n"
|
||||
"\n"
|
||||
"The result is made for laser engraving: it contains only the ink that is actually visible. Lines hidden by the skulls on top are removed and skulls on the edge are trimmed; no mask, clone or white object is written, so the laser engraves nothing hidden.\n"
|
||||
"\n"
|
||||
"The result is a group of filled paths placed just above each shape. Large fills take time, about 5 seconds per 100 skulls. Change the random seed to get another arrangement."
|
||||
msgstr ""
|
||||
|
||||
#: skull_fill.py
|
||||
msgid "Select at least one shape to fill."
|
||||
msgstr ""
|
||||
|
||||
#: skull_fill.py
|
||||
msgid "No fillable shape in the selection: select paths, rectangles, circles, ellipses or groups of them."
|
||||
msgstr ""
|
||||
|
||||
#: skull_fill.py
|
||||
msgid "The skull sizes must be strictly positive."
|
||||
msgstr ""
|
||||
|
||||
#: skull_fill.py
|
||||
msgid "About {} skulls would be needed. Increase the minimum size or the spacing."
|
||||
msgstr ""
|
||||
|
||||
#: skull_fill.py
|
||||
msgid "Skull fill"
|
||||
msgstr ""
|
||||
|
||||
#: skull_fill.py
|
||||
msgid "Gaps"
|
||||
msgstr ""
|
||||
@@ -0,0 +1,407 @@
|
||||
# coding=utf-8
|
||||
"""
|
||||
Dessin du crane integre, genere par docs/extraire_crane.py a partir de
|
||||
doc/dessin.svg (cornes retirees). Ne pas modifier a la main.
|
||||
|
||||
Repere unite : centre du cadre en (0, 0), hauteur 1, y vers le bas.
|
||||
BODY_D : silhouette (remplie de la couleur de l'os) ;
|
||||
INK_D : trait et ombres, un seul chemin en regle non nulle.
|
||||
"""
|
||||
|
||||
WIDTH = 0.7969
|
||||
|
||||
BODY_D = (
|
||||
'M -0.2284,0.4864 C -0.2284,0.4864 -0.2426,0.4729 -0.2426,0.4729 C -0.2426,0.4729 '
|
||||
'-0.2434,0.4343 -0.2434,0.4343 C -0.2440,0.4023 -0.2454,0.3911 -0.2517,0.3681 C '
|
||||
'-0.2559,0.3529 -0.2597,0.3347 -0.2601,0.3276 C -0.2605,0.3198 -0.2631,0.3116 '
|
||||
'-0.2665,0.3068 C -0.2706,0.3013 -0.2728,0.2928 -0.2741,0.2782 C -0.2751,0.2668 '
|
||||
'-0.2775,0.2556 -0.2795,0.2534 C -0.2818,0.2507 -0.2829,0.2422 -0.2827,0.2299 C '
|
||||
'-0.2822,0.2091 -0.2855,0.2001 -0.2982,0.1863 C -0.3051,0.1789 -0.3061,0.1787 '
|
||||
'-0.3353,0.1787 C -0.3353,0.1787 -0.3652,0.1787 -0.3652,0.1787 C -0.3652,0.1787 '
|
||||
'-0.3810,0.1482 -0.3810,0.1482 C -0.3897,0.1315 -0.3968,0.1147 -0.3968,0.1111 C '
|
||||
'-0.3968,0.1074 -0.3928,0.0928 -0.3879,0.0786 C -0.3797,0.0551 -0.3789,0.0500 '
|
||||
'-0.3789,0.0197 C -0.3788,-0.0126 -0.3791,-0.0140 -0.3886,-0.0340 C -0.3886,-0.0340 '
|
||||
'-0.3984,-0.0546 -0.3984,-0.0546 C -0.3984,-0.0546 -0.3854,-0.0800 -0.3854,-0.0800 C '
|
||||
'-0.3714,-0.1073 -0.3711,-0.1089 -0.3667,-0.1698 C -0.3622,-0.2309 -0.3480,-0.2774 '
|
||||
'-0.3193,-0.3248 C -0.2995,-0.3519 -0.2780,-0.3780 -0.2518,-0.3994 C -0.2256,-0.4207 '
|
||||
'-0.1979,-0.4405 -0.1670,-0.4546 C -0.1313,-0.4711 -0.0891,-0.4856 -0.0520,-0.4939 C '
|
||||
'-0.0291,-0.4991 -0.0166,-0.5000 0.0290,-0.5000 C 0.1038,-0.4999 0.1503,-0.4907 '
|
||||
'0.2108,-0.4638 C 0.2426,-0.4453 0.2713,-0.4223 0.2973,-0.3964 C 0.3232,-0.3705 '
|
||||
'0.3451,-0.3410 0.3636,-0.3094 C 0.3882,-0.2546 0.3984,-0.1987 0.3958,-0.1338 C '
|
||||
'0.3934,-0.0764 0.3839,-0.0378 0.3590,0.0155 C 0.3443,0.0471 0.3344,0.0631 0.3137,0.0892 C '
|
||||
'0.3051,0.1000 0.2954,0.1143 0.2922,0.1210 C 0.2786,0.1488 0.2439,0.1787 0.2251,0.1787 C '
|
||||
'0.2222,0.1787 0.2196,0.1790 0.2194,0.1794 C 0.2192,0.1798 0.2183,0.2050 0.2174,0.2354 C '
|
||||
'0.2174,0.2354 0.2157,0.2907 0.2157,0.2907 C 0.2157,0.2907 0.1752,0.3211 0.1752,0.3211 C '
|
||||
'0.1529,0.3378 0.1272,0.3586 0.1179,0.3672 C 0.1087,0.3758 0.0792,0.3982 0.0523,0.4169 C '
|
||||
'0.0255,0.4357 -0.0103,0.4621 -0.0272,0.4755 C -0.0272,0.4755 -0.0579,0.5000 -0.0579,0.5000 '
|
||||
'C -0.0579,0.5000 -0.0787,0.4979 -0.0787,0.4979 C -0.1024,0.4955 -0.1883,0.4958 '
|
||||
'-0.2039,0.4983 C -0.2134,0.4998 -0.2153,0.4989 -0.2284,0.4864 C -0.2284,0.4864 '
|
||||
'-0.2284,0.4864 -0.2284,0.4864 Z'
|
||||
)
|
||||
|
||||
INK_D = (
|
||||
'M -0.2284,0.4864 C -0.2284,0.4864 -0.2426,0.4729 -0.2426,0.4729 C -0.2426,0.4729 '
|
||||
'-0.2434,0.4343 -0.2434,0.4343 C -0.2440,0.4023 -0.2454,0.3911 -0.2517,0.3681 C '
|
||||
'-0.2559,0.3529 -0.2597,0.3347 -0.2601,0.3276 C -0.2605,0.3198 -0.2631,0.3116 '
|
||||
'-0.2665,0.3068 C -0.2706,0.3013 -0.2728,0.2928 -0.2741,0.2782 C -0.2751,0.2668 '
|
||||
'-0.2775,0.2556 -0.2795,0.2534 C -0.2818,0.2507 -0.2829,0.2422 -0.2827,0.2299 C '
|
||||
'-0.2822,0.2091 -0.2855,0.2001 -0.2982,0.1863 C -0.3051,0.1789 -0.3061,0.1787 '
|
||||
'-0.3353,0.1787 C -0.3353,0.1787 -0.3652,0.1787 -0.3652,0.1787 C -0.3652,0.1787 '
|
||||
'-0.3810,0.1482 -0.3810,0.1482 C -0.3897,0.1315 -0.3968,0.1147 -0.3968,0.1111 C '
|
||||
'-0.3968,0.1074 -0.3928,0.0928 -0.3879,0.0786 C -0.3797,0.0551 -0.3789,0.0500 '
|
||||
'-0.3789,0.0197 C -0.3788,-0.0126 -0.3791,-0.0140 -0.3886,-0.0340 C -0.3886,-0.0340 '
|
||||
'-0.3984,-0.0546 -0.3984,-0.0546 C -0.3984,-0.0546 -0.3854,-0.0800 -0.3854,-0.0800 C '
|
||||
'-0.3714,-0.1073 -0.3711,-0.1089 -0.3667,-0.1698 C -0.3622,-0.2309 -0.3480,-0.2774 '
|
||||
'-0.3193,-0.3248 C -0.2995,-0.3519 -0.2780,-0.3780 -0.2518,-0.3994 C -0.2256,-0.4207 '
|
||||
'-0.1979,-0.4405 -0.1670,-0.4546 C -0.1313,-0.4711 -0.0891,-0.4856 -0.0520,-0.4939 C '
|
||||
'-0.0291,-0.4991 -0.0166,-0.5000 0.0290,-0.5000 C 0.1038,-0.4999 0.1503,-0.4907 '
|
||||
'0.2108,-0.4638 C 0.2426,-0.4453 0.2713,-0.4223 0.2973,-0.3964 C 0.3232,-0.3705 '
|
||||
'0.3451,-0.3410 0.3636,-0.3094 C 0.3882,-0.2546 0.3984,-0.1987 0.3958,-0.1338 C '
|
||||
'0.3934,-0.0764 0.3839,-0.0378 0.3590,0.0155 C 0.3443,0.0471 0.3344,0.0631 0.3137,0.0892 C '
|
||||
'0.3051,0.1000 0.2954,0.1143 0.2922,0.1210 C 0.2786,0.1488 0.2439,0.1787 0.2251,0.1787 C '
|
||||
'0.2222,0.1787 0.2196,0.1790 0.2194,0.1794 C 0.2192,0.1798 0.2183,0.2050 0.2174,0.2354 C '
|
||||
'0.2174,0.2354 0.2157,0.2907 0.2157,0.2907 C 0.2157,0.2907 0.1752,0.3211 0.1752,0.3211 C '
|
||||
'0.1529,0.3378 0.1272,0.3586 0.1179,0.3672 C 0.1087,0.3758 0.0792,0.3982 0.0523,0.4169 C '
|
||||
'0.0255,0.4357 -0.0103,0.4621 -0.0272,0.4755 C -0.0272,0.4755 -0.0579,0.5000 -0.0579,0.5000 '
|
||||
'C -0.0579,0.5000 -0.0787,0.4979 -0.0787,0.4979 C -0.1024,0.4955 -0.1883,0.4958 '
|
||||
'-0.2039,0.4983 C -0.2134,0.4998 -0.2153,0.4989 -0.2284,0.4864 C -0.2284,0.4864 '
|
||||
'-0.2284,0.4864 -0.2284,0.4864 Z M -0.0484,0.4788 C -0.0416,0.4736 -0.0217,0.4580 '
|
||||
'-0.0042,0.4442 C 0.0133,0.4303 0.0424,0.4089 0.0605,0.3966 C 0.0786,0.3843 0.1040,0.3645 '
|
||||
'0.1170,0.3526 C 0.1300,0.3406 0.1548,0.3208 0.1719,0.3085 C 0.1920,0.2942 0.2036,0.2841 '
|
||||
'0.2044,0.2802 C 0.2051,0.2768 0.2064,0.2580 0.2073,0.2384 C 0.2088,0.2048 0.2140,0.1616 '
|
||||
'0.2196,0.1369 C 0.2219,0.1267 0.2216,0.1258 0.2141,0.1219 C 0.2028,0.1161 0.2014,0.1167 '
|
||||
'0.1995,0.1282 C 0.1986,0.1339 0.1933,0.1452 0.1878,0.1534 C 0.1764,0.1703 0.1649,0.1764 '
|
||||
'0.1438,0.1770 C 0.1306,0.1773 0.1299,0.1769 0.1291,0.1697 C 0.1281,0.1615 0.1273,0.1613 '
|
||||
'0.1085,0.1638 C 0.1085,0.1638 0.0960,0.1655 0.0960,0.1655 C 0.0960,0.1655 0.0915,0.1901 '
|
||||
'0.0915,0.1901 C 0.0859,0.2204 0.0583,0.3008 0.0522,0.3045 C 0.0497,0.3060 0.0441,0.3102 '
|
||||
'0.0397,0.3138 C 0.0288,0.3227 0.0298,0.3165 0.0413,0.3037 C 0.0505,0.2935 0.0650,0.2580 '
|
||||
'0.0614,0.2544 C 0.0604,0.2534 0.0550,0.2563 0.0492,0.2608 C 0.0434,0.2652 0.0354,0.2702 '
|
||||
'0.0313,0.2720 C 0.0258,0.2744 0.0243,0.2766 0.0254,0.2809 C 0.0262,0.2840 0.0256,0.2865 '
|
||||
'0.0239,0.2865 C 0.0222,0.2865 0.0216,0.2848 0.0224,0.2828 C 0.0232,0.2807 0.0216,0.2781 '
|
||||
'0.0189,0.2771 C 0.0121,0.2745 0.0061,0.2831 0.0084,0.2921 C 0.0126,0.3080 0.0128,0.3150 '
|
||||
'0.0092,0.3173 C 0.0028,0.3213 0.0003,0.3199 0.0048,0.3149 C 0.0085,0.3108 0.0085,0.3095 '
|
||||
'0.0054,0.3066 C 0.0008,0.3024 -0.0042,0.3021 -0.0042,0.3059 C -0.0042,0.3074 '
|
||||
'-0.0021,0.3087 0.0004,0.3087 C 0.0030,0.3087 0.0042,0.3095 0.0031,0.3106 C -0.0000,0.3137 '
|
||||
'-0.0093,0.3143 -0.0110,0.3115 C -0.0119,0.3100 -0.0153,0.3115 -0.0185,0.3147 C '
|
||||
'-0.0185,0.3147 -0.0244,0.3206 -0.0244,0.3206 C -0.0244,0.3206 -0.0188,0.3252 '
|
||||
'-0.0188,0.3252 C -0.0133,0.3296 -0.0134,0.3298 -0.0239,0.3359 C -0.0321,0.3406 '
|
||||
'-0.0346,0.3437 -0.0346,0.3494 C -0.0346,0.3551 -0.0353,0.3560 -0.0379,0.3535 C '
|
||||
'-0.0397,0.3516 -0.0420,0.3501 -0.0430,0.3501 C -0.0462,0.3501 -0.0557,0.3597 '
|
||||
'-0.0576,0.3648 C -0.0596,0.3704 -0.0650,0.3687 -0.0650,0.3624 C -0.0650,0.3553 '
|
||||
'-0.0728,0.3582 -0.0804,0.3681 C -0.0845,0.3734 -0.0888,0.3778 -0.0900,0.3778 C '
|
||||
'-0.0937,0.3778 -0.0968,0.3663 -0.0968,0.3529 C -0.0968,0.3419 -0.0974,0.3406 '
|
||||
'-0.1023,0.3417 C -0.1054,0.3423 -0.1116,0.3429 -0.1162,0.3430 C -0.1207,0.3431 '
|
||||
'-0.1255,0.3449 -0.1267,0.3468 C -0.1297,0.3515 -0.1215,0.3642 -0.1143,0.3660 C '
|
||||
'-0.1079,0.3677 -0.1084,0.3772 -0.1150,0.3814 C -0.1230,0.3863 -0.1449,0.3756 '
|
||||
'-0.1545,0.3620 C -0.1621,0.3512 -0.1639,0.3501 -0.1748,0.3501 C -0.1813,0.3501 '
|
||||
'-0.1867,0.3508 -0.1867,0.3517 C -0.1867,0.3525 -0.1847,0.3569 -0.1824,0.3615 C '
|
||||
'-0.1793,0.3675 -0.1763,0.3696 -0.1720,0.3691 C -0.1614,0.3679 -0.1531,0.3750 '
|
||||
'-0.1450,0.3926 C -0.1407,0.4019 -0.1346,0.4133 -0.1315,0.4179 C -0.1227,0.4308 '
|
||||
'-0.1248,0.4319 -0.1370,0.4209 C -0.1462,0.4125 -0.1490,0.4113 -0.1536,0.4138 C '
|
||||
'-0.1584,0.4164 -0.1590,0.4158 -0.1592,0.4090 C -0.1594,0.3953 -0.1681,0.3770 '
|
||||
'-0.1748,0.3760 C -0.1781,0.3755 -0.1816,0.3763 -0.1825,0.3778 C -0.1847,0.3814 '
|
||||
'-0.1969,0.3814 -0.1991,0.3778 C -0.2012,0.3744 -0.2116,0.3741 -0.2116,0.3775 C '
|
||||
'-0.2116,0.3788 -0.2097,0.3844 -0.2074,0.3898 C -0.2023,0.4021 -0.2022,0.4054 '
|
||||
'-0.2071,0.4054 C -0.2092,0.4054 -0.2135,0.3993 -0.2168,0.3917 C -0.2200,0.3841 '
|
||||
'-0.2253,0.3765 -0.2286,0.3748 C -0.2341,0.3719 -0.2343,0.3721 -0.2321,0.3796 C '
|
||||
'-0.2308,0.3839 -0.2297,0.4055 -0.2296,0.4276 C -0.2296,0.4496 -0.2284,0.4693 '
|
||||
'-0.2271,0.4713 C -0.2258,0.4734 -0.2210,0.4773 -0.2164,0.4801 C -0.2087,0.4848 '
|
||||
'-0.2074,0.4849 -0.2014,0.4809 C -0.1956,0.4771 -0.1889,0.4770 -0.1431,0.4800 C '
|
||||
'-0.1146,0.4818 -0.0863,0.4843 -0.0802,0.4855 C -0.0628,0.4891 -0.0616,0.4888 '
|
||||
'-0.0484,0.4788 C -0.0484,0.4788 -0.0484,0.4788 -0.0484,0.4788 Z M 0.0097,0.3377 C '
|
||||
'0.0132,0.3339 0.0174,0.3308 0.0189,0.3308 C 0.0204,0.3308 0.0188,0.3339 0.0152,0.3377 C '
|
||||
'0.0116,0.3415 0.0075,0.3446 0.0059,0.3446 C 0.0044,0.3446 0.0061,0.3415 0.0097,0.3377 C '
|
||||
'0.0097,0.3377 0.0097,0.3377 0.0097,0.3377 Z M -0.0097,0.3256 C -0.0097,0.3242 '
|
||||
'-0.0077,0.3223 -0.0052,0.3213 C -0.0014,0.3199 -0.0012,0.3203 -0.0041,0.3238 C '
|
||||
'-0.0081,0.3286 -0.0097,0.3291 -0.0097,0.3256 C -0.0097,0.3256 -0.0097,0.3256 '
|
||||
'-0.0097,0.3256 Z M -0.0162,0.3183 C -0.0153,0.3161 -0.0141,0.3142 -0.0135,0.3142 C '
|
||||
'-0.0129,0.3142 -0.0125,0.3161 -0.0125,0.3183 C -0.0125,0.3206 -0.0137,0.3225 '
|
||||
'-0.0151,0.3225 C -0.0166,0.3225 -0.0171,0.3206 -0.0162,0.3183 C -0.0162,0.3183 '
|
||||
'-0.0162,0.3183 -0.0162,0.3183 Z M 0.0308,0.2823 C 0.0317,0.2801 0.0335,0.2782 '
|
||||
'0.0348,0.2782 C 0.0388,0.2782 0.0377,0.2830 0.0333,0.2847 C 0.0306,0.2858 0.0298,0.2849 '
|
||||
'0.0308,0.2823 C 0.0308,0.2823 0.0308,0.2823 0.0308,0.2823 Z M 0.0490,0.2711 C '
|
||||
'0.0516,0.2684 0.0545,0.2669 0.0555,0.2678 C 0.0564,0.2687 0.0542,0.2710 0.0507,0.2728 C '
|
||||
'0.0445,0.2760 0.0444,0.2759 0.0490,0.2711 C 0.0490,0.2711 0.0490,0.2711 0.0490,0.2711 Z M '
|
||||
'-0.1203,0.3748 C -0.1203,0.3732 -0.1234,0.3678 -0.1272,0.3628 C -0.1310,0.3578 '
|
||||
'-0.1341,0.3523 -0.1341,0.3504 C -0.1341,0.3481 -0.1372,0.3477 -0.1445,0.3490 C '
|
||||
'-0.1502,0.3500 -0.1552,0.3512 -0.1556,0.3515 C -0.1585,0.3539 -0.1507,0.3629 '
|
||||
'-0.1400,0.3697 C -0.1265,0.3781 -0.1203,0.3798 -0.1203,0.3748 C -0.1203,0.3748 '
|
||||
'-0.1203,0.3748 -0.1203,0.3748 Z M -0.1869,0.3590 C -0.1886,0.3541 -0.1914,0.3501 '
|
||||
'-0.1932,0.3500 C -0.1949,0.3499 -0.2034,0.3492 -0.2121,0.3484 C -0.2121,0.3484 '
|
||||
'-0.2278,0.3471 -0.2278,0.3471 C -0.2278,0.3471 -0.2218,0.3583 -0.2218,0.3583 C '
|
||||
'-0.2183,0.3647 -0.2137,0.3695 -0.2109,0.3695 C -0.2052,0.3695 -0.2052,0.3693 '
|
||||
'-0.2087,0.3600 C -0.2127,0.3495 -0.2085,0.3515 -0.1994,0.3643 C -0.1927,0.3739 '
|
||||
'-0.1909,0.3749 -0.1877,0.3717 C -0.1846,0.3686 -0.1844,0.3660 -0.1869,0.3590 C '
|
||||
'-0.1869,0.3590 -0.1869,0.3590 -0.1869,0.3590 Z M -0.2281,0.3643 C -0.2281,0.3630 '
|
||||
'-0.2299,0.3604 -0.2321,0.3586 C -0.2343,0.3568 -0.2365,0.3527 -0.2370,0.3495 C '
|
||||
'-0.2380,0.3425 -0.2447,0.3394 -0.2447,0.3459 C -0.2447,0.3483 -0.2420,0.3541 '
|
||||
'-0.2387,0.3586 C -0.2327,0.3666 -0.2281,0.3691 -0.2281,0.3643 C -0.2281,0.3643 '
|
||||
'-0.2281,0.3643 -0.2281,0.3643 Z M -0.0740,0.3575 C -0.0669,0.3511 -0.0661,0.3451 '
|
||||
'-0.0715,0.3377 C -0.0749,0.3331 -0.0762,0.3329 -0.0843,0.3363 C -0.0928,0.3398 '
|
||||
'-0.0931,0.3405 -0.0914,0.3510 C -0.0886,0.3688 -0.0871,0.3694 -0.0740,0.3575 C '
|
||||
'-0.0740,0.3575 -0.0740,0.3575 -0.0740,0.3575 Z M -0.0478,0.3480 C -0.0435,0.3443 '
|
||||
'-0.0435,0.3432 -0.0472,0.3360 C -0.0518,0.3270 -0.0522,0.3269 -0.0597,0.3309 C '
|
||||
'-0.0637,0.3331 -0.0646,0.3356 -0.0634,0.3413 C -0.0599,0.3575 -0.0592,0.3578 '
|
||||
'-0.0478,0.3480 C -0.0478,0.3480 -0.0478,0.3480 -0.0478,0.3480 Z M -0.1633,0.3398 C '
|
||||
'-0.1645,0.3371 -0.1668,0.3284 -0.1684,0.3204 C -0.1684,0.3204 -0.1713,0.3059 '
|
||||
'-0.1713,0.3059 C -0.1713,0.3059 -0.1899,0.3059 -0.1899,0.3059 C -0.2001,0.3059 '
|
||||
'-0.2092,0.3071 -0.2102,0.3087 C -0.2127,0.3128 -0.1978,0.3387 -0.1918,0.3406 C '
|
||||
'-0.1890,0.3415 -0.1842,0.3414 -0.1811,0.3405 C -0.1780,0.3395 -0.1756,0.3400 '
|
||||
'-0.1756,0.3417 C -0.1756,0.3433 -0.1724,0.3446 -0.1684,0.3446 C -0.1626,0.3446 '
|
||||
'-0.1616,0.3437 -0.1633,0.3398 C -0.1633,0.3398 -0.1633,0.3398 -0.1633,0.3398 Z M '
|
||||
'-0.2077,0.3395 C -0.2069,0.3383 -0.2084,0.3308 -0.2110,0.3230 C -0.2151,0.3104 '
|
||||
'-0.2166,0.3087 -0.2233,0.3087 C -0.2324,0.3087 -0.2324,0.3086 -0.2250,0.3233 C '
|
||||
'-0.2161,0.3411 -0.2114,0.3455 -0.2077,0.3395 C -0.2077,0.3395 -0.2077,0.3395 '
|
||||
'-0.2077,0.3395 Z M -0.1336,0.3338 C -0.1329,0.3294 -0.1329,0.3214 -0.1336,0.3159 C '
|
||||
'-0.1336,0.3159 -0.1347,0.3059 -0.1347,0.3059 C -0.1347,0.3059 -0.1510,0.3059 '
|
||||
'-0.1510,0.3059 C -0.1600,0.3059 -0.1673,0.3071 -0.1673,0.3086 C -0.1673,0.3101 '
|
||||
'-0.1639,0.3182 -0.1598,0.3266 C -0.1531,0.3403 -0.1515,0.3418 -0.1435,0.3418 C '
|
||||
'-0.1360,0.3418 -0.1346,0.3407 -0.1336,0.3338 C -0.1336,0.3338 -0.1336,0.3338 '
|
||||
'-0.1336,0.3338 Z M -0.1091,0.3362 C -0.1048,0.3339 -0.1037,0.3304 -0.1037,0.3182 C '
|
||||
'-0.1037,0.3182 -0.1037,0.3031 -0.1037,0.3031 C -0.1037,0.3031 -0.1162,0.3031 '
|
||||
'-0.1162,0.3031 C -0.1300,0.3031 -0.1311,0.3054 -0.1256,0.3228 C -0.1239,0.3279 '
|
||||
'-0.1221,0.3337 -0.1215,0.3356 C -0.1202,0.3398 -0.1162,0.3400 -0.1091,0.3362 C '
|
||||
'-0.1091,0.3362 -0.1091,0.3362 -0.1091,0.3362 Z M -0.0276,0.3344 C -0.0276,0.3344 '
|
||||
'-0.0177,0.3296 -0.0177,0.3296 C -0.0177,0.3296 -0.0239,0.3250 -0.0239,0.3250 C '
|
||||
'-0.0287,0.3214 -0.0317,0.3209 -0.0378,0.3231 C -0.0466,0.3261 -0.0467,0.3264 '
|
||||
'-0.0428,0.3337 C -0.0393,0.3402 -0.0399,0.3402 -0.0276,0.3344 C -0.0276,0.3344 '
|
||||
'-0.0276,0.3344 -0.0276,0.3344 Z M -0.2274,0.3347 C -0.2266,0.3338 -0.2279,0.3276 '
|
||||
'-0.2303,0.3209 C -0.2338,0.3116 -0.2363,0.3087 -0.2409,0.3087 C -0.2469,0.3087 '
|
||||
'-0.2469,0.3087 -0.2396,0.3225 C -0.2324,0.3361 -0.2306,0.3379 -0.2274,0.3347 C '
|
||||
'-0.2274,0.3347 -0.2274,0.3347 -0.2274,0.3347 Z M -0.0832,0.3299 C -0.0777,0.3259 '
|
||||
'-0.0719,0.3006 -0.0756,0.2969 C -0.0787,0.2938 -0.0915,0.2971 -0.0956,0.3019 C '
|
||||
'-0.0997,0.3069 -0.0962,0.3336 -0.0915,0.3336 C -0.0897,0.3336 -0.0860,0.3319 '
|
||||
'-0.0832,0.3299 C -0.0832,0.3299 -0.0832,0.3299 -0.0832,0.3299 Z M -0.2447,0.3258 C '
|
||||
'-0.2447,0.3246 -0.2467,0.3211 -0.2491,0.3182 C -0.2515,0.3152 -0.2529,0.3141 '
|
||||
'-0.2523,0.3156 C -0.2516,0.3171 -0.2503,0.3205 -0.2494,0.3232 C -0.2476,0.3282 '
|
||||
'-0.2447,0.3298 -0.2447,0.3258 C -0.2447,0.3258 -0.2447,0.3258 -0.2447,0.3258 Z M '
|
||||
'-0.0614,0.3248 C -0.0580,0.3231 -0.0546,0.3206 -0.0537,0.3192 C -0.0510,0.3150 '
|
||||
'-0.0524,0.2912 -0.0554,0.2902 C -0.0621,0.2880 -0.0677,0.2967 -0.0695,0.3121 C '
|
||||
'-0.0714,0.3290 -0.0709,0.3298 -0.0614,0.3248 C -0.0614,0.3248 -0.0614,0.3248 '
|
||||
'-0.0614,0.3248 Z M -0.0340,0.3086 C -0.0289,0.2981 -0.0275,0.2838 -0.0317,0.2838 C '
|
||||
'-0.0331,0.2838 -0.0373,0.2851 -0.0409,0.2868 C -0.0467,0.2894 -0.0476,0.2919 '
|
||||
'-0.0481,0.3050 C -0.0485,0.3182 -0.0479,0.3200 -0.0437,0.3192 C -0.0410,0.3187 '
|
||||
'-0.0366,0.3139 -0.0340,0.3086 C -0.0340,0.3086 -0.0340,0.3086 -0.0340,0.3086 Z M '
|
||||
'-0.0157,0.2969 C -0.0077,0.2775 -0.0078,0.2747 -0.0166,0.2787 C -0.0214,0.2809 '
|
||||
'-0.0239,0.2848 -0.0251,0.2918 C -0.0260,0.2973 -0.0274,0.3039 -0.0281,0.3066 C '
|
||||
'-0.0289,0.3095 -0.0279,0.3114 -0.0256,0.3114 C -0.0235,0.3114 -0.0191,0.3049 '
|
||||
'-0.0157,0.2969 C -0.0157,0.2969 -0.0157,0.2969 -0.0157,0.2969 Z M -0.2338,0.2950 C '
|
||||
'-0.2305,0.2889 -0.2298,0.2561 -0.2330,0.2562 C -0.2341,0.2562 -0.2379,0.2570 '
|
||||
'-0.2413,0.2579 C -0.2469,0.2594 -0.2475,0.2612 -0.2475,0.2781 C -0.2475,0.2883 '
|
||||
'-0.2467,0.2975 -0.2457,0.2985 C -0.2422,0.3020 -0.2366,0.3004 -0.2338,0.2950 C '
|
||||
'-0.2338,0.2950 -0.2338,0.2950 -0.2338,0.2950 Z M -0.2160,0.2801 C -0.2134,0.2592 '
|
||||
'-0.2159,0.2526 -0.2236,0.2603 C -0.2269,0.2636 -0.2281,0.2698 -0.2281,0.2828 C '
|
||||
'-0.2281,0.2984 -0.2275,0.3007 -0.2233,0.2999 C -0.2196,0.2991 -0.2179,0.2947 '
|
||||
'-0.2160,0.2801 C -0.2160,0.2801 -0.2160,0.2801 -0.2160,0.2801 Z M -0.1728,0.2897 C '
|
||||
'-0.1728,0.2684 -0.1844,0.2478 -0.1963,0.2478 C -0.2049,0.2478 -0.2116,0.2636 '
|
||||
'-0.2116,0.2839 C -0.2116,0.2839 -0.2116,0.3004 -0.2116,0.3004 C -0.2116,0.3004 '
|
||||
'-0.1922,0.3004 -0.1922,0.3004 C -0.1922,0.3004 -0.1728,0.3004 -0.1728,0.3004 C '
|
||||
'-0.1728,0.3004 -0.1728,0.2897 -0.1728,0.2897 Z M -0.1348,0.2809 C -0.1359,0.2656 '
|
||||
'-0.1375,0.2599 -0.1425,0.2546 C -0.1513,0.2452 -0.1606,0.2458 -0.1659,0.2560 C '
|
||||
'-0.1701,0.2641 -0.1718,0.2950 -0.1682,0.2985 C -0.1672,0.2995 -0.1590,0.3004 '
|
||||
'-0.1499,0.3004 C -0.1499,0.3004 -0.1334,0.3004 -0.1334,0.3004 C -0.1334,0.3004 '
|
||||
'-0.1348,0.2809 -0.1348,0.2809 Z M -0.2530,0.2782 C -0.2530,0.2610 -0.2536,0.2589 '
|
||||
'-0.2584,0.2589 C -0.2671,0.2589 -0.2685,0.2707 -0.2623,0.2928 C -0.2616,0.2954 '
|
||||
'-0.2592,0.2976 -0.2570,0.2976 C -0.2539,0.2976 -0.2530,0.2932 -0.2530,0.2782 C '
|
||||
'-0.2530,0.2782 -0.2530,0.2782 -0.2530,0.2782 Z M -0.0951,0.2912 C -0.0896,0.2791 '
|
||||
'-0.1037,0.2451 -0.1142,0.2451 C -0.1244,0.2451 -0.1294,0.2519 -0.1307,0.2675 C '
|
||||
'-0.1313,0.2757 -0.1305,0.2858 -0.1289,0.2900 C -0.1262,0.2969 -0.1247,0.2976 '
|
||||
'-0.1120,0.2976 C -0.1001,0.2976 -0.0976,0.2967 -0.0951,0.2912 C -0.0951,0.2912 '
|
||||
'-0.0951,0.2912 -0.0951,0.2912 Z M -0.0028,0.2948 C -0.0018,0.2933 -0.0023,0.2921 '
|
||||
'-0.0038,0.2921 C -0.0054,0.2921 -0.0074,0.2933 -0.0083,0.2948 C -0.0093,0.2964 '
|
||||
'-0.0088,0.2976 -0.0073,0.2976 C -0.0057,0.2976 -0.0037,0.2964 -0.0028,0.2948 C '
|
||||
'-0.0028,0.2948 -0.0028,0.2948 -0.0028,0.2948 Z M -0.0643,0.2882 C -0.0515,0.2785 '
|
||||
'-0.0640,0.2437 -0.0803,0.2437 C -0.0874,0.2437 -0.0888,0.2450 -0.0910,0.2536 C '
|
||||
'-0.0944,0.2674 -0.0909,0.2886 -0.0849,0.2902 C -0.0760,0.2925 -0.0691,0.2919 '
|
||||
'-0.0643,0.2882 C -0.0643,0.2882 -0.0643,0.2882 -0.0643,0.2882 Z M -0.0372,0.2809 C '
|
||||
'-0.0268,0.2754 -0.0339,0.2423 -0.0454,0.2423 C -0.0542,0.2423 -0.0570,0.2508 '
|
||||
'-0.0539,0.2673 C -0.0524,0.2753 -0.0512,0.2822 -0.0512,0.2828 C -0.0512,0.2848 '
|
||||
'-0.0423,0.2837 -0.0372,0.2809 C -0.0372,0.2809 -0.0372,0.2809 -0.0372,0.2809 Z M '
|
||||
'-0.0157,0.2698 C -0.0124,0.2667 -0.0097,0.2629 -0.0097,0.2614 C -0.0097,0.2598 '
|
||||
'-0.0084,0.2593 -0.0069,0.2603 C -0.0033,0.2625 0.0019,0.2488 0.0008,0.2397 C 0.0002,0.2347 '
|
||||
'-0.0017,0.2326 -0.0055,0.2326 C -0.0104,0.2326 -0.0110,0.2342 -0.0103,0.2451 C '
|
||||
'-0.0103,0.2451 -0.0095,0.2575 -0.0095,0.2575 C -0.0095,0.2575 -0.0148,0.2478 '
|
||||
'-0.0148,0.2478 C -0.0219,0.2347 -0.0306,0.2345 -0.0300,0.2474 C -0.0293,0.2615 '
|
||||
'-0.0263,0.2755 -0.0239,0.2755 C -0.0228,0.2755 -0.0191,0.2729 -0.0157,0.2698 C '
|
||||
'-0.0157,0.2698 -0.0157,0.2698 -0.0157,0.2698 Z M -0.1534,0.2395 C -0.1505,0.2395 '
|
||||
'-0.1454,0.2432 -0.1421,0.2476 C -0.1421,0.2476 -0.1362,0.2557 -0.1362,0.2557 C '
|
||||
'-0.1362,0.2557 -0.1294,0.2476 -0.1294,0.2476 C -0.1215,0.2383 -0.1127,0.2373 '
|
||||
'-0.1035,0.2447 C -0.0971,0.2498 -0.0970,0.2498 -0.0919,0.2433 C -0.0859,0.2357 '
|
||||
'-0.0747,0.2347 -0.0656,0.2411 C -0.0599,0.2451 -0.0589,0.2450 -0.0522,0.2397 C '
|
||||
'-0.0481,0.2365 -0.0408,0.2340 -0.0355,0.2340 C -0.0303,0.2340 -0.0193,0.2306 '
|
||||
'-0.0111,0.2264 C 0.0022,0.2197 0.0040,0.2178 0.0041,0.2102 C 0.0041,0.2003 -0.0009,0.1842 '
|
||||
'-0.0041,0.1842 C -0.0053,0.1842 -0.0071,0.1861 -0.0079,0.1884 C -0.0111,0.1967 '
|
||||
'-0.0153,0.1925 -0.0140,0.1822 C -0.0131,0.1748 -0.0101,0.1695 -0.0036,0.1638 C '
|
||||
'0.0014,0.1594 0.0036,0.1567 0.0014,0.1578 C -0.0009,0.1589 0.0010,0.1566 0.0055,0.1526 C '
|
||||
'0.0055,0.1526 0.0138,0.1455 0.0138,0.1455 C 0.0138,0.1455 0.0022,0.1455 0.0022,0.1455 C '
|
||||
'-0.0042,0.1455 -0.0161,0.1480 -0.0241,0.1511 C -0.0241,0.1511 -0.0387,0.1566 '
|
||||
'-0.0387,0.1566 C -0.0387,0.1566 -0.0304,0.1497 -0.0304,0.1497 C -0.0098,0.1324 '
|
||||
'0.0179,0.1308 0.0677,0.1439 C 0.0822,0.1476 0.1005,0.1516 0.1085,0.1526 C 0.1215,0.1543 '
|
||||
'0.1243,0.1537 0.1348,0.1468 C 0.1547,0.1337 0.1831,0.1042 0.1948,0.0846 C 0.2055,0.0665 '
|
||||
'0.2071,0.0652 0.2398,0.0463 C 0.2770,0.0248 0.2862,0.0223 0.2862,0.0337 C 0.2862,0.0377 '
|
||||
'0.2874,0.0400 0.2889,0.0391 C 0.2905,0.0381 0.2917,0.0341 0.2917,0.0302 C 0.2917,0.0260 '
|
||||
'0.2964,0.0170 0.3027,0.0088 C 0.3087,0.0010 0.3168,-0.0125 0.3208,-0.0211 C 0.3326,-0.0470 '
|
||||
'0.3350,-0.0980 0.3250,-0.1101 C 0.3205,-0.1156 0.3140,-0.1155 0.3000,-0.1099 C '
|
||||
'0.2905,-0.1061 0.2869,-0.1060 0.2767,-0.1088 C 0.2556,-0.1147 0.2466,-0.1094 '
|
||||
'0.2127,-0.0706 C 0.2069,-0.0640 0.1969,-0.0562 0.1905,-0.0531 C 0.1817,-0.0490 '
|
||||
'0.1773,-0.0446 0.1730,-0.0354 C 0.1699,-0.0287 0.1673,-0.0216 0.1673,-0.0197 C '
|
||||
'0.1673,-0.0128 0.1756,-0.0043 0.1905,0.0041 C 0.2089,0.0145 0.2107,0.0171 0.2042,0.0243 C '
|
||||
'0.2042,0.0243 0.1991,0.0300 0.1991,0.0300 C 0.1991,0.0300 0.2101,0.0252 0.2101,0.0252 C '
|
||||
'0.2162,0.0225 0.2274,0.0194 0.2350,0.0182 C 0.2426,0.0171 0.2546,0.0146 0.2617,0.0128 C '
|
||||
'0.2688,0.0110 0.2769,0.0101 0.2797,0.0108 C 0.2835,0.0118 0.2830,0.0122 0.2779,0.0125 C '
|
||||
'0.2643,0.0131 0.2209,0.0263 0.2012,0.0357 C 0.1813,0.0453 0.1812,0.0453 0.1680,0.0411 C '
|
||||
'0.1478,0.0346 0.1469,0.0340 0.1405,0.0209 C 0.1332,0.0059 0.1286,-0.0189 0.1286,-0.0436 C '
|
||||
'0.1286,-0.0608 0.1277,-0.0633 0.1175,-0.0779 C 0.1060,-0.0943 0.0900,-0.1351 '
|
||||
'0.0899,-0.1483 C 0.0899,-0.1524 0.0953,-0.1680 0.1019,-0.1828 C 0.1165,-0.2155 '
|
||||
'0.1212,-0.2295 0.1189,-0.2333 C 0.1180,-0.2348 0.1181,-0.2375 0.1191,-0.2393 C '
|
||||
'0.1205,-0.2415 0.1222,-0.2410 0.1246,-0.2377 C 0.1275,-0.2338 0.1271,-0.2307 '
|
||||
'0.1223,-0.2200 C 0.1192,-0.2129 0.1163,-0.2033 0.1160,-0.1987 C 0.1156,-0.1942 '
|
||||
'0.1138,-0.1867 0.1119,-0.1822 C 0.1071,-0.1708 0.1054,-0.1455 0.1085,-0.1338 C '
|
||||
'0.1085,-0.1338 0.1111,-0.1241 0.1111,-0.1241 C 0.1111,-0.1241 0.1225,-0.1417 '
|
||||
'0.1225,-0.1417 C 0.1288,-0.1514 0.1348,-0.1636 0.1357,-0.1688 C 0.1371,-0.1760 '
|
||||
'0.1396,-0.1791 0.1466,-0.1820 C 0.1516,-0.1841 0.1565,-0.1884 0.1575,-0.1915 C '
|
||||
'0.1585,-0.1947 0.1645,-0.1996 0.1709,-0.2024 C 0.1773,-0.2052 0.1909,-0.2133 '
|
||||
'0.2011,-0.2203 C 0.2114,-0.2273 0.2245,-0.2339 0.2302,-0.2349 C 0.2434,-0.2373 '
|
||||
'0.2488,-0.2401 0.2634,-0.2518 C 0.2766,-0.2625 0.2787,-0.2677 0.2683,-0.2638 C '
|
||||
'0.2560,-0.2835 0.2649,-0.3214 0.2472,-0.3397 C 0.2295,-0.3579 0.2283,-0.3982 '
|
||||
'0.2052,-0.4134 C 0.1821,-0.4286 0.1703,-0.4688 0.1424,-0.4794 C 0.0746,-0.4982 '
|
||||
'0.0055,-0.4978 -0.0719,-0.4780 C -0.1472,-0.4588 -0.2011,-0.4309 -0.2611,-0.3801 C '
|
||||
'-0.2903,-0.3554 -0.3239,-0.3021 -0.3405,-0.2540 C -0.3474,-0.2337 -0.3481,-0.2278 '
|
||||
'-0.3492,-0.1808 C -0.3499,-0.1441 -0.3512,-0.1288 -0.3537,-0.1269 C -0.3557,-0.1253 '
|
||||
'-0.3595,-0.1172 -0.3623,-0.1089 C -0.3650,-0.1005 -0.3708,-0.0862 -0.3751,-0.0771 C '
|
||||
'-0.3795,-0.0680 -0.3830,-0.0583 -0.3830,-0.0557 C -0.3830,-0.0516 -0.3817,-0.0519 '
|
||||
'-0.3731,-0.0577 C -0.3600,-0.0666 -0.3352,-0.0757 -0.3241,-0.0757 C -0.3114,-0.0757 '
|
||||
'-0.2723,-0.0685 -0.2637,-0.0646 C -0.2597,-0.0628 -0.2551,-0.0583 -0.2534,-0.0548 C '
|
||||
'-0.2495,-0.0460 -0.2310,-0.0367 -0.2252,-0.0405 C -0.2221,-0.0425 -0.2179,-0.0418 '
|
||||
'-0.2104,-0.0383 C -0.2016,-0.0341 -0.1996,-0.0339 -0.1974,-0.0372 C -0.1943,-0.0420 '
|
||||
'-0.1967,-0.0575 -0.2024,-0.0683 C -0.2063,-0.0760 -0.2061,-0.0759 -0.1964,-0.0663 C '
|
||||
'-0.1865,-0.0563 -0.1811,-0.0554 -0.1811,-0.0636 C -0.1811,-0.0698 -0.1364,-0.1284 '
|
||||
'-0.1256,-0.1365 C -0.1060,-0.1512 -0.1057,-0.1508 -0.1231,-0.1336 C -0.1434,-0.1135 '
|
||||
'-0.1784,-0.0663 -0.1784,-0.0590 C -0.1784,-0.0542 -0.1611,-0.0370 -0.1564,-0.0370 C '
|
||||
'-0.1550,-0.0370 -0.1518,-0.0391 -0.1492,-0.0417 C -0.1448,-0.0461 -0.1443,-0.0461 '
|
||||
'-0.1409,-0.0414 C -0.1353,-0.0337 -0.1255,-0.0370 -0.1171,-0.0496 C -0.1108,-0.0589 '
|
||||
'-0.1044,-0.0633 -0.0797,-0.0750 C -0.0464,-0.0907 0.0090,-0.1123 0.0128,-0.1111 C '
|
||||
'0.0142,-0.1106 0.0041,-0.1059 -0.0097,-0.1006 C -0.0234,-0.0953 -0.0346,-0.0900 '
|
||||
'-0.0346,-0.0889 C -0.0346,-0.0877 -0.0237,-0.0868 -0.0103,-0.0868 C 0.0052,-0.0868 '
|
||||
'0.0209,-0.0848 0.0333,-0.0814 C 0.0585,-0.0744 0.0820,-0.0635 0.0788,-0.0602 C '
|
||||
'0.0774,-0.0588 0.0785,-0.0515 0.0816,-0.0425 C 0.0883,-0.0232 0.0893,0.0310 0.0832,0.0427 '
|
||||
'C 0.0806,0.0475 0.0717,0.0540 0.0581,0.0609 C 0.0388,0.0707 0.0360,0.0714 0.0267,0.0687 C '
|
||||
'0.0211,0.0671 0.0048,0.0649 -0.0097,0.0638 C -0.0275,0.0625 -0.0426,0.0594 -0.0567,0.0543 '
|
||||
'C -0.0567,0.0543 -0.0774,0.0467 -0.0774,0.0467 C -0.0774,0.0467 -0.0884,0.0249 '
|
||||
'-0.0884,0.0249 C -0.0884,0.0249 -0.0993,0.0031 -0.0993,0.0031 C -0.0993,0.0031 '
|
||||
'-0.1009,0.0142 -0.1009,0.0142 C -0.1009,0.0142 -0.1025,0.0252 -0.1025,0.0252 C '
|
||||
'-0.1025,0.0252 -0.1043,0.0128 -0.1043,0.0128 C -0.1054,0.0054 -0.1081,-0.0008 '
|
||||
'-0.1109,-0.0024 C -0.1135,-0.0039 -0.1223,-0.0111 -0.1305,-0.0183 C -0.1445,-0.0308 '
|
||||
'-0.1562,-0.0353 -0.1562,-0.0282 C -0.1562,-0.0239 -0.1409,-0.0003 -0.1341,0.0059 C '
|
||||
'-0.1311,0.0086 -0.1286,0.0121 -0.1286,0.0135 C -0.1286,0.0185 -0.1472,-0.0025 '
|
||||
'-0.1532,-0.0143 C -0.1565,-0.0208 -0.1620,-0.0272 -0.1655,-0.0285 C -0.1689,-0.0298 '
|
||||
'-0.1733,-0.0329 -0.1754,-0.0353 C -0.1774,-0.0378 -0.1807,-0.0397 -0.1826,-0.0397 C '
|
||||
'-0.1876,-0.0397 -0.2014,-0.0216 -0.2082,-0.0060 C -0.2114,0.0012 -0.2179,0.0130 '
|
||||
'-0.2226,0.0203 C -0.2226,0.0203 -0.2314,0.0335 -0.2314,0.0335 C -0.2314,0.0335 '
|
||||
'-0.2232,0.0240 -0.2232,0.0240 C -0.2232,0.0240 -0.2149,0.0145 -0.2149,0.0145 C '
|
||||
'-0.2149,0.0145 -0.1987,0.0284 -0.1987,0.0284 C -0.1898,0.0361 -0.1798,0.0438 '
|
||||
'-0.1764,0.0456 C -0.1678,0.0501 -0.1574,0.0689 -0.1462,0.1003 C -0.1346,0.1329 '
|
||||
'-0.1343,0.1489 -0.1454,0.1572 C -0.1517,0.1619 -0.1539,0.1621 -0.1657,0.1591 C '
|
||||
'-0.1657,0.1591 -0.1790,0.1558 -0.1790,0.1558 C -0.1790,0.1558 -0.1772,0.1423 '
|
||||
'-0.1772,0.1423 C -0.1762,0.1350 -0.1761,0.1289 -0.1768,0.1289 C -0.1776,0.1289 '
|
||||
'-0.1815,0.1352 -0.1853,0.1429 C -0.1892,0.1506 -0.1942,0.1575 -0.1965,0.1584 C '
|
||||
'-0.2033,0.1610 -0.2135,0.1570 -0.2224,0.1481 C -0.2300,0.1404 -0.2309,0.1378 '
|
||||
'-0.2310,0.1225 C -0.2311,0.1119 -0.2326,0.1034 -0.2351,0.1001 C -0.2374,0.0971 '
|
||||
'-0.2392,0.0889 -0.2392,0.0819 C -0.2392,0.0630 -0.2430,0.0595 -0.2599,0.0628 C '
|
||||
'-0.2951,0.0697 -0.3137,0.0711 -0.3255,0.0679 C -0.3320,0.0662 -0.3383,0.0633 '
|
||||
'-0.3394,0.0616 C -0.3405,0.0598 -0.3413,0.0478 -0.3411,0.0349 C -0.3411,0.0349 '
|
||||
'-0.3408,0.0114 -0.3408,0.0114 C -0.3408,0.0114 -0.3382,0.0362 -0.3382,0.0362 C '
|
||||
'-0.3368,0.0499 -0.3354,0.0613 -0.3351,0.0617 C -0.3347,0.0620 -0.3259,0.0632 '
|
||||
'-0.3156,0.0642 C -0.3156,0.0642 -0.2967,0.0662 -0.2967,0.0662 C -0.2967,0.0662 '
|
||||
'-0.3039,0.0547 -0.3039,0.0547 C -0.3079,0.0483 -0.3131,0.0348 -0.3155,0.0245 C '
|
||||
'-0.3183,0.0122 -0.3223,0.0032 -0.3272,-0.0019 C -0.3272,-0.0019 -0.3346,-0.0098 '
|
||||
'-0.3346,-0.0098 C -0.3346,-0.0098 -0.3363,0.0008 -0.3363,0.0008 C -0.3363,0.0008 '
|
||||
'-0.3380,0.0114 -0.3380,0.0114 C -0.3380,0.0114 -0.3384,0.0003 -0.3384,0.0003 C '
|
||||
'-0.3388,-0.0096 -0.3407,-0.0124 -0.3581,-0.0282 C -0.3688,-0.0378 -0.3774,-0.0446 '
|
||||
'-0.3774,-0.0434 C -0.3774,-0.0421 -0.3749,-0.0332 -0.3719,-0.0236 C -0.3651,-0.0019 '
|
||||
'-0.3648,0.0258 -0.3710,0.0558 C -0.3710,0.0558 -0.3756,0.0780 -0.3756,0.0780 C '
|
||||
'-0.3756,0.0780 -0.3668,0.0900 -0.3668,0.0900 C -0.3582,0.1020 -0.3556,0.1132 '
|
||||
'-0.3608,0.1164 C -0.3642,0.1185 -0.3747,0.1081 -0.3747,0.1027 C -0.3747,0.1004 '
|
||||
'-0.3759,0.0985 -0.3775,0.0985 C -0.3837,0.0985 -0.3795,0.1178 -0.3684,0.1399 C '
|
||||
'-0.3684,0.1399 -0.3567,0.1633 -0.3567,0.1633 C -0.3567,0.1633 -0.3256,0.1634 '
|
||||
'-0.3256,0.1634 C -0.3085,0.1634 -0.2945,0.1625 -0.2945,0.1612 C -0.2945,0.1572 '
|
||||
'-0.3007,0.1472 -0.3105,0.1351 C -0.3158,0.1286 -0.3195,0.1226 -0.3188,0.1219 C '
|
||||
'-0.3163,0.1194 -0.2895,0.1423 -0.2784,0.1562 C -0.2616,0.1776 -0.2598,0.1841 '
|
||||
'-0.2639,0.2088 C -0.2658,0.2204 -0.2685,0.2303 -0.2699,0.2308 C -0.2713,0.2313 '
|
||||
'-0.2724,0.2347 -0.2724,0.2383 C -0.2724,0.2431 -0.2712,0.2444 -0.2681,0.2433 C '
|
||||
'-0.2658,0.2424 -0.2615,0.2438 -0.2586,0.2464 C -0.2535,0.2510 -0.2532,0.2509 '
|
||||
'-0.2518,0.2447 C -0.2509,0.2411 -0.2478,0.2276 -0.2448,0.2146 C -0.2382,0.1865 '
|
||||
'-0.2377,0.1723 -0.2434,0.1676 C -0.2477,0.1640 -0.2488,0.1474 -0.2458,0.1320 C '
|
||||
'-0.2433,0.1199 -0.2392,0.1213 -0.2392,0.1342 C -0.2392,0.1417 -0.2371,0.1476 '
|
||||
'-0.2324,0.1532 C -0.2324,0.1532 -0.2256,0.1612 -0.2256,0.1612 C -0.2256,0.1612 '
|
||||
'-0.2311,0.1886 -0.2311,0.1886 C -0.2342,0.2037 -0.2385,0.2207 -0.2407,0.2265 C '
|
||||
'-0.2429,0.2322 -0.2447,0.2409 -0.2446,0.2458 C -0.2446,0.2458 -0.2445,0.2547 '
|
||||
'-0.2445,0.2547 C -0.2445,0.2547 -0.2401,0.2466 -0.2401,0.2466 C -0.2401,0.2466 '
|
||||
'-0.2357,0.2385 -0.2357,0.2385 C -0.2357,0.2385 -0.2318,0.2461 -0.2318,0.2461 C '
|
||||
'-0.2267,0.2557 -0.2222,0.2543 -0.2189,0.2421 C -0.2175,0.2369 -0.2160,0.2339 '
|
||||
'-0.2156,0.2354 C -0.2152,0.2369 -0.2140,0.2419 -0.2129,0.2464 C -0.2129,0.2464 '
|
||||
'-0.2111,0.2547 -0.2111,0.2547 C -0.2111,0.2547 -0.2071,0.2471 -0.2071,0.2471 C '
|
||||
'-0.2018,0.2372 -0.1970,0.2375 -0.1846,0.2490 C -0.1846,0.2490 -0.1742,0.2585 '
|
||||
'-0.1742,0.2585 C -0.1742,0.2585 -0.1664,0.2490 -0.1664,0.2490 C -0.1621,0.2438 '
|
||||
'-0.1563,0.2395 -0.1534,0.2395 C -0.1534,0.2395 -0.1534,0.2395 -0.1534,0.2395 Z M '
|
||||
'-0.2039,0.2048 C -0.2028,0.1745 -0.2021,0.1704 -0.1977,0.1704 C -0.1940,0.1704 '
|
||||
'-0.1971,0.2127 -0.2017,0.2242 C -0.2044,0.2311 -0.2048,0.2280 -0.2039,0.2048 C '
|
||||
'-0.2039,0.2048 -0.2039,0.2048 -0.2039,0.2048 Z M -0.0206,0.2216 C -0.0206,0.2186 '
|
||||
'-0.0082,0.2036 -0.0057,0.2036 C -0.0019,0.2036 -0.0047,0.2123 -0.0090,0.2139 C '
|
||||
'-0.0117,0.2149 -0.0154,0.2176 -0.0172,0.2200 C -0.0191,0.2224 -0.0206,0.2231 '
|
||||
'-0.0206,0.2216 C -0.0206,0.2216 -0.0206,0.2216 -0.0206,0.2216 Z M -0.2728,0.1021 C '
|
||||
'-0.2902,0.0874 -0.2925,0.0862 -0.3066,0.0844 C -0.3066,0.0844 -0.3208,0.0827 '
|
||||
'-0.3208,0.0827 C -0.3208,0.0827 -0.3026,0.0823 -0.3026,0.0823 C -0.2914,0.0821 '
|
||||
'-0.2766,0.0793 -0.2641,0.0750 C -0.2529,0.0712 -0.2434,0.0681 -0.2429,0.0681 C '
|
||||
'-0.2424,0.0681 -0.2420,0.0753 -0.2420,0.0840 C -0.2420,0.1006 -0.2421,0.1008 '
|
||||
'-0.2603,0.1086 C -0.2621,0.1093 -0.2677,0.1064 -0.2728,0.1021 C -0.2728,0.1021 '
|
||||
'-0.2728,0.1021 -0.2728,0.1021 Z M -0.0548,0.0944 C -0.0754,0.0834 -0.0788,0.0829 '
|
||||
'-0.0893,0.0891 C -0.0893,0.0891 -0.0968,0.0936 -0.0968,0.0936 C -0.0968,0.0936 '
|
||||
'-0.0906,0.0880 -0.0906,0.0880 C -0.0868,0.0846 -0.0769,0.0812 -0.0656,0.0793 C '
|
||||
'-0.0416,0.0752 -0.0203,0.0785 0.0078,0.0905 C 0.0305,0.1003 0.0343,0.1045 0.0142,0.0977 C '
|
||||
'0.0015,0.0934 -0.0107,0.0944 -0.0227,0.1008 C -0.0316,0.1056 -0.0348,0.1050 -0.0548,0.0944 '
|
||||
'C -0.0548,0.0944 -0.0548,0.0944 -0.0548,0.0944 Z M 0.0622,0.0961 C 0.0622,0.0860 '
|
||||
'0.1103,0.0556 0.1232,0.0575 C 0.1282,0.0582 0.1236,0.0624 0.0998,0.0785 C 0.0720,0.0973 '
|
||||
'0.0622,0.1019 0.0622,0.0961 C 0.0622,0.0961 0.0622,0.0961 0.0622,0.0961 Z M -0.1082,0.0434 '
|
||||
'C -0.1130,0.0405 -0.1179,0.0366 -0.1190,0.0348 C -0.1202,0.0329 -0.1173,0.0342 '
|
||||
'-0.1127,0.0376 C -0.1081,0.0410 -0.1002,0.0448 -0.0950,0.0460 C -0.0873,0.0478 '
|
||||
'-0.0869,0.0482 -0.0927,0.0484 C -0.0965,0.0486 -0.1035,0.0463 -0.1082,0.0434 C '
|
||||
'-0.1082,0.0434 -0.1082,0.0434 -0.1082,0.0434 Z M -0.2669,-0.0745 C -0.2692,-0.0769 '
|
||||
'-0.2803,-0.0876 -0.2917,-0.0982 C -0.3051,-0.1107 -0.3092,-0.1157 -0.3032,-0.1123 C '
|
||||
'-0.2884,-0.1036 -0.2557,-0.0702 -0.2621,-0.0702 C -0.2625,-0.0702 -0.2647,-0.0721 '
|
||||
'-0.2669,-0.0745 C -0.2669,-0.0745 -0.2669,-0.0745 -0.2669,-0.0745 Z M -0.2819,-0.0799 C '
|
||||
'-0.2848,-0.0821 -0.2865,-0.0846 -0.2858,-0.0854 C -0.2850,-0.0861 -0.2821,-0.0843 '
|
||||
'-0.2793,-0.0812 C -0.2734,-0.0747 -0.2744,-0.0742 -0.2819,-0.0799 C -0.2819,-0.0799 '
|
||||
'-0.2819,-0.0799 -0.2819,-0.0799 Z M 0.1223,-0.2523 C 0.1212,-0.2575 0.1204,-0.2674 '
|
||||
'0.1205,-0.2744 C 0.1205,-0.2744 0.1208,-0.2872 0.1208,-0.2872 C 0.1208,-0.2872 '
|
||||
'0.1234,-0.2762 0.1234,-0.2762 C 0.1249,-0.2701 0.1257,-0.2601 0.1252,-0.2540 C '
|
||||
'0.1252,-0.2540 0.1244,-0.2430 0.1244,-0.2430 C 0.1244,-0.2430 0.1223,-0.2523 '
|
||||
'0.1223,-0.2523 Z M 0.2385,0.1103 C 0.2428,0.1041 0.2531,0.0811 0.2661,0.0487 C '
|
||||
'0.2678,0.0446 0.2643,0.0469 0.2475,0.0615 C 0.2437,0.0647 0.2356,0.0684 0.2295,0.0695 C '
|
||||
'0.2234,0.0706 0.2200,0.0721 0.2219,0.0728 C 0.2302,0.0758 0.2232,0.1013 0.2141,0.1013 C '
|
||||
'0.2100,0.1013 0.2111,0.1088 0.2159,0.1135 C 0.2226,0.1203 0.2326,0.1189 0.2385,0.1103 C '
|
||||
'0.2385,0.1103 0.2385,0.1103 0.2385,0.1103 Z M -0.2337,0.0555 C -0.2337,0.0533 '
|
||||
'-0.2349,0.0515 -0.2364,0.0515 C -0.2380,0.0515 -0.2392,0.0541 -0.2392,0.0572 C '
|
||||
'-0.2392,0.0603 -0.2380,0.0621 -0.2364,0.0612 C -0.2349,0.0602 -0.2337,0.0577 '
|
||||
'-0.2337,0.0555 C -0.2337,0.0555 -0.2337,0.0555 -0.2337,0.0555 Z M 0.2101,-0.0738 C '
|
||||
'0.2147,-0.0786 0.2214,-0.0866 0.2249,-0.0916 C 0.2284,-0.0965 0.2368,-0.1038 '
|
||||
'0.2437,-0.1079 C 0.2549,-0.1144 0.2581,-0.1150 0.2750,-0.1136 C 0.2906,-0.1123 '
|
||||
'0.2965,-0.1131 0.3092,-0.1182 C 0.3292,-0.1264 0.3313,-0.1283 0.3401,-0.1470 C '
|
||||
'0.3442,-0.1557 0.3518,-0.1680 0.3569,-0.1743 C 0.3644,-0.1834 0.3652,-0.1855 '
|
||||
'0.3609,-0.1844 C 0.3549,-0.1828 0.3531,-0.1875 0.3519,-0.2081 C 0.3519,-0.2081 '
|
||||
'0.3512,-0.2202 0.3512,-0.2202 C 0.3512,-0.2202 0.3147,-0.2393 0.3147,-0.2393 C '
|
||||
'0.3147,-0.2393 0.2782,-0.2585 0.2782,-0.2585 C 0.2782,-0.2585 0.2630,-0.2462 '
|
||||
'0.2630,-0.2462 C 0.2475,-0.2335 0.2448,-0.2322 0.2281,-0.2294 C 0.2228,-0.2285 '
|
||||
'0.2116,-0.2226 0.2033,-0.2163 C 0.1950,-0.2100 0.1828,-0.2024 0.1763,-0.1996 C '
|
||||
'0.1698,-0.1967 0.1645,-0.1931 0.1645,-0.1915 C 0.1645,-0.1899 0.1600,-0.1797 '
|
||||
'0.1546,-0.1688 C 0.1546,-0.1688 0.1446,-0.1490 0.1446,-0.1490 C 0.1446,-0.1490 '
|
||||
'0.1475,-0.1139 0.1475,-0.1139 C 0.1504,-0.0782 0.1519,-0.0728 0.1635,-0.0572 C '
|
||||
'0.1635,-0.0572 0.1701,-0.0484 0.1701,-0.0484 C 0.1701,-0.0484 0.1858,-0.0566 '
|
||||
'0.1858,-0.0566 C 0.1945,-0.0612 0.2054,-0.0689 0.2101,-0.0738 C 0.2101,-0.0738 '
|
||||
'0.2101,-0.0738 0.2101,-0.0738 Z M 0.3556,-0.1387 C 0.3602,-0.1641 0.3606,-0.1736 '
|
||||
'0.3571,-0.1695 C 0.3565,-0.1688 0.3508,-0.1581 0.3444,-0.1456 C 0.3370,-0.1313 '
|
||||
'0.3305,-0.1222 0.3269,-0.1211 C 0.3213,-0.1193 0.3214,-0.1190 0.3287,-0.1137 C '
|
||||
'0.3329,-0.1106 0.3376,-0.1049 0.3392,-0.1009 C 0.3392,-0.1009 0.3419,-0.0937 '
|
||||
'0.3419,-0.0937 C 0.3419,-0.0937 0.3461,-0.1016 0.3461,-0.1016 C 0.3484,-0.1060 '
|
||||
'0.3527,-0.1227 0.3556,-0.1387 C 0.3556,-0.1387 0.3556,-0.1387 0.3556,-0.1387 Z'
|
||||
)
|
||||
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Textes source en anglais, traduits par le catalogue « skullfill »
|
||||
(locale/<langue>/LC_MESSAGES/skullfill.mo). Après toute modification
|
||||
d'un texte : python i18n.py, puis compléter po/fr.po et relancer.
|
||||
-->
|
||||
<inkscape-extension translationdomain="skullfill"
|
||||
xmlns="http://www.inkscape.org/namespace/inkscape/extension">
|
||||
<name>Skull Pattern Fill</name>
|
||||
<id>fr.alexp.skullfill</id>
|
||||
|
||||
<param name="tab" type="notebook">
|
||||
<page name="skulls" gui-text="Skulls">
|
||||
<param name="size_max" type="float" precision="2" min="0.1" max="10000"
|
||||
gui-text="Largest skull height:">30.0</param>
|
||||
<param name="size_min" type="float" precision="2" min="0.1" max="10000"
|
||||
gui-text="Smallest skull height:">10.0</param>
|
||||
<param name="unit" type="optiongroup" appearance="combo" gui-text="Unit:">
|
||||
<!-- Les unités ne se traduisent pas -->
|
||||
<option translatable="no" value="mm">mm</option>
|
||||
<option translatable="no" value="cm">cm</option>
|
||||
<option translatable="no" value="px">px</option>
|
||||
<option translatable="no" value="pt">pt</option>
|
||||
<option translatable="no" value="in">in</option>
|
||||
</param>
|
||||
<param name="spacing" type="float" precision="0" min="30" max="150"
|
||||
gui-text="Spacing (% of the smallest height):"
|
||||
gui-description="Distance between two neighbouring skulls. Below 100 %, skulls overlap and leave no gap.">70</param>
|
||||
<param name="max_rotation" type="float" precision="0" min="0" max="180"
|
||||
gui-text="Maximum tilt (°):"
|
||||
gui-description="Each skull is tilted by a random angle between minus and plus this value.">30</param>
|
||||
<param name="mirror" type="bool"
|
||||
gui-text="Randomly mirror skulls">true</param>
|
||||
<param name="seed" type="int" min="0" max="99999"
|
||||
gui-text="Random seed:"
|
||||
gui-description="Change it to get another arrangement with the same settings.">1</param>
|
||||
</page>
|
||||
|
||||
<page name="style" gui-text="Style">
|
||||
<param name="ink_color" type="color" appearance="colorbutton"
|
||||
gui-text="Ink color:">255</param>
|
||||
<param name="fill_gaps" type="bool"
|
||||
gui-text="Fill the gaps with the ink color">true</param>
|
||||
<param name="keep_original" type="bool"
|
||||
gui-text="Keep the original shape">true</param>
|
||||
</page>
|
||||
|
||||
<page name="help" gui-text="Help">
|
||||
<!-- Schéma généré par docs/schema_parametres.py, en anglais :
|
||||
Inkscape ne traduit pas le chemin d'une image. Affiché aux
|
||||
3/4 du PNG (900 px) pour limiter la hauteur de l'onglet. -->
|
||||
<image width="675" height="617">images/parameters_en.png</image>
|
||||
<separator/>
|
||||
<!-- Un paragraphe par ligne : Inkscape le replie à la largeur de
|
||||
l'onglet ; des retours à la ligne forcés le laisseraient étroit. -->
|
||||
<label xml:space="preserve">Select one or more shapes (paths, rectangles, circles, ellipses or groups of them), then run the extension. Each shape is filled with skulls of different sizes, tilted and mirrored at random, cut to the outline of the shape.
|
||||
|
||||
Skull heights range from the smallest to the largest: there are many small skulls and a few large ones, drawn on top. The spacing sets how tightly they are packed; below 100 % they overlap and cover the whole shape.
|
||||
|
||||
The result is made for laser engraving: it contains only the ink that is actually visible. Lines hidden by the skulls on top are removed and skulls on the edge are trimmed; no mask, clone or white object is written, so the laser engraves nothing hidden.
|
||||
|
||||
The result is a group of filled paths placed just above each shape. Large fills take time, about 5 seconds per 100 skulls. Change the random seed to get another arrangement.</label>
|
||||
</page>
|
||||
</param>
|
||||
|
||||
<effect>
|
||||
<object-type>all</object-type>
|
||||
<effects-menu>
|
||||
<submenu name="AlexDesign"/>
|
||||
</effects-menu>
|
||||
</effect>
|
||||
|
||||
<script>
|
||||
<command location="inx" interpreter="python">skull_fill.py</command>
|
||||
</script>
|
||||
</inkscape-extension>
|
||||
@@ -0,0 +1,224 @@
|
||||
#!/usr/bin/env python3
|
||||
# coding=utf-8
|
||||
"""
|
||||
Extension Inkscape : remplit les formes selectionnees de tetes de mort,
|
||||
pretes pour la gravure laser.
|
||||
|
||||
Comme dans le motif de reference (doc/patern.png), un meme crane (dessine
|
||||
d'apres doc/dessin.svg, sans ses cornes) est repete a des tailles, des
|
||||
angles et en miroir differents, sans laisser de vide : les petits dessous,
|
||||
les grands par-dessus.
|
||||
|
||||
Une decoupeuse laser grave tout trait present dans le fichier, meme cache
|
||||
ou masque. Le resultat ne contient donc que l'encre reellement visible :
|
||||
pour chaque crane, son trait moins ce que couvrent les cranes du dessus,
|
||||
limite a la forme ; plus, en option, les interstices entre les cranes.
|
||||
Aucun masque, aucun clone, aucun objet blanc.
|
||||
|
||||
La logique vit dans `skull_fill_core` (et `boolean_ops`), sans inkex.
|
||||
"""
|
||||
|
||||
import math
|
||||
import os
|
||||
import sys
|
||||
|
||||
import inkex
|
||||
from inkex.localization import localize
|
||||
from inkex.units import convert_unit
|
||||
|
||||
# L'extension vit dans son propre sous-dossier des extensions Inkscape, qui
|
||||
# n'est pas forcement dans sys.path : on l'y ajoute pour trouver skull_fill_core.
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
from skull_fill_core import ( # noqa: E402
|
||||
Region, estimate_count, parse_color, rings_to_d, skull_placements,
|
||||
visible_gaps, visible_skulls)
|
||||
|
||||
# Au-dela, le calcul (environ 5 s pour 100 cranes) devient trop long.
|
||||
MAX_SKULLS = 10000
|
||||
|
||||
|
||||
def use_system_language():
|
||||
"""Renseigne LANGUAGE avec la langue du systeme si rien ne la fixe.
|
||||
|
||||
Sous Windows, Inkscape regle sur « langue du systeme » ne transmet aucune
|
||||
variable de langue au script : gettext retomberait sur l'anglais alors que
|
||||
la boite de dialogue, traduite par Inkscape lui-meme, est dans la langue
|
||||
de l'utilisateur.
|
||||
"""
|
||||
if any(os.environ.get(name) for name in ("LANGUAGE", "LC_ALL", "LC_MESSAGES", "LANG")):
|
||||
return
|
||||
try:
|
||||
import ctypes
|
||||
import locale
|
||||
language = locale.windows_locale.get(
|
||||
ctypes.windll.kernel32.GetUserDefaultUILanguage())
|
||||
except Exception: # pylint: disable=broad-except
|
||||
return # hors Windows : LANG est toujours defini
|
||||
if language:
|
||||
os.environ["LANGUAGE"] = language
|
||||
|
||||
|
||||
# Installe _() dans les builtins : catalogue « skullfill » de la langue
|
||||
# de l'interface (Inkscape transmet domaine et dossier par l'environnement),
|
||||
# textes anglais d'origine sinon.
|
||||
use_system_language()
|
||||
localize()
|
||||
|
||||
|
||||
def uu_per_mm(svg):
|
||||
"""Unites utilisateur par millimetre, comme Inkscape les affiche.
|
||||
|
||||
svg.unittouu() devine l'unite du document par arrondi a l'unite connue la
|
||||
plus proche : il se trompe des que l'echelle n'est pas standard (page
|
||||
redimensionnee). On prend le rapport reel page / viewBox ; Inkscape
|
||||
applique une echelle uniforme (preserveAspectRatio « meet »), soit la
|
||||
plus petite des deux.
|
||||
"""
|
||||
try:
|
||||
vb_w, vb_h = svg.viewbox_width, svg.viewbox_height
|
||||
page_w = svg.to_dimensional(svg.viewport_width, "mm")
|
||||
page_h = svg.to_dimensional(svg.viewport_height, "mm")
|
||||
except AttributeError: # inkex anterieur a 1.2
|
||||
return svg.unittouu("1mm")
|
||||
if not (vb_w and vb_h and page_w and page_h):
|
||||
return svg.unittouu("1mm")
|
||||
return 1 / min(page_w / vb_w, page_h / vb_h)
|
||||
|
||||
|
||||
def length_to_uu(svg, value, unit="mm"):
|
||||
"""Longueur reelle (valeur + unite) -> unites utilisateur du document."""
|
||||
return convert_unit("{}{}".format(value, unit), "mm") * uu_per_mm(svg)
|
||||
|
||||
|
||||
class SkullFill(inkex.EffectExtension):
|
||||
"""Remplit chaque forme selectionnee de tetes de mort (encre visible seule)."""
|
||||
|
||||
def add_arguments(self, pars):
|
||||
# Un argument par <param> du .inx, memes noms et memes valeurs par defaut.
|
||||
pars.add_argument("--tab", default="skulls")
|
||||
pars.add_argument("--size_max", type=float, default=30.0)
|
||||
pars.add_argument("--size_min", type=float, default=10.0)
|
||||
pars.add_argument("--unit", default="mm")
|
||||
pars.add_argument("--spacing", type=float, default=70.0)
|
||||
pars.add_argument("--max_rotation", type=float, default=30.0)
|
||||
pars.add_argument("--mirror", type=inkex.Boolean, default=True)
|
||||
pars.add_argument("--seed", type=int, default=1)
|
||||
pars.add_argument("--ink_color", default="255")
|
||||
pars.add_argument("--fill_gaps", type=inkex.Boolean, default=True)
|
||||
pars.add_argument("--keep_original", type=inkex.Boolean, default=True)
|
||||
|
||||
def effect(self):
|
||||
opt = self.options
|
||||
|
||||
elements = list(self.svg.selection.values())
|
||||
if not elements:
|
||||
inkex.errormsg(_("Select at least one shape to fill."))
|
||||
return
|
||||
|
||||
shapes = []
|
||||
for elem in elements:
|
||||
shapes.extend(self.fillable(elem))
|
||||
if not shapes:
|
||||
inkex.errormsg(_("No fillable shape in the selection: select paths, "
|
||||
"rectangles, circles, ellipses or groups of them."))
|
||||
return
|
||||
|
||||
size_min = length_to_uu(self.svg, opt.size_min, opt.unit)
|
||||
size_max = length_to_uu(self.svg, opt.size_max, opt.unit)
|
||||
if size_min <= 0 or size_max <= 0:
|
||||
inkex.errormsg(_("The skull sizes must be strictly positive."))
|
||||
return
|
||||
if size_max < size_min:
|
||||
size_min, size_max = size_max, size_min
|
||||
|
||||
self.ink = parse_color(opt.ink_color, ("#000000", 1.0))
|
||||
|
||||
regions = [(elem, self.rings(elem)) for elem in shapes]
|
||||
spacing = opt.spacing / 100.0
|
||||
total = sum(estimate_count(rings, size_min, spacing) for _elem, rings in regions)
|
||||
if total > MAX_SKULLS:
|
||||
inkex.errormsg(_("About {} skulls would be needed. Increase the minimum "
|
||||
"size or the spacing.").format(total))
|
||||
return
|
||||
|
||||
# Coordonnees au 1/500 de la plus petite hauteur : bien sous la
|
||||
# finesse d'un laser, sans alourdir le fichier.
|
||||
self.precision = max(0, int(math.ceil(-math.log10(size_min / 500.0))))
|
||||
|
||||
for elem, rings in regions:
|
||||
placements = skull_placements(
|
||||
rings, size_min, size_max, spacing=spacing,
|
||||
max_rotation=opt.max_rotation, mirror=opt.mirror, seed=opt.seed)
|
||||
self.process(elem, Region(rings), placements)
|
||||
|
||||
@staticmethod
|
||||
def fillable(elem):
|
||||
"""Formes a remplir : l'element lui-meme, ou les formes d'un groupe."""
|
||||
if isinstance(elem, inkex.Group):
|
||||
return [child for child in elem.descendants()
|
||||
if isinstance(child, inkex.ShapeElement)
|
||||
and not isinstance(child, (inkex.Group, inkex.TextElement))
|
||||
and child.get_path() is not None]
|
||||
if isinstance(elem, (inkex.TextElement, inkex.Image)) or \
|
||||
not isinstance(elem, inkex.ShapeElement):
|
||||
return []
|
||||
return [elem]
|
||||
|
||||
@staticmethod
|
||||
def absolute_path(elem):
|
||||
return elem.path.transform(elem.composed_transform())
|
||||
|
||||
def rings(self, elem):
|
||||
"""Contour de la forme en coordonnees absolues, courbes aplaties."""
|
||||
csp = self.absolute_path(elem).to_superpath()
|
||||
inkex.bezier.cspsubdiv(csp, 0.1)
|
||||
return [[(point[1][0], point[1][1]) for point in sub] for sub in csp if len(sub) > 2]
|
||||
|
||||
def ink_path(self, rings, label=None):
|
||||
"""Chemin rempli de la couleur de l'encre, en regle pair-impair."""
|
||||
color, opacity = self.ink
|
||||
path = inkex.PathElement()
|
||||
path.set("d", rings_to_d(rings, self.precision))
|
||||
path.style = inkex.Style({
|
||||
"fill": color, "fill-opacity": str(opacity),
|
||||
"fill-rule": "evenodd", "stroke": "none"})
|
||||
if label:
|
||||
path.label = label
|
||||
return path
|
||||
|
||||
def process(self, elem, region, placements):
|
||||
"""Ecrit le remplissage d'une forme, juste au-dessus d'elle."""
|
||||
opt = self.options
|
||||
parent = elem.getparent()
|
||||
group = inkex.Group()
|
||||
group.label = _("Skull fill")
|
||||
if parent is not None:
|
||||
# Resultat calcule en coordonnees absolues du document : on
|
||||
# neutralise la transformation heritee du parent d'accueil.
|
||||
parent_transform = parent.composed_transform()
|
||||
if parent_transform != inkex.Transform():
|
||||
group.transform = -parent_transform
|
||||
parent.insert(parent.index(elem) + 1, group)
|
||||
else:
|
||||
self.svg.add(group)
|
||||
|
||||
if opt.fill_gaps:
|
||||
# Interstices : la forme moins toutes les silhouettes, comme les
|
||||
# ombres entre les cranes du motif de reference.
|
||||
gaps = visible_gaps(placements, region)
|
||||
if gaps:
|
||||
group.add(self.ink_path(gaps, _("Gaps")))
|
||||
|
||||
# Un chemin par crane visible : son trait, moins ce que cachent les
|
||||
# cranes du dessus, limite a la forme. Les chemins ne se recouvrent
|
||||
# pas : le laser ne grave rien de cache.
|
||||
for _placement, rings in visible_skulls(placements, region):
|
||||
group.add(self.ink_path(rings))
|
||||
|
||||
if not opt.keep_original:
|
||||
elem.delete()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
SkullFill().run()
|
||||
@@ -0,0 +1,585 @@
|
||||
# coding=utf-8
|
||||
"""
|
||||
Noyau de calcul de l'extension « Skull Pattern Fill », sans dependance a inkex.
|
||||
|
||||
Testable avec pytest seul et reutilisable hors Inkscape (scripts, schema
|
||||
des parametres).
|
||||
|
||||
Le remplissage reprend le principe du motif de reference (doc/patern.png) :
|
||||
un meme crane, repete a des tailles, des angles et en miroir differents, les
|
||||
cranes s'empilant sans laisser de vide ; les petits sont dessines d'abord,
|
||||
les grands viennent par-dessus.
|
||||
|
||||
Conventions :
|
||||
- un contour (`rings`) est une liste d'anneaux, chaque anneau etant une liste
|
||||
de points (x, y) fermee implicitement ; les trous suivent la regle pair-impair ;
|
||||
- une polyligne est une liste de points (x, y) ;
|
||||
- une boucle de Bezier est une liste de segments cubiques (p0, c1, c2, p3),
|
||||
fermee ;
|
||||
- le crane est dessine dans un repere unite : centre en (0, 0), hauteur 1
|
||||
(y de -0,5 a 0,5), largeur 0,80 ; c'est le dessin de doc/dessin.svg sans
|
||||
ses cornes, vu de trois quarts et tourne vers la gauche ;
|
||||
- l'axe y est oriente vers le bas (repere SVG).
|
||||
"""
|
||||
|
||||
import math
|
||||
import random
|
||||
|
||||
from skull_drawing import BODY_D, INK_D
|
||||
|
||||
|
||||
def parse_color(value, default=("#b3b3b3", 1.0)):
|
||||
"""Couleur Inkscape (entier RGBA decimal ou 0x..., ou #rrggbb[aa]).
|
||||
|
||||
Renvoie (couleur CSS #rrggbb, opacite entre 0 et 1). Le parametre
|
||||
« color » d'Inkscape arrive sous forme d'entier RGBA ; on le decode
|
||||
nous-memes pour ne pas dependre de l'API couleur d'inkex, qui a change
|
||||
entre les versions 1.x.
|
||||
"""
|
||||
text = str(value).strip()
|
||||
try:
|
||||
if text.startswith("#"):
|
||||
digits = text[1:]
|
||||
if len(digits) == 3:
|
||||
digits = "".join(c * 2 for c in digits)
|
||||
if len(digits) == 6:
|
||||
digits += "ff"
|
||||
if len(digits) != 8:
|
||||
return default
|
||||
number = int(digits, 16)
|
||||
else:
|
||||
number = int(text, 0)
|
||||
except ValueError:
|
||||
return default
|
||||
number &= 0xFFFFFFFF
|
||||
red, green, blue = (number >> 24) & 255, (number >> 16) & 255, (number >> 8) & 255
|
||||
alpha = (number & 255) / 255.0
|
||||
return "#{:02x}{:02x}{:02x}".format(red, green, blue), round(alpha, 4)
|
||||
|
||||
|
||||
def polylines_to_d(polylines, precision=4):
|
||||
"""Donnees `d` d'un chemin SVG : une polyligne par sous-chemin."""
|
||||
fmt = "{:.%df},{:.%df}" % (precision, precision)
|
||||
parts = []
|
||||
for polyline in polylines:
|
||||
if len(polyline) < 2:
|
||||
continue
|
||||
parts.append("M " + fmt.format(*polyline[0]))
|
||||
parts.extend("L " + fmt.format(*point) for point in polyline[1:])
|
||||
return " ".join(parts)
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Le crane
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
def parse_loops(d):
|
||||
"""Donnees `d` en commandes absolues M, C, Z -> boucles de Bezier.
|
||||
|
||||
Ne lit que la forme produite par docs/extraire_crane.py (et par
|
||||
loops_to_d) : un sous-chemin par boucle, uniquement des cubiques.
|
||||
"""
|
||||
loops, loop, start, current = [], None, None, None
|
||||
tokens = d.replace(",", " ").split()
|
||||
i = 0
|
||||
while i < len(tokens):
|
||||
command = tokens[i]
|
||||
if command == "M":
|
||||
start = current = (float(tokens[i + 1]), float(tokens[i + 2]))
|
||||
loop = []
|
||||
i += 3
|
||||
elif command == "C":
|
||||
values = [float(v) for v in tokens[i + 1:i + 7]]
|
||||
c1, c2, p3 = tuple(values[0:2]), tuple(values[2:4]), tuple(values[4:6])
|
||||
loop.append((current, c1, c2, p3))
|
||||
current = p3
|
||||
i += 7
|
||||
elif command == "Z":
|
||||
if current != start:
|
||||
loop.append((current, current, start, start))
|
||||
loops.append(loop)
|
||||
current = start
|
||||
i += 1
|
||||
else:
|
||||
raise ValueError("commande non geree : {}".format(command))
|
||||
return loops
|
||||
|
||||
|
||||
_GEOMETRY = None
|
||||
|
||||
|
||||
def skull_geometry():
|
||||
"""Le crane dans son repere unite : (silhouette, encre).
|
||||
|
||||
Dessin de doc/dessin.svg, cornes retirees (donnees de skull_drawing.py,
|
||||
regenerees par docs/extraire_crane.py). `silhouette` est le contour
|
||||
exterieur, a remplir de la couleur de l'os pour cacher les cranes du
|
||||
dessous ; `encre` est le trait et les ombres, un seul chemin a remplir
|
||||
en regle non nulle (les trous blancs tournent en sens inverse).
|
||||
"""
|
||||
global _GEOMETRY
|
||||
if _GEOMETRY is None:
|
||||
_GEOMETRY = (parse_loops(BODY_D), parse_loops(INK_D))
|
||||
return _GEOMETRY
|
||||
|
||||
|
||||
def placement_matrix(x, y, size, angle=0.0, mirror=False):
|
||||
"""Matrice affine (a, b, c, d, e, f) du repere unite vers le document.
|
||||
|
||||
Ordre : miroir horizontal, mise a l'echelle `size`, rotation `angle`
|
||||
(degres, sens horaire a l'ecran comme dans Inkscape), translation.
|
||||
"""
|
||||
rad = math.radians(angle)
|
||||
cos_a, sin_a = math.cos(rad) * size, math.sin(rad) * size
|
||||
sx = -1.0 if mirror else 1.0
|
||||
return (cos_a * sx, sin_a * sx, -sin_a, cos_a, x, y)
|
||||
|
||||
|
||||
def apply_matrix(matrix, point):
|
||||
a, b, c, d, e, f = matrix
|
||||
return (a * point[0] + c * point[1] + e, b * point[0] + d * point[1] + f)
|
||||
|
||||
|
||||
def loops_to_d(loops, matrix=(1, 0, 0, 1, 0, 0), precision=3):
|
||||
"""Donnees `d` (M, C, Z absolus) de boucles de Bezier transformees.
|
||||
|
||||
Une transformation affine laisse une courbe de Bezier de meme forme :
|
||||
transformer les points de controle suffit, le chemin produit n'a pas
|
||||
besoin d'attribut `transform`.
|
||||
"""
|
||||
fmt = "{:.%df},{:.%df}" % (precision, precision)
|
||||
parts = []
|
||||
for loop in loops:
|
||||
start = apply_matrix(matrix, loop[0][0])
|
||||
parts.append("M " + fmt.format(*start))
|
||||
for _p0, c1, c2, p3 in loop:
|
||||
parts.append("C " + " ".join(fmt.format(*apply_matrix(matrix, p))
|
||||
for p in (c1, c2, p3)))
|
||||
parts.append("Z")
|
||||
return " ".join(parts)
|
||||
|
||||
|
||||
def skull_paths(placement, precision=3):
|
||||
"""(d de la silhouette, d de l'encre) d'un crane place."""
|
||||
matrix = placement_matrix(*placement)
|
||||
return tuple(loops_to_d(loops, matrix, precision) for loops in skull_geometry())
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Region a remplir
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
def rings_bbox(rings):
|
||||
xs = [x for ring in rings for x, _y in ring]
|
||||
ys = [y for ring in rings for _x, y in ring]
|
||||
if not xs:
|
||||
return None
|
||||
return min(xs), min(ys), max(xs), max(ys)
|
||||
|
||||
|
||||
def point_in_rings(point, rings):
|
||||
"""Point dans la region (regle pair-impair, les trous sont exclus)."""
|
||||
x, y = point
|
||||
inside = False
|
||||
for ring in rings:
|
||||
n = len(ring)
|
||||
for i in range(n):
|
||||
x1, y1 = ring[i]
|
||||
x2, y2 = ring[(i + 1) % n]
|
||||
if (y1 > y) != (y2 > y):
|
||||
if x < x1 + (y - y1) * (x2 - x1) / (y2 - y1):
|
||||
inside = not inside
|
||||
return inside
|
||||
|
||||
|
||||
def distance_to_rings(point, rings):
|
||||
"""Distance d'un point au bord de la region."""
|
||||
px, py = point
|
||||
best = float("inf")
|
||||
for ring in rings:
|
||||
n = len(ring)
|
||||
for i in range(n):
|
||||
x1, y1 = ring[i]
|
||||
x2, y2 = ring[(i + 1) % n]
|
||||
dx, dy = x2 - x1, y2 - y1
|
||||
length2 = dx * dx + dy * dy
|
||||
t = 0.0 if not length2 else max(0.0, min(1.0, ((px - x1) * dx + (py - y1) * dy) / length2))
|
||||
best = min(best, math.hypot(px - x1 - t * dx, py - y1 - t * dy))
|
||||
return best
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Geometrie visible
|
||||
#
|
||||
# Destination : la gravure laser. La machine grave tout trait present dans
|
||||
# le fichier, meme cache sous un autre objet ou rendu invisible par un
|
||||
# masque. On ne produit donc que l'encre reellement visible :
|
||||
# - pour chaque crane, son encre, limitee a la forme, moins les silhouettes
|
||||
# de tous les cranes poses au-dessus de lui ;
|
||||
# - les interstices : la forme moins l'union de toutes les silhouettes.
|
||||
# Les silhouettes elles-memes (le blanc de l'os) ne sont pas ecrites.
|
||||
#
|
||||
# Les calculs se font sur des polygones (courbes aplaties) avec le moteur
|
||||
# booleen de boolean_ops. L'encre se lit en regle pair-impair (equivalente,
|
||||
# pour ce dessin, a sa regle non nulle : ses trous tournent en sens inverse
|
||||
# et ne se chevauchent pas) ; les silhouettes, toutes remises dans le meme
|
||||
# sens, en regle non nulle, ce qui revient a leur union.
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
IDENTITY = (1.0, 0.0, 0.0, 1.0, 0.0, 0.0)
|
||||
|
||||
|
||||
def _bezier_point(q, t):
|
||||
s = 1.0 - t
|
||||
a, b, c, d = s * s * s, 3 * s * s * t, 3 * s * t * t, t * t * t
|
||||
return (a * q[0][0] + b * q[1][0] + c * q[2][0] + d * q[3][0],
|
||||
a * q[0][1] + b * q[1][1] + c * q[2][1] + d * q[3][1])
|
||||
|
||||
|
||||
def flatten_loops(loops, matrix=IDENTITY, step=0.01):
|
||||
"""Boucles de Bezier transformees -> anneaux (polygones fermes).
|
||||
|
||||
Chaque courbe est decoupee en morceaux d'au plus `step` environ (longueur
|
||||
du polygone de controle), 24 au plus.
|
||||
"""
|
||||
rings = []
|
||||
for loop in loops:
|
||||
ring = []
|
||||
for segment in loop:
|
||||
q = [apply_matrix(matrix, p) for p in segment]
|
||||
length = sum(math.hypot(b[0] - a[0], b[1] - a[1]) for a, b in zip(q, q[1:]))
|
||||
count = max(1, min(24, int(math.ceil(length / step))))
|
||||
ring.extend(_bezier_point(q, k / count) for k in range(count))
|
||||
if len(ring) >= 3:
|
||||
rings.append(ring)
|
||||
return rings
|
||||
|
||||
|
||||
def simplify_ring(ring, tolerance):
|
||||
"""Anneau simplifie (Douglas-Peucker) : ecart au trace d'origine <= tolerance."""
|
||||
n = len(ring)
|
||||
if n < 4:
|
||||
return ring
|
||||
# On coupe l'anneau en deux au point le plus eloigne du premier.
|
||||
far = max(range(n), key=lambda i: (ring[i][0] - ring[0][0]) ** 2 + (ring[i][1] - ring[0][1]) ** 2)
|
||||
keep = [False] * (n + 1)
|
||||
keep[0] = keep[far] = keep[n] = True
|
||||
points = ring + [ring[0]]
|
||||
stack = [(0, far), (far, n)]
|
||||
while stack:
|
||||
i, j = stack.pop()
|
||||
a, b = points[i], points[j]
|
||||
dx, dy = b[0] - a[0], b[1] - a[1]
|
||||
norm = math.hypot(dx, dy)
|
||||
best, index = tolerance, None
|
||||
for k in range(i + 1, j):
|
||||
p = points[k]
|
||||
if norm:
|
||||
dist = abs(dx * (p[1] - a[1]) - dy * (p[0] - a[0])) / norm
|
||||
else:
|
||||
dist = math.hypot(p[0] - a[0], p[1] - a[1])
|
||||
if dist > best:
|
||||
best, index = dist, k
|
||||
if index is not None:
|
||||
keep[index] = True
|
||||
stack.append((i, index))
|
||||
stack.append((index, j))
|
||||
result = [points[k] for k in range(n) if keep[k]]
|
||||
return result if len(result) >= 3 else ring
|
||||
|
||||
|
||||
def rings_to_d(rings, precision=2):
|
||||
"""Donnees `d` compactes d'anneaux fermes : M absolu, puis l relatifs.
|
||||
|
||||
Les ecarts sont pris entre points deja arrondis : ils ne cumulent pas
|
||||
d'erreur. Les points confondus apres arrondi sont omis.
|
||||
"""
|
||||
scale = 10 ** precision
|
||||
|
||||
def num(v):
|
||||
text = "{:.{}f}".format(v / scale, precision).rstrip("0").rstrip(".")
|
||||
return "0" if text in ("", "-0") else text
|
||||
|
||||
parts = []
|
||||
for ring in rings:
|
||||
pts = [(int(round(x * scale)), int(round(y * scale))) for x, y in ring]
|
||||
kept = [pts[0]]
|
||||
for p in pts[1:]:
|
||||
if p != kept[-1]:
|
||||
kept.append(p)
|
||||
if len(kept) < 3:
|
||||
continue
|
||||
parts.append("M{},{}l".format(num(kept[0][0]), num(kept[0][1])))
|
||||
parts.append(" ".join("{},{}".format(num(b[0] - a[0]), num(b[1] - a[1]))
|
||||
for a, b in zip(kept, kept[1:])))
|
||||
parts.append("z")
|
||||
return "".join(parts)
|
||||
|
||||
|
||||
def ring_area(ring):
|
||||
"""Aire signee (positive dans le sens horaire a l'ecran, y vers le bas)."""
|
||||
return 0.5 * sum(a[0] * b[1] - b[0] * a[1] for a, b in zip(ring, ring[1:] + ring[:1]))
|
||||
|
||||
|
||||
def _ring_bbox(ring):
|
||||
xs = [p[0] for p in ring]
|
||||
ys = [p[1] for p in ring]
|
||||
return min(xs), min(ys), max(xs), max(ys)
|
||||
|
||||
|
||||
def _boxes_overlap(a, b):
|
||||
return a[0] <= b[2] and b[0] <= a[2] and a[1] <= b[3] and b[1] <= a[3]
|
||||
|
||||
|
||||
class _EdgeGrid(object):
|
||||
"""Cases traversees par les cotes d'anneaux : dit vite si une boite
|
||||
est loin de tout bord."""
|
||||
|
||||
def __init__(self, rings):
|
||||
edges = [(r[i], r[(i + 1) % len(r)]) for r in rings for i in range(len(r))]
|
||||
total = sum(math.hypot(b[0] - a[0], b[1] - a[1]) for a, b in edges)
|
||||
self.cell = max(4.0 * total / max(len(edges), 1), 1e-9)
|
||||
self.cells = set()
|
||||
c = self.cell
|
||||
for a, b in edges:
|
||||
for i in range(int(math.floor(min(a[0], b[0]) / c)), int(math.floor(max(a[0], b[0]) / c)) + 1):
|
||||
for j in range(int(math.floor(min(a[1], b[1]) / c)), int(math.floor(max(a[1], b[1]) / c)) + 1):
|
||||
self.cells.add((i, j))
|
||||
|
||||
def touches(self, box):
|
||||
c = self.cell
|
||||
for i in range(int(math.floor(box[0] / c)), int(math.floor(box[2] / c)) + 1):
|
||||
for j in range(int(math.floor(box[1] / c)), int(math.floor(box[3] / c)) + 1):
|
||||
if (i, j) in self.cells:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
class Region(object):
|
||||
"""Region a remplir : anneaux en regle pair-impair."""
|
||||
|
||||
def __init__(self, rings):
|
||||
self.rings = [ring for ring in rings if len(ring) >= 3]
|
||||
self.box = rings_bbox(self.rings)
|
||||
self.grid = _EdgeGrid(self.rings)
|
||||
|
||||
def contains(self, point):
|
||||
return point_in_rings(point, self.rings)
|
||||
|
||||
|
||||
|
||||
_RADIUS = None
|
||||
|
||||
|
||||
def skull_radius():
|
||||
"""Rayon du disque contenant le crane, pour une hauteur 1."""
|
||||
global _RADIUS
|
||||
if _RADIUS is None:
|
||||
body, _ink = skull_geometry()
|
||||
_RADIUS = max(math.hypot(*p) for seg in body[0] for p in seg)
|
||||
return _RADIUS
|
||||
|
||||
|
||||
_FLAT = {}
|
||||
|
||||
|
||||
def _flat_skull(step):
|
||||
"""Crane aplati et simplifie une fois pour toutes, dans son repere unite.
|
||||
|
||||
Renvoie (silhouette, anneaux d'encre). La silhouette est remise dans le
|
||||
sens horaire, pour que l'union des silhouettes en regle non nulle ne
|
||||
fasse pas de trou la ou deux cranes de sens opposes se chevauchent.
|
||||
"""
|
||||
if step not in _FLAT:
|
||||
body, ink = skull_geometry()
|
||||
# Ecart tolere : 0,25 % de la hauteur (moins d'un dixieme de
|
||||
# millimetre sur un crane de 30 mm, sous la finesse d'un laser).
|
||||
tolerance = 0.25 * step
|
||||
outline = simplify_ring(flatten_loops(body, step=step)[0], tolerance)
|
||||
if ring_area(outline) < 0:
|
||||
outline = outline[::-1]
|
||||
rings = [simplify_ring(ring, tolerance) for ring in flatten_loops(ink, step=step)]
|
||||
_FLAT[step] = (outline, rings)
|
||||
return _FLAT[step]
|
||||
|
||||
|
||||
def _move(ring, matrix):
|
||||
a, b, c, d, e, f = matrix
|
||||
return [(a * x + c * y + e, b * x + d * y + f) for x, y in ring]
|
||||
|
||||
|
||||
class _Placed(object):
|
||||
"""Crane place : silhouette et encre en coordonnees du document."""
|
||||
|
||||
def __init__(self, placement, step):
|
||||
outline, rings = _flat_skull(step)
|
||||
matrix = placement_matrix(*placement)
|
||||
self.placement = placement
|
||||
self.body = _move(outline, matrix)
|
||||
if placement[4]:
|
||||
# Le miroir inverse le sens de parcours : on le retablit.
|
||||
self.body.reverse()
|
||||
self.box = _ring_bbox(self.body)
|
||||
self.ink = [_move(ring, matrix) for ring in rings]
|
||||
|
||||
|
||||
def visible_skulls(placements, region, step=0.01, progress=None):
|
||||
"""Encre visible de chaque crane : [(placement, anneaux pair-impair)].
|
||||
|
||||
`placements` est dans l'ordre de dessin (du dessous vers le dessus).
|
||||
Un crane entierement cache n'apparait pas. `progress(k, total)`, s'il est
|
||||
donne, est appele apres chaque crane.
|
||||
"""
|
||||
from boolean_ops import boolean
|
||||
|
||||
skulls = [_Placed(p, step) for p in placements]
|
||||
# Index des silhouettes par cases, pour trouver vite celles du dessus.
|
||||
cell = max((max(s.box[2] - s.box[0], s.box[3] - s.box[1]) for s in skulls), default=1.0)
|
||||
grid = {}
|
||||
for k, s in enumerate(skulls):
|
||||
for i in range(int(math.floor(s.box[0] / cell)), int(math.floor(s.box[2] / cell)) + 1):
|
||||
for j in range(int(math.floor(s.box[1] / cell)), int(math.floor(s.box[3] / cell)) + 1):
|
||||
grid.setdefault((i, j), []).append(k)
|
||||
|
||||
result = []
|
||||
for k, skull in enumerate(skulls):
|
||||
above = set()
|
||||
box = skull.box
|
||||
for i in range(int(math.floor(box[0] / cell)), int(math.floor(box[2] / cell)) + 1):
|
||||
for j in range(int(math.floor(box[1] / cell)), int(math.floor(box[3] / cell)) + 1):
|
||||
for other in grid.get((i, j), ()):
|
||||
if other > k and _boxes_overlap(box, skulls[other].box):
|
||||
above.add(other)
|
||||
covers = [skulls[o] for o in sorted(above)]
|
||||
|
||||
border = region.grid.touches(box)
|
||||
if not border and not region.contains(skull.body[0]):
|
||||
# Loin du bord et dehors : entierement hors de la forme.
|
||||
if progress:
|
||||
progress(k + 1, len(skulls))
|
||||
continue
|
||||
if not covers and not border:
|
||||
# Ni recouvert ni au bord : toute l'encre est visible.
|
||||
result.append((skull.placement, list(skull.ink)))
|
||||
if progress:
|
||||
progress(k + 1, len(skulls))
|
||||
continue
|
||||
|
||||
# Partie visible de la silhouette : petit polygone, vite calcule.
|
||||
# Vide, le crane est entierement cache.
|
||||
sets = [([skull.body], "nonzero"), ([c.body for c in covers], "nonzero")]
|
||||
if border:
|
||||
sets.append((region.rings, "evenodd"))
|
||||
shown = boolean(sets, lambda inside: inside[0] and not inside[1] and inside[2])
|
||||
else:
|
||||
shown = boolean(sets, lambda inside: inside[0] and not inside[1])
|
||||
kept = []
|
||||
if shown:
|
||||
# Les anneaux d'encre loin du bord de cette partie visible sont
|
||||
# gardes ou ecartes d'un coup ; les autres sont intersectes avec
|
||||
# elle (l'intersection se distribue sur le OU exclusif).
|
||||
edges = _EdgeGrid(shown)
|
||||
work = []
|
||||
for ring in skull.ink:
|
||||
ring_box = _ring_bbox(ring)
|
||||
if edges.touches(ring_box):
|
||||
work.append(ring)
|
||||
elif point_in_rings(ring[0], shown):
|
||||
kept.append(ring)
|
||||
if work:
|
||||
kept.extend(boolean([(work, "evenodd"), (shown, "evenodd")],
|
||||
lambda inside: inside[0] and inside[1]))
|
||||
if kept:
|
||||
result.append((skull.placement, kept))
|
||||
if progress:
|
||||
progress(k + 1, len(skulls))
|
||||
return result
|
||||
|
||||
|
||||
def visible_gaps(placements, region, step=0.01):
|
||||
"""Interstices : la forme moins l'union des silhouettes des cranes."""
|
||||
from boolean_ops import boolean
|
||||
bodies = [_Placed(p, step).body for p in placements]
|
||||
return boolean([(region.rings, "evenodd"), (bodies, "nonzero")],
|
||||
lambda inside: inside[0] and not inside[1])
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Placement
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
def random_size(rng, size_min, size_max, exponent=3.0):
|
||||
"""Taille tiree selon une loi de puissance tronquee sur [min, max].
|
||||
|
||||
Densite proportionnelle a s^-exponent : beaucoup de petits cranes, peu
|
||||
de grands ; avec 3, chaque octave de tailles couvre une surface
|
||||
comparable, comme dans le motif de reference.
|
||||
"""
|
||||
if size_max <= size_min:
|
||||
return size_min
|
||||
k = 1.0 - exponent
|
||||
lo, hi = size_min ** k, size_max ** k
|
||||
return (lo + rng.random() * (hi - lo)) ** (1.0 / k)
|
||||
|
||||
|
||||
def estimate_count(rings, size_min, spacing):
|
||||
"""Nombre de positions candidates (pour refuser un calcul demesure)."""
|
||||
box = rings_bbox(rings)
|
||||
if box is None or size_min <= 0 or spacing <= 0:
|
||||
return 0
|
||||
step = size_min * spacing
|
||||
return int(((box[2] - box[0]) / step + 2) * ((box[3] - box[1]) / step + 2))
|
||||
|
||||
|
||||
def skull_placements(rings, size_min, size_max, spacing=0.7, max_rotation=30.0,
|
||||
mirror=True, seed=1, origin=(0.0, 0.0)):
|
||||
"""Positions des cranes couvrant la region.
|
||||
|
||||
Une grille, de pas `spacing` x taille minimale, decalee une ligne sur
|
||||
deux et secouee au hasard, donne une position par case : la couverture
|
||||
est assuree par les petits cranes. Chaque position recoit une taille
|
||||
(loi de puissance), un angle dans [-max_rotation, max_rotation] et un
|
||||
miroir aleatoire. On ne garde que les cranes qui touchent la region.
|
||||
|
||||
`origin` cale la grille (origine du document par defaut) : deux formes
|
||||
voisines remplies avec la meme graine partagent les memes positions.
|
||||
|
||||
Renvoie des tuples (x, y, taille, angle, miroir), du plus petit au plus
|
||||
grand : dessines dans cet ordre, les grands cranes passent devant.
|
||||
"""
|
||||
box = rings_bbox(rings)
|
||||
if box is None or size_min <= 0:
|
||||
return []
|
||||
size_max = max(size_max, size_min)
|
||||
step = size_min * spacing
|
||||
if step <= 0:
|
||||
return []
|
||||
row_h = step * 0.866
|
||||
margin = size_max * skull_radius()
|
||||
x0, y0, x1, y1 = box[0] - margin, box[1] - margin, box[2] + margin, box[3] + margin
|
||||
|
||||
j_start = int(math.floor((y0 - origin[1]) / row_h))
|
||||
j_end = int(math.ceil((y1 - origin[1]) / row_h))
|
||||
i_start = int(math.floor((x0 - origin[0]) / step)) - 1
|
||||
i_end = int(math.ceil((x1 - origin[0]) / step)) + 1
|
||||
|
||||
result = []
|
||||
for j in range(j_start, j_end + 1):
|
||||
for i in range(i_start, i_end + 1):
|
||||
# Une graine par case : le tirage ne depend pas de l'etendue de la
|
||||
# region, donc pas de la forme remplie.
|
||||
rng = random.Random((seed * 73856093) ^ (i * 19349663) ^ (j * 83492791))
|
||||
x = origin[0] + (i + 0.5 * (j % 2) + (rng.random() - 0.5) * 0.6) * step
|
||||
y = origin[1] + (j + (rng.random() - 0.5) * 0.6) * row_h
|
||||
size = random_size(rng, size_min, size_max)
|
||||
angle = (rng.random() * 2.0 - 1.0) * max_rotation
|
||||
flip = mirror and rng.random() < 0.5
|
||||
if not (x0 <= x <= x1 and y0 <= y <= y1):
|
||||
continue
|
||||
# Un crane tient dans un disque de rayon skull_radius() x taille.
|
||||
if not point_in_rings((x, y), rings) and \
|
||||
distance_to_rings((x, y), rings) > skull_radius() * size:
|
||||
continue
|
||||
result.append((x, y, size, angle, flip))
|
||||
result.sort(key=lambda p: p[2])
|
||||
return result
|
||||
@@ -0,0 +1,467 @@
|
||||
# coding=utf-8
|
||||
"""Tests de l'extension « Skull Pattern Fill » (pytest)."""
|
||||
|
||||
import math
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
import pytest
|
||||
|
||||
import boolean_ops
|
||||
from skull_fill_core import (
|
||||
Region, _Placed, apply_matrix, distance_to_rings, estimate_count, loops_to_d,
|
||||
parse_color, parse_loops, placement_matrix, point_in_rings, polylines_to_d,
|
||||
random_size, rings_bbox, rings_to_d, simplify_ring, skull_geometry,
|
||||
skull_paths, skull_placements, skull_radius, visible_gaps, visible_skulls)
|
||||
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
SHAPES = os.path.join(HERE, "tests", "data", "shapes.svg")
|
||||
SCALED = os.path.join(HERE, "tests", "data", "scaled.svg")
|
||||
|
||||
SQUARE = [[(0, 0), (100, 0), (100, 100), (0, 100)]]
|
||||
FRAME = [[(0, 0), (100, 0), (100, 100), (0, 100)], [(30, 30), (70, 30), (70, 70), (30, 70)]]
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Noyau (sans inkex)
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
def test_parse_color_inkscape_integer():
|
||||
assert parse_color("3014898687") == ("#b3b3b3", 1.0)
|
||||
assert parse_color(str(0xFF000080)) == ("#ff0000", round(0x80 / 255, 4))
|
||||
|
||||
|
||||
def test_parse_color_hex_and_invalid():
|
||||
assert parse_color("#123456") == ("#123456", 1.0)
|
||||
assert parse_color("#abc") == ("#aabbcc", 1.0)
|
||||
assert parse_color("pas une couleur") == ("#b3b3b3", 1.0)
|
||||
|
||||
|
||||
def test_polylines_to_d():
|
||||
d = polylines_to_d([[(0, 0), (1, 2)], [(3, 4), (5, 6)]], precision=1)
|
||||
assert d == "M 0.0,0.0 L 1.0,2.0 M 3.0,4.0 L 5.0,6.0"
|
||||
|
||||
|
||||
def test_parse_loops_roundtrip():
|
||||
d = "M 0,0 C 1,0 1,1 0,1 Z M 5,5 C 6,5 6,6 5,5 Z"
|
||||
loops = parse_loops(d)
|
||||
assert len(loops) == 2
|
||||
# Fermeture implicite ajoutee quand le dernier point n'est pas le depart.
|
||||
assert loops[0][-1][3] == (0.0, 0.0) and len(loops[0]) == 2
|
||||
assert len(loops[1]) == 1
|
||||
assert parse_loops(loops_to_d(loops, precision=1)) == loops
|
||||
with pytest.raises(ValueError):
|
||||
parse_loops("M 0,0 L 1,1 Z")
|
||||
|
||||
|
||||
def test_skull_geometry_fits_unit_frame():
|
||||
body, ink = skull_geometry()
|
||||
assert len(body) == 1 and len(ink) > 40
|
||||
xs = [p[0] for seg in body[0] for p in seg]
|
||||
ys = [p[1] for seg in body[0] for p in seg]
|
||||
assert min(ys) == pytest.approx(-0.5, abs=1e-3) and max(ys) == pytest.approx(0.5, abs=1e-3)
|
||||
assert min(xs) == pytest.approx(-max(xs), abs=1e-3) # cadre centre
|
||||
assert 0.7 < max(xs) - min(xs) < 0.9
|
||||
# L'encre reste dans le cadre de la silhouette.
|
||||
for loop in ink:
|
||||
for seg in loop:
|
||||
for x, y in seg:
|
||||
assert min(xs) - 1e-3 <= x <= max(xs) + 1e-3
|
||||
assert min(ys) - 1e-3 <= y <= max(ys) + 1e-3
|
||||
|
||||
|
||||
def test_skull_has_no_horns():
|
||||
"""Les cornes du dessin d'origine depassaient largement du crane."""
|
||||
body, _ink = skull_geometry()
|
||||
top = [p for seg in body[0] for p in seg if p[1] < -0.45]
|
||||
# Seule la calotte atteint le haut du cadre, autour du milieu.
|
||||
assert top and all(-0.25 < x < 0.35 for x, _y in top)
|
||||
|
||||
|
||||
def test_ink_loops_are_closed_and_continuous():
|
||||
_body, ink = skull_geometry()
|
||||
for loop in ink:
|
||||
assert loop[-1][3] == pytest.approx(loop[0][0], abs=1e-3)
|
||||
for a, b in zip(loop, loop[1:]):
|
||||
assert a[3] == b[0]
|
||||
|
||||
|
||||
def test_skull_is_seen_three_quarters():
|
||||
"""Crane tourne vers la gauche : le miroir donne une vraie variante."""
|
||||
body, _ink = skull_geometry()
|
||||
chin = max((seg[0] for seg in body[0]), key=lambda p: p[1])
|
||||
assert chin[0] < 0
|
||||
|
||||
|
||||
def evenodd_area(rings, box=(-20, -20, 120, 120), step=1.0):
|
||||
"""Aire d'anneaux en regle pair-impair, par comptage sur une grille."""
|
||||
count = 0
|
||||
y = box[1] + step / 2
|
||||
while y < box[3]:
|
||||
x = box[0] + step / 2
|
||||
while x < box[2]:
|
||||
count += point_in_rings((x, y), rings)
|
||||
x += step
|
||||
y += step
|
||||
return count * step * step
|
||||
|
||||
|
||||
def square(x, y, w, h):
|
||||
return [(x, y), (x + w, y), (x + w, y + h), (x, y + h)]
|
||||
|
||||
|
||||
# -- Moteur booleen ----------------------------------------------------------
|
||||
|
||||
def test_boolean_basic_operations():
|
||||
a, b = [square(0, 0, 10, 10)], [square(5, 5, 10, 10)]
|
||||
box = (-1, -1, 16, 16)
|
||||
assert evenodd_area(boolean_ops.intersection(a, b), box, 0.25) == pytest.approx(25, abs=0.5)
|
||||
assert evenodd_area(boolean_ops.difference(a, b), box, 0.25) == pytest.approx(75, abs=0.5)
|
||||
assert evenodd_area(boolean_ops.union(a + b), box, 0.25) == pytest.approx(175, abs=0.5)
|
||||
|
||||
|
||||
def test_boolean_shared_and_identical_edges():
|
||||
joined = boolean_ops.union([square(0, 0, 10, 10), square(10, 0, 10, 10)])
|
||||
assert len(joined) == 1 and len(joined[0]) == 4 # cote commun efface
|
||||
assert boolean_ops.difference([square(0, 0, 10, 10)], [square(0, 0, 10, 10)]) == []
|
||||
|
||||
|
||||
def test_boolean_nonzero_union_and_holes():
|
||||
# Regle non nulle : deux carres de meme sens se reunissent.
|
||||
ring = square(0, 0, 10, 10)
|
||||
assert evenodd_area(boolean_ops.union([ring, square(5, 5, 10, 10)], "nonzero"),
|
||||
(-1, -1, 16, 16), 0.25) == pytest.approx(175, abs=0.5)
|
||||
# Trou du sujet (pair-impair) conserve.
|
||||
pieces = boolean_ops.intersection(FRAME, [square(-10, -10, 120, 120)])
|
||||
assert evenodd_area(pieces) == pytest.approx(10000 - 1600)
|
||||
assert not point_in_rings((50, 50), pieces)
|
||||
|
||||
|
||||
def test_boolean_random_differences_match_sampling():
|
||||
rng = random.Random(7)
|
||||
|
||||
def blob(cx, cy, r, n):
|
||||
return [(cx + r * (0.6 + 0.4 * rng.random()) * math.cos(2 * math.pi * k / n),
|
||||
cy + r * (0.6 + 0.4 * rng.random()) * math.sin(2 * math.pi * k / n))
|
||||
for k in range(n)]
|
||||
|
||||
for _trial in range(15):
|
||||
a = [blob(rng.uniform(0, 30), rng.uniform(0, 30), rng.uniform(5, 15), rng.randint(5, 30))]
|
||||
b = [blob(rng.uniform(0, 30), rng.uniform(0, 30), rng.uniform(5, 15), rng.randint(5, 30))
|
||||
for _ in range(rng.randint(1, 4))]
|
||||
result = boolean_ops.difference(a, b, "evenodd", "nonzero")
|
||||
for _ in range(200):
|
||||
p = (rng.uniform(-15, 45), rng.uniform(-15, 45))
|
||||
expected = point_in_rings(p, a) and not any(point_in_rings(p, [r]) for r in b)
|
||||
assert point_in_rings(p, result) == expected
|
||||
|
||||
|
||||
# -- Geometrie visible -------------------------------------------------------
|
||||
|
||||
def test_rings_to_d_is_compact_and_exact():
|
||||
d = rings_to_d([[(0, 0), (1.234, 0), (1.234, 1), (1.2341, 1.0001), (0, 1)]], precision=2)
|
||||
assert d == "M0,0l1.23,0 0,1 -1.23,0z"
|
||||
assert rings_to_d([[(0, 0), (0.001, 0), (0, 0.001)]], precision=2) == ""
|
||||
|
||||
|
||||
def test_simplify_ring_drops_collinear_points():
|
||||
ring = [(0, 0), (5, 0), (10, 0), (10, 5), (10, 10), (5, 10), (0, 10), (0, 5)]
|
||||
assert sorted(simplify_ring(ring, 0.01)) == sorted([(0, 0), (10, 0), (10, 10), (0, 10)])
|
||||
|
||||
|
||||
def bodies(placements):
|
||||
return [_Placed(p, 0.01).body for p in placements]
|
||||
|
||||
|
||||
def test_visible_ink_is_never_under_a_skull_above():
|
||||
"""Rien de cache n'est ecrit : un point d'encre visible n'est sous aucun
|
||||
crane pose plus haut."""
|
||||
region = Region(SQUARE)
|
||||
placements = skull_placements(SQUARE, 20, 45, seed=3)
|
||||
order = {p: k for k, p in enumerate(placements)}
|
||||
outlines = bodies(placements)
|
||||
visible = visible_skulls(placements, region)
|
||||
assert visible
|
||||
rng = random.Random(1)
|
||||
checked = 0
|
||||
for placement, rings in visible:
|
||||
k = order[placement]
|
||||
box = rings_bbox(rings)
|
||||
for _ in range(60):
|
||||
p = (rng.uniform(box[0], box[2]), rng.uniform(box[1], box[3]))
|
||||
if not point_in_rings(p, rings):
|
||||
continue
|
||||
checked += 1
|
||||
assert 0 <= p[0] <= 100 and 0 <= p[1] <= 100 # dans la forme
|
||||
for above in outlines[k + 1:]:
|
||||
assert not point_in_rings(p, [above])
|
||||
assert checked > 100
|
||||
|
||||
|
||||
def test_visible_skull_on_top_keeps_all_its_ink():
|
||||
region = Region(SQUARE)
|
||||
_body, ink = skull_geometry()
|
||||
alone = [(50, 50, 30, 10, True)]
|
||||
(placement, rings), = visible_skulls(alone, region)
|
||||
assert placement == alone[0] and len(rings) == len(_Placed(alone[0], 0.01).ink)
|
||||
|
||||
|
||||
def test_fully_hidden_skull_is_dropped():
|
||||
region = Region(SQUARE)
|
||||
small, big = (50, 50, 8, 0, False), (50, 50, 40, 0, False)
|
||||
visible = visible_skulls([small, big], region)
|
||||
assert [p for p, _rings in visible] == [big]
|
||||
|
||||
|
||||
def test_skull_outside_the_shape_writes_nothing():
|
||||
region = Region(SQUARE)
|
||||
assert visible_skulls([(140, 50, 30, 0, False)], region) == []
|
||||
|
||||
|
||||
def test_gaps_are_the_shape_minus_the_skulls():
|
||||
region = Region(SQUARE)
|
||||
placements = skull_placements(SQUARE, 20, 45, spacing=1.2, seed=3)
|
||||
outlines = bodies(placements)
|
||||
gaps = visible_gaps(placements, region)
|
||||
rng = random.Random(2)
|
||||
for _ in range(400):
|
||||
p = (rng.uniform(-5, 105), rng.uniform(-5, 105))
|
||||
expected = point_in_rings(p, SQUARE) and not any(point_in_rings(p, [o]) for o in outlines)
|
||||
assert point_in_rings(p, gaps) == expected
|
||||
|
||||
|
||||
def test_placement_matrix_scale_rotation_mirror():
|
||||
m = placement_matrix(10, 20, 2, 0, False)
|
||||
assert apply_matrix(m, (0, 0)) == (10, 20)
|
||||
assert apply_matrix(m, (1, 0)) == pytest.approx((12, 20))
|
||||
m = placement_matrix(0, 0, 1, 90, False) # sens horaire a l'ecran
|
||||
assert apply_matrix(m, (1, 0)) == pytest.approx((0, 1))
|
||||
m = placement_matrix(0, 0, 1, 0, True)
|
||||
assert apply_matrix(m, (1, 0)) == pytest.approx((-1, 0))
|
||||
assert apply_matrix(m, (0, 1)) == pytest.approx((0, 1))
|
||||
|
||||
|
||||
def test_loops_to_d_and_skull_paths():
|
||||
loop = parse_loops("M 0,0 C 1,0 1,0 1,0 C 1,1 1,1 1,1 C 0,0 0,0 0,0 Z")[0]
|
||||
d = loops_to_d([loop], placement_matrix(5, 5, 1), precision=1)
|
||||
assert d.startswith("M 5.0,5.0 C") and d.endswith("Z") and d.count("C ") == 3
|
||||
body, ink = skull_paths((50, 50, 20, 15, True))
|
||||
assert "transform" not in body
|
||||
assert body.count("M ") == 1 and ink.count("M ") > 40
|
||||
|
||||
|
||||
def test_rings_bbox_point_in_rings_with_hole():
|
||||
assert rings_bbox(FRAME) == (0, 0, 100, 100)
|
||||
assert rings_bbox([]) is None
|
||||
assert point_in_rings((10, 10), FRAME)
|
||||
assert not point_in_rings((50, 50), FRAME) # dans le trou
|
||||
assert not point_in_rings((150, 50), FRAME)
|
||||
assert distance_to_rings((50, 50), FRAME) == pytest.approx(20)
|
||||
assert distance_to_rings((110, 50), SQUARE) == pytest.approx(10)
|
||||
|
||||
|
||||
def test_random_size_stays_in_range_and_favors_small():
|
||||
import random
|
||||
rng = random.Random(3)
|
||||
sizes = [random_size(rng, 10, 40) for _ in range(2000)]
|
||||
assert min(sizes) >= 10 and max(sizes) <= 40
|
||||
small = sum(1 for s in sizes if s < 20)
|
||||
assert small > 0.7 * len(sizes)
|
||||
assert random_size(rng, 10, 10) == 10
|
||||
|
||||
|
||||
def test_placements_cover_region_and_are_sorted():
|
||||
placements = skull_placements(SQUARE, 10, 30, spacing=0.7, seed=1)
|
||||
sizes = [p[2] for p in placements]
|
||||
assert sizes == sorted(sizes) # grands par-dessus
|
||||
assert all(10 <= s <= 30 for s in sizes)
|
||||
# Tout point de la region est proche du centre d'un crane.
|
||||
for x in range(5, 100, 10):
|
||||
for y in range(5, 100, 10):
|
||||
nearest = min(math.hypot(x - p[0], y - p[1]) for p in placements)
|
||||
assert nearest < 10 * 0.7
|
||||
# Aucun crane loin de la region.
|
||||
for x, y, size, _a, _m in placements:
|
||||
assert point_in_rings((x, y), SQUARE) or distance_to_rings((x, y), SQUARE) <= skull_radius() * size
|
||||
|
||||
|
||||
def test_placements_respect_rotation_and_mirror():
|
||||
placements = skull_placements(SQUARE, 10, 20, max_rotation=12, mirror=False)
|
||||
assert all(abs(p[3]) <= 12 for p in placements)
|
||||
assert not any(p[4] for p in placements)
|
||||
flips = [p[4] for p in skull_placements(SQUARE, 10, 20, mirror=True)]
|
||||
assert any(flips) and not all(flips)
|
||||
|
||||
|
||||
def test_placements_skip_holes():
|
||||
placements = skull_placements(FRAME, 5, 5, spacing=0.7)
|
||||
assert not any(abs(p[0] - 50) < 10 and abs(p[1] - 50) < 10 for p in placements)
|
||||
|
||||
|
||||
def test_placements_reproducible_and_independent_of_region():
|
||||
a = skull_placements(SQUARE, 10, 30, seed=4)
|
||||
assert a == skull_placements(SQUARE, 10, 30, seed=4)
|
||||
assert a != skull_placements(SQUARE, 10, 30, seed=5)
|
||||
# Une region plus grande contient les memes cranes au centre.
|
||||
big = skull_placements([[(-100, -100), (200, -100), (200, 200), (-100, 200)]], 10, 30, seed=4)
|
||||
centre = [p for p in a if 20 < p[0] < 80 and 20 < p[1] < 80]
|
||||
assert centre and all(p in big for p in centre)
|
||||
|
||||
|
||||
def test_placements_empty_inputs():
|
||||
assert skull_placements([], 10, 20) == []
|
||||
assert skull_placements(SQUARE, 0, 20) == []
|
||||
assert estimate_count([], 10, 0.7) == 0
|
||||
assert estimate_count(SQUARE, 10, 0.7) > 100
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Bout en bout (necessite inkex)
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
def run_extension(tmp_path, *args, source=SHAPES):
|
||||
pytest.importorskip("inkex")
|
||||
from skull_fill import SkullFill
|
||||
out = tmp_path / "out.svg"
|
||||
SkullFill().run([*args, "--output={}".format(out), source])
|
||||
# Apres un message d'erreur, inkex n'ecrit pas de fichier de sortie.
|
||||
return out.read_text(encoding="utf-8") if out.exists() else ""
|
||||
|
||||
|
||||
def written_rings(svg):
|
||||
"""Anneaux de chaque chemin ecrit par l'extension (M ... l ... z)."""
|
||||
import inkex
|
||||
paths = []
|
||||
for d in re.findall(r' d="(M[^"]*z)"', svg):
|
||||
rings = []
|
||||
for segment in inkex.Path(d).to_absolute():
|
||||
if segment.letter == "M":
|
||||
rings.append([(segment.x, segment.y)])
|
||||
elif segment.letter == "L":
|
||||
rings[-1].append((segment.x, segment.y))
|
||||
paths.append(rings)
|
||||
assert paths
|
||||
return paths
|
||||
|
||||
|
||||
def test_end_to_end_default(tmp_path):
|
||||
svg = run_extension(tmp_path, "--id=rect1")
|
||||
assert "Skull fill" in svg
|
||||
assert 'id="rect1"' in svg
|
||||
# Pret pour le laser : ni masque, ni clone, ni blanc, que des chemins pleins.
|
||||
for forbidden in ("clipPath", "clip-path", "<mask", "<use", "fill:#ffffff"):
|
||||
assert forbidden not in svg
|
||||
# Tout ce qui est ecrit reste dans le rectangle (10, 10, 60, 50).
|
||||
for rings in written_rings(svg):
|
||||
for ring in rings:
|
||||
for x, y in ring:
|
||||
assert 10 - 1e-2 <= x <= 60 + 1e-2 and 10 - 1e-2 <= y <= 50 + 1e-2
|
||||
|
||||
|
||||
def test_end_to_end_non_standard_document_scale(tmp_path):
|
||||
"""Page de 400 mm pour 538,72 unites : svg.unittouu() s'y tromperait."""
|
||||
svg = run_extension(tmp_path, "--id=rect1", "--size_min=20", "--size_max=20",
|
||||
"--max_rotation=0", "--mirror=false", "--fill_gaps=false",
|
||||
source=SCALED)
|
||||
heights = []
|
||||
for rings in written_rings(svg):
|
||||
box = rings_bbox(rings)
|
||||
heights.append(box[3] - box[1])
|
||||
# Les cranes du dessus, entiers, mesurent 20 mm du document.
|
||||
assert max(heights) == pytest.approx(20 * 538.72053 / 400, abs=0.05)
|
||||
|
||||
|
||||
def test_end_to_end_removes_original(tmp_path):
|
||||
svg = run_extension(tmp_path, "--id=rect1", "--keep_original=false")
|
||||
assert 'id="rect1"' not in svg
|
||||
|
||||
|
||||
def test_end_to_end_color_and_gaps(tmp_path):
|
||||
svg = run_extension(tmp_path, "--id=circle1", "--ink_color={}".format(0x336699FF))
|
||||
assert re.search(r"fill:#336699", svg)
|
||||
assert "Gaps" in svg
|
||||
svg = run_extension(tmp_path, "--id=circle1", "--fill_gaps=false")
|
||||
assert "Gaps" not in svg
|
||||
|
||||
|
||||
def test_end_to_end_group_and_hole(tmp_path):
|
||||
svg = run_extension(tmp_path, "--id=path2", "--size_min=6", "--size_max=12")
|
||||
# Le trou (35..65 x 80..100) reste vide : aucun chemin ne le remplit.
|
||||
for rings in written_rings(svg):
|
||||
for x in range(37, 64, 2):
|
||||
for y in range(82, 99, 2):
|
||||
assert not point_in_rings((x, y), rings)
|
||||
svg = run_extension(tmp_path, "--id=group1")
|
||||
assert "Skull fill" in svg
|
||||
|
||||
|
||||
def test_end_to_end_too_many_skulls(tmp_path, capsys):
|
||||
svg = run_extension(tmp_path, "--id=rect1", "--size_min=0.1")
|
||||
assert "Skull fill" not in svg
|
||||
assert "skulls would be needed" in capsys.readouterr().err
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Traductions
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
def test_translations_up_to_date_and_complete():
|
||||
"""Chaque texte du .inx et des .py a sa traduction dans chaque catalogue."""
|
||||
import gettext
|
||||
import i18n
|
||||
|
||||
msgids = [msgid for msgid, _refs in i18n.extract()]
|
||||
assert "Skull Pattern Fill" in msgids
|
||||
assert "mm" not in msgids # unites marquees translatable="no"
|
||||
|
||||
for language in i18n.LANGUAGES:
|
||||
entries = i18n.read_po(i18n.po_path(language))
|
||||
missing = [m for m in msgids if not entries.get(m, ("", False))[0]]
|
||||
assert not missing, "{}.po incomplet : {}".format(language, missing)
|
||||
|
||||
catalog = gettext.translation(i18n.DOMAIN, i18n.LOCALE_DIR, [language])
|
||||
for msgid in msgids:
|
||||
assert catalog.gettext(msgid) == entries[msgid][0], \
|
||||
"{} : .mo a recompiler (python i18n.py)".format(language)
|
||||
|
||||
|
||||
def test_po_roundtrip(tmp_path):
|
||||
import i18n
|
||||
|
||||
messages = [("Simple", ["a"]), ('Quote "x" and \\ back', ["a"]),
|
||||
("Two\nlines", ["a"]), ("Tab\tend\n", ["a"])]
|
||||
path = str(tmp_path / "xx.po")
|
||||
i18n.write_po(path, "fr", messages,
|
||||
{m: ("<" + m + ">", False) for m, _r in messages})
|
||||
entries = i18n.read_po(path)
|
||||
for msgid, _refs in messages:
|
||||
assert entries[msgid] == ("<" + msgid + ">", False)
|
||||
|
||||
|
||||
def test_inx_matches_arguments():
|
||||
"""Chaque <param> du .inx a son add_argument, et inversement, memes defauts."""
|
||||
root = ET.parse(os.path.join(HERE, "skull_fill.inx")).getroot()
|
||||
params = {elem.get("name"): (elem.text or "").strip() for elem in root.iter()
|
||||
if elem.tag.rsplit("}", 1)[-1] == "param"}
|
||||
with open(os.path.join(HERE, "skull_fill.py"), encoding="utf-8") as handle:
|
||||
source = handle.read()
|
||||
arguments = dict(re.findall(r'add_argument\("--(\w+)".*default="?([^")]+)"?\)', source))
|
||||
assert set(params) == set(arguments)
|
||||
for name, default in arguments.items():
|
||||
if name in ("tab", "unit", "motif"):
|
||||
continue
|
||||
inx = params[name]
|
||||
if default in ("True", "False"):
|
||||
assert inx == default.lower(), name
|
||||
else:
|
||||
assert float(inx) == float(default), name
|
||||
|
||||
|
||||
def test_inx_images_exist():
|
||||
"""Les images de la boite de dialogue sont presentes (chemin relatif au .inx)."""
|
||||
root = ET.parse(os.path.join(HERE, "skull_fill.inx")).getroot()
|
||||
for elem in root.iter():
|
||||
if elem.tag.rsplit("}", 1)[-1] == "image":
|
||||
assert os.path.isfile(os.path.join(HERE, elem.text.strip())), elem.text
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Echelle non standard (page redimensionnee) : 1 mm = 1,3468 unite utilisateur -->
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="400mm" height="400mm"
|
||||
viewBox="0 0 538.72053 538.72054">
|
||||
<rect id="rect1" x="100" y="100" width="200" height="100" fill="#e9ecef" stroke="#212529"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 334 B |
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="200mm" height="120mm" viewBox="0 0 200 120">
|
||||
<rect id="rect1" x="10" y="10" width="50" height="40" fill="#e9ecef" stroke="#212529"/>
|
||||
<circle id="circle1" cx="100" cy="30" r="22" fill="#e9ecef" stroke="#212529"/>
|
||||
<path id="path1" d="M 140,10 C 190,0 200,60 160,55 C 130,52 120,30 140,10 Z"
|
||||
fill="#e9ecef" stroke="#212529"/>
|
||||
<!-- Forme trouee : le sous-chemin interne est un trou (pair-impair) -->
|
||||
<path id="path2" d="M 10,65 H 90 V 115 H 10 Z M 35,80 H 65 V 100 H 35 Z"
|
||||
fill="#e9ecef" fill-rule="evenodd" stroke="#212529"/>
|
||||
<g id="group1" transform="translate(100,65)">
|
||||
<ellipse id="ellipse1" cx="45" cy="25" rx="40" ry="20" fill="#e9ecef" stroke="#212529"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 790 B |