Задание:
Придумайте линейный орнамент и разработайте расширение Inkscape для его рисования.
Расширение должно запрашивать у пользователя:
Отчет о выполненной работе должен содержать:
Примеры орнаментов (не использовать!):
Файл
my.inx:
<?xml
version="1.0" encoding="windows-1251"?>
<inkscape-extension>
<_name>Рисовать квадрат</_name>
<id>www.prolans.ru</id>
<dependency
type="executable" location="extensions">my.py</dependency>
<dependency type="executable"
location="extensions">inkex.py</dependency>
<param name="alength"
type="int" min="0.0"
max="100" _gui-text="Длина стороны квадрата">10</param>
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu _name="Мои расширения"/>
</effects-menu>
</effect>
<script>
<command reldir="extensions"
interpreter="python">my.py</command>
</script>
</inkscape-extension>
Файл my.py:
import inkex
class My(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
self.OptionParser.add_option("-a", "--alength",
action="store", type="int",
dest="square_length",
default=10.0,
help="length")
def effect(self):
a = self.options.square_length
s =
'M 0,0 L '+str(a)+',0 L '+str(a)+','+str(a)+' L 0,'+str(a)+' z'
line_attribs = {'stroke': '#000000',
'stroke-width':'1px',
'fill': 'none',
'd':s}
inkex.etree.SubElement(self.current_layer, inkex.addNS('path','svg'), line_attribs )
if __name__ == '__main__':
e = My()
e.affect()
Полезные ссылки:
http://wiki.inkscape.org/wiki/index.php/Inkscape
http://wiki.inkscape.org/wiki/index.php/Generating_objects_from_extensions