Skip to content
SvgFormat.py 42 KiB
Newer Older
####################################################################################################
#
# Patro - A Python library to make patterns for fashion design
# Copyright (C) 2017 Fabrice Salvaire
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
####################################################################################################

"""This modules implements the `SVG <https://www.w3.org/Graphics/SVG>`_ file format.

References:

* `SVG 1.1 (Second Edition) W3C Recommendation 16 August 2011 <https://www.w3.org/TR/SVG11>`_

"""

####################################################################################################

__all__ = [
    'Svg',
    'Anchor',
    'AltGlyph',
    'AltGlyphDef',
    'AltGlyphItem',
    'Animate',
    'AnimateMotion',
    'AnimateTransform',
    'Circle',
    'ClipPath',
    'ColorProfile',
    'Cursor',
    'Defs',
    'Desc',
    'Ellipse',
    'FeBlend',
    'Group',
    'Image',
    'Line',
    'LinearGradient',
    'Marker',
    'Mask',
    'Path',
    'Pattern',
    'Polyline',
    'Polygon',
    'RadialGradient',
    'Rect',
    'Stop',
    'Text',
    'TextRef',
    'TextSpan',
    'Use',
    ]

####################################################################################################

import logging

from Patro.Common.Xml.Objectivity import (
    # BoolAttribute,
    IntAttribute, FloatAttribute,
    FloatListAttribute,
    StringAttribute,
    XmlObjectAdaptator,
    TextXmlObjectAdaptator,
# Fixme: should we mix SVG format and ... ???
from Patro.GeometryEngine.Path import Path2D
from Patro.GeometryEngine.Transformation import AffineTransformation2D
Fabrice Salvaire's avatar
Fabrice Salvaire committed
from Patro.GeometryEngine.Vector import Vector2D

####################################################################################################

_module_logger = logging.getLogger(__name__)

####################################################################################################

def split_space_list(value):
    return [x for x in value.split(' ') if x]

####################################################################################################
#
# Conditional Processing Attributes
#   requiredFeatures
#   requiredExtensions
#   systemLanguage
#
####################################################################################################

####################################################################################################
#
# Core Attribute
#   id
#   xml:base
#   xml:lang
#   xml:space
#
####################################################################################################

class IdMixin:

    """Core attribute"""

    __attributes__ = (
        StringAttribute('id'),
    )

####################################################################################################
#
# Graphical Event Attributes
#   onactivate
#   onclick
#   onfocusin
#   onfocusout
#   onload
#   onmousedown
#   onmousemove
#   onmouseout
#   onmouseover
#   onmouseup
#
####################################################################################################

####################################################################################################

class PresentationAttributes:

    # https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute

    # Fixme: type !!!

    alignment_baseline = None # check
    baseline_shift = None # check
    clip = None # check
    clip_path = None # check
    clip_rule = None # check
    color = None # check
    color_interpolation = None # check
    color_interpolation_filters = None # check
    color_profile = None # check
    color_rendering = None # check
    cursor = None # check
    direction = None # check
    display = None # check
    dominant_baseline = None # check
    enable_background = None # check
    fill = None
    fill_opacity = 1
    fill_rule = 'nonzero'
    #! filter = None # check
    flood_color = None # check
    flood_opacity = None # check
    font_family = None # check
    font_size = None # check
    font_size_adjust = None # check
    font_stretch = None # check
    font_style = None # check
    font_variant = None # check
    font_weight = None # check
    glyph_orientation_horizontal = None # check
    glyph_orientation_vertical = None # check
    image_rendering = None # check
    kerning = None # check
    letter_spacing = None # check
    lighting_color = None # check
    marker_end = None # check
    marker_mid = None # check
    marker_start = None # check
    mask = None # check
    opacity = 1
    overflow = None # check
    paint_order = None
    pointer_events = None # check
    shape_rendering = None # check
    stop_color = None # check
    stop_opacity = None # check
    stroke = None
    stroke_dasharray = None # check
    stroke_dashoffset = None # check
    stroke_linecap = 'butt'
    stroke_linejoin = 'miter'
    stroke_miterlimit = 4
    stroke_opacity = 1
    stroke_width = 1 # px
    style = None
    text_anchor = None # check
    text_decoration = None # check
Loading full blame...