Compare commits
No commits in common. "5dca0797672be6c9af3e01dd322bd272dc8b72a8" and "2105bb96a08102ec996ffba74a7262acca8d714b" have entirely different histories.
5dca079767
...
2105bb96a0
3
.gitignore
vendored
3
.gitignore
vendored
@ -9,6 +9,3 @@ __pycache__/
|
||||
|
||||
# SVG intermediaires du schema (regeneres par docs/schema_parametres.py)
|
||||
docs/*.svg
|
||||
|
||||
# Page de presentation : hors depot (publiee par site/deploy.ps1)
|
||||
site/
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 316 KiB After Width: | Height: | Size: 316 KiB |
@ -330,12 +330,11 @@ def panel_edge():
|
||||
.format(fmt(cx), fmt(cy), fmt(r), EDGE))
|
||||
out.append('<circle cx="{}" cy="{}" r="{}" fill="none" stroke="{}" stroke-width="1.4" '
|
||||
'stroke-dasharray="5,4"/>'.format(fmt(cx), fmt(cy), fmt(r - margin), DIM))
|
||||
# Cote et legende cote gauche : a droite, la legende sortirait du panneau
|
||||
u = unit(145)
|
||||
u = unit(35)
|
||||
dimension((cx + (r - margin) * u[0], cy + (r - margin) * u[1]),
|
||||
(cx + r * u[0], cy + r * u[1]), 0, "", color=DIM)
|
||||
text(cx + (r + 12) * u[0], cy + (r + 12) * u[1] - 4, T["margin"], size=17,
|
||||
color=DIM, anchor="end", weight="bold")
|
||||
color=DIM, weight="bold")
|
||||
text(cx, cy + r + 30 * FS, T["whole"], size=17, anchor="middle",
|
||||
weight="bold", halo=False)
|
||||
note(30, H - 28, T["note3"])
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 279 KiB After Width: | Height: | Size: 278 KiB |
51
y_pattern.py
51
y_pattern.py
@ -18,7 +18,6 @@ import sys
|
||||
import inkex
|
||||
from inkex import bezier
|
||||
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 pattern_core.
|
||||
@ -27,60 +26,12 @@ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
from pattern_core import (fill_pattern, parse_color, polylines_to_d, # noqa: E402
|
||||
rings_bbox)
|
||||
|
||||
|
||||
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 « yarrowpattern » 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)
|
||||
|
||||
|
||||
def flatten_path(path, flatness):
|
||||
"""Convertit un inkex.Path en liste d'anneaux (listes de points)."""
|
||||
csp = path.to_superpath()
|
||||
@ -135,7 +86,7 @@ class YArrowPattern(inkex.EffectExtension):
|
||||
return
|
||||
|
||||
def to_uu(value):
|
||||
return length_to_uu(self.svg, value, opt.unit)
|
||||
return self.svg.unittouu("{}{}".format(value, opt.unit))
|
||||
|
||||
period = to_uu(opt.period)
|
||||
stroke_width = to_uu(opt.stroke_width)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user