File: solidcolor.py

package info (click to toggle)
svgwrite 1.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,304 kB
  • sloc: python: 12,524; makefile: 116; sh: 5
file content (29 lines) | stat: -rw-r--r-- 804 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python3
#coding:utf-8
# Author:  mozman
# Purpose: svg examples
# Created: 26.10.2016
# Copyright (C) 2016, Manfred Moitzi
# License: MIT License

try:
    import svgwrite
except ImportError:
    # if svgwrite is not 'installed' append parent dir of __file__ to sys.path
    import sys
    from pathlib import Path
    sys.path.insert(0, str(Path(__file__).resolve().parent.parent))

import svgwrite

def solid_color(name):
    dwg = svgwrite.Drawing(name, size=('20cm', '15cm'), profile='tiny', debug=True)

    # set user coordinate space
    dwg.viewbox(width=200, height=150)
    my_color = dwg.defs.add(dwg.solidColor(color='red'))
    dwg.add(dwg.circle((100, 100), 50, fill=my_color.get_paint_server()))
    dwg.save()

if __name__ == '__main__':
    solid_color("solid_color.svg")