:tocdepth: 3 :py:mod:`gws.lib.svg.draw` ========================== .. py:module:: gws.lib.svg.draw .. autoapi-nested-parse:: SVG builders. **Source code:** :source:`gws.lib.svg.draw` Module Contents --------------- .. py:data:: DEFAULT_FONT_SIZE :value: 10 .. py:data:: DEFAULT_MARKER_SIZE :value: 10 .. py:data:: DEFAULT_POINT_SIZE :value: 10 .. py:function:: shape_to_fragment(shape: gws.Shape, view: gws.MapView, label: str = None, style: gws.Style = None) -> list[gws.XmlElement] Convert a shape to a list of XmlElements (a "fragment"). .. py:function:: soup_to_fragment(view: gws.MapView, points: list[gws.Point], tags: list) -> list[gws.XmlElement] Convert an svg "soup" to a list of XmlElements (a "fragment"). A soup has two components: - a list of points, in the map coordinate system - a list of tuples suitable for `xmlx.tag` input (tag-name, {atts}, child1, child2....) The idea is to represent client-side svg drawings (e.g. dimensions) in a resolution-independent way First, points are converted to pixels using the view's transform. Then, each tag's attributes are iterated. If any attribute value is an array, it's assumed to be a 'function'. The first element is a function name, the rest are arguments. Attribute 'functions' are - ['x', n] - returns points[n][0] - ['y', n] - returns points[n][1] - ['r', p1, p2, r] - computes a slope between points[p1] points[p2] and returns a string `rotate(slope, points[r].x, points[r].y)`